22 $this->worksheet = $workSheet;
27 public function load(): void
32 $this->worksheetXml->extLst
39 foreach ($xmlSheet->conditionalFormatting as $conditional) {
40 foreach ($conditional->cfRule as $cfRule) {
41 if (Conditional::isValidConditionType((
string) $cfRule[
'type']) && isset($this->dxfs[(
int) ($cfRule[
'dxfId'])])) {
42 $conditionals[(string) $conditional[
'sqref']][(
int) ($cfRule[
'priority'])] = $cfRule;
43 } elseif ((
string) $cfRule[
'type'] == Conditional::CONDITION_DATABAR) {
44 $conditionals[(string) $conditional[
'sqref']][(
int) ($cfRule[
'priority'])] = $cfRule;
54 foreach ($conditionals as $ref => $cfRules) {
59 $cellBlocks = explode(
' ', str_replace(
'$',
'', strtoupper($ref)));
60 foreach ($cellBlocks as $cellBlock) {
61 $worksheet->
getStyle($cellBlock)->setConditionalStyles($conditionalStyles);
68 $conditionalFormattingRuleExtensions = ConditionalFormattingRuleExtension::parseExtLstXml($extLst);
69 $conditionalStyles = [];
70 foreach ($cfRules as $cfRule) {
72 $objConditional->setConditionType((
string) $cfRule[
'type']);
73 $objConditional->setOperatorType((
string) $cfRule[
'operator']);
75 if ((
string) $cfRule[
'text'] !=
'') {
76 $objConditional->setText((
string) $cfRule[
'text']);
79 if (isset($cfRule[
'stopIfTrue']) && (
int) $cfRule[
'stopIfTrue'] === 1) {
80 $objConditional->setStopIfTrue(
true);
83 if (count($cfRule->formula) > 1) {
84 foreach ($cfRule->formula as $formula) {
85 $objConditional->addCondition((
string) $formula);
88 $objConditional->addCondition((
string) $cfRule->formula);
91 if (isset($cfRule->dataBar)) {
92 $objConditional->setDataBar(
96 $objConditional->setStyle(clone $this->dxfs[(
int) ($cfRule[
'dxfId'])]);
99 $conditionalStyles[] = $objConditional;
102 return $conditionalStyles;
109 if (isset($cfRule->dataBar[
'showValue'])) {
110 $dataBar->setShowValue((
bool) $cfRule->dataBar[
'showValue']);
115 $cfvoXml = $cfRule->dataBar->cfvo;
117 foreach ((count($cfvoXml) > 1 ? $cfvoXml : [$cfvoXml]) as $cfvo) {
118 if ($cfvoIndex === 0) {
121 if ($cfvoIndex === 1) {
128 if (isset($cfRule->dataBar->color)) {
129 $dataBar->setColor((
string) $cfRule->dataBar->color[
'rgb']);
139 if (isset($cfRule->extLst)) {
140 $ns = $cfRule->extLst->getNamespaces(
true);
141 foreach ((count($cfRule->extLst) > 0 ? $cfRule->extLst->ext : [$cfRule->extLst->ext]) as $ext) {
142 $extId = (string) $ext->children($ns[
'x14'])->id;
143 if (isset($conditionalFormattingRuleExtensions[$extId]) && (
string) $ext[
'uri'] ===
'{B025F937-C7B1-47D3-B67F-A62EFF666E3E}') {
readDataBarOfConditionalRule($cfRule, $conditionalFormattingRuleExtensions)
getStyle($pCellCoordinate)
Get style for cell.
readStyleRules($cfRules, $extLst)
__construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml, array $dxfs=[])
setConditionalStyles(Worksheet $worksheet, array $conditionals, $xmlExtLst)
readDataBarExtLstOfConditionalRule(ConditionalDataBar $dataBar, $cfRule, $conditionalFormattingRuleExtensions)
readConditionalStyles($xmlSheet)