Skip to content

Commit 0f515ee

Browse files
committed
Xls Conditional Format Improvements
While researching another problem, I noticed that font color was not working as expected for Xls Conditional Formats, at least not when a "non-standard" color is used. In such cases, the color might wind up being rendered as black. The reason is as follows. Xls Writer includes a color palette which is dynamically generated from the (non-Conditional) styles used in the workbook. Any colors used in the workbook are indexes to this dynamic palette. However, Conditional colors use a static palette found in class ColorMap to determine the index, so the determination of index will often not find a match, and, if a match is found, it is not necessarily correct. (Also, the ColorMap method was case-sensitive and needs to be insensitive.) In order to correct this, the `addColor` method in Xls Writer Workbook needs to be accessible to the Conditional logic which is found in Xls Writer Worksheet. This is accomplished by passing the Workbook in the Worksheet's constructor, and changing the method to public, and changing Conditional Font to use this method rather than ColorMap. The logic for Conditional Fill colors is similarly changed. Although Xls Conditional Fill has appeared to just not work, I was finally able to figure out the problem. Excel Xls Conditional Fill with fill type Solid requires that the fill color be specified as startColor, and that endColor be omitted. Our conditional samples used endColor, and are now changed to use startColor instead; the same is true for our online documentation, and for some tests. Xlsx continues to work as expected, and now Xls does at least some of the time. If the condition is one that Excel Xls does not recognize (e.g. cell contains), it will, of course, not work. A surprising situation that also doesn't work is the use of ISODD or ISEVEN in formulas. Those are "add-in functions" which are handled differently than other functions, and I'm not sure how to support them. I will document this in issue PHPOffice#3403. Samples 08_Conditional_Formatting(_2) had produced corrupt Xls versions. This turned out to be because the code was using hash codes to avoid having to write out duplicate conditionals; this is often a good idea, but not in this case. Allowing the duplicates fixes the corruption problem. Conditional Border colors also ought to figure in this change, but the current code does not support Border colors, and I have not yet been able to figure out how to implement it (BIFF format can be very messy to figure out). With this change, I could delete ColorMap altogether. However, it is a public class with a static public method, so maybe someone is using it for a purpose I'm not familiar with. I will just deprecate it.
1 parent 563de5f commit 0f515ee

22 files changed

+144
-63
lines changed

docs/topics/conditional-formatting.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $conditional->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERA
4343
$conditional->addCondition(80);
4444
$conditional->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN);
4545
$conditional->getStyle()->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
46-
$conditional->getStyle()->getFill()->getEndColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
46+
$conditional->getStyle()->getFill()->getStartColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
4747

4848
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1:A10')->getConditionalStyles();
4949
$conditionalStyles[] = $conditional;
@@ -63,7 +63,7 @@ $wizard = $wizardFactory->newRule(\PhpOffice\PhpSpreadsheet\Style\ConditionalFor
6363
$wizard->greaterThan(80);
6464
$wizard->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN);
6565
$wizard->getStyle()->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
66-
$wizard->getStyle()->getFill()->getEndColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
66+
$wizard->getStyle()->getFill()->getStartColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
6767

6868
$conditional = $wizard->getConditional();
6969
```
@@ -84,7 +84,7 @@ $conditional2->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPER
8484
$conditional2->addCondition(10);
8585
$conditional2->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKRED);
8686
$conditional2->getStyle()->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
87-
$conditional2->getStyle()->getFill()->getEndColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
87+
$conditional2->getStyle()->getFill()->getStartColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED);
8888

8989
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1:A10')->getConditionalStyles();
9090
$conditionalStyles[] = $conditional2;
@@ -98,7 +98,7 @@ $wizard = $wizardFactory->newRule(\PhpOffice\PhpSpreadsheet\Style\ConditionalFor
9898
$wizard->lessThan(10);
9999
$wizard->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN);
100100
$wizard->getStyle()->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
101-
$wizard->getStyle()->getFill()->getEndColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
101+
$wizard->getStyle()->getFill()->getStartColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN);
102102

103103
$conditional = $wizard->getConditional();
104104
```

samples/ConditionalFormatting/01_Basic_Comparisons.php

-6
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,16 @@
7474
$yellowStyle->getFill()
7575
->setFillType(Fill::FILL_SOLID)
7676
->getStartColor()->setARGB(Color::COLOR_YELLOW);
77-
$yellowStyle->getFill()
78-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
7977
$yellowStyle->getFont()->setColor(new Color(Color::COLOR_BLUE));
8078
$greenStyle = new Style(false, true);
8179
$greenStyle->getFill()
8280
->setFillType(Fill::FILL_SOLID)
8381
->getStartColor()->setARGB(Color::COLOR_GREEN);
84-
$greenStyle->getFill()
85-
->getEndColor()->setARGB(Color::COLOR_GREEN);
8682
$greenStyle->getFont()->setColor(new Color(Color::COLOR_DARKRED));
8783
$redStyle = new Style(false, true);
8884
$redStyle->getFill()
8985
->setFillType(Fill::FILL_SOLID)
9086
->getStartColor()->setARGB(Color::COLOR_RED);
91-
$redStyle->getFill()
92-
->getEndColor()->setARGB(Color::COLOR_RED);
9387
$redStyle->getFont()->setColor(new Color(Color::COLOR_GREEN));
9488

9589
// Set conditional formatting rules and styles

samples/ConditionalFormatting/02_Text_Comparisons.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@
7373
$yellowStyle = new Style(false, true);
7474
$yellowStyle->getFill()
7575
->setFillType(Fill::FILL_SOLID)
76-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
76+
->getStartColor()->setARGB(Color::COLOR_YELLOW);
7777
$yellowStyle->getFont()->setColor(new Color(Color::COLOR_BLUE));
7878
$greenStyle = new Style(false, true);
7979
$greenStyle->getFill()
8080
->setFillType(Fill::FILL_SOLID)
81-
->getEndColor()->setARGB(Color::COLOR_GREEN);
81+
->getStartColor()->setARGB(Color::COLOR_GREEN);
8282
$greenStyle->getFont()->setColor(new Color(Color::COLOR_DARKRED));
8383
$redStyle = new Style(false, true);
8484
$redStyle->getFill()
8585
->setFillType(Fill::FILL_SOLID)
86-
->getEndColor()->setARGB(Color::COLOR_RED);
86+
->getStartColor()->setARGB(Color::COLOR_RED);
8787
$redStyle->getFont()->setColor(new Color(Color::COLOR_GREEN));
8888

8989
// Set conditional formatting rules and styles

samples/ConditionalFormatting/03_Blank_Comparisons.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
$greenStyle = new Style(false, true);
4646
$greenStyle->getFill()
4747
->setFillType(Fill::FILL_SOLID)
48-
->getEndColor()->setARGB(Color::COLOR_GREEN);
48+
->getStartColor()->setARGB(Color::COLOR_GREEN);
4949
$greenStyle->getFont()->setColor(new Color(Color::COLOR_DARKRED));
5050
$redStyle = new Style(false, true);
5151
$redStyle->getFill()
5252
->setFillType(Fill::FILL_SOLID)
53-
->getEndColor()->setARGB(Color::COLOR_RED);
53+
->getStartColor()->setARGB(Color::COLOR_RED);
5454
$redStyle->getFont()->setColor(new Color(Color::COLOR_GREEN));
5555

5656
// Set conditional formatting rules and styles

samples/ConditionalFormatting/04_Error_Comparisons.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
$greenStyle = new Style(false, true);
4949
$greenStyle->getFill()
5050
->setFillType(Fill::FILL_SOLID)
51-
->getEndColor()->setARGB(Color::COLOR_GREEN);
51+
->getStartColor()->setARGB(Color::COLOR_GREEN);
5252
$greenStyle->getFont()->setColor(new Color(Color::COLOR_DARKRED));
5353
$redStyle = new Style(false, true);
5454
$redStyle->getFill()
5555
->setFillType(Fill::FILL_SOLID)
56-
->getEndColor()->setARGB(Color::COLOR_RED);
56+
->getStartColor()->setARGB(Color::COLOR_RED);
5757
$redStyle->getFont()->setColor(new Color(Color::COLOR_GREEN));
5858

5959
// Set conditional formatting rules and styles

samples/ConditionalFormatting/05_Date_Comparisons.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
$yellowStyle = new Style(false, true);
112112
$yellowStyle->getFill()
113113
->setFillType(Fill::FILL_SOLID)
114-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
114+
->getStartColor()->setARGB(Color::COLOR_YELLOW);
115115
$yellowStyle->getFont()->setColor(new Color(Color::COLOR_BLUE));
116116

117117
// Set conditional formatting rules and styles

samples/ConditionalFormatting/06_Duplicate_Comparisons.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
$yellowStyle = new Style(false, true);
5555
$yellowStyle->getFill()
5656
->setFillType(Fill::FILL_SOLID)
57-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
57+
->getStartColor()->setARGB(Color::COLOR_YELLOW);
5858
$yellowStyle->getFont()->setColor(new Color(Color::COLOR_BLUE));
5959
$greenStyle = new Style(false, true);
6060
$greenStyle->getFill()
6161
->setFillType(Fill::FILL_SOLID)
62-
->getEndColor()->setARGB(Color::COLOR_GREEN);
62+
->getStartColor()->setARGB(Color::COLOR_GREEN);
6363
$greenStyle->getFont()->setColor(new Color(Color::COLOR_DARKRED));
6464

6565
// Set conditional formatting rules and styles

samples/ConditionalFormatting/07_Expression_Comparisons.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@
7373
$yellowStyle = new Style(false, true);
7474
$yellowStyle->getFill()
7575
->setFillType(Fill::FILL_SOLID)
76-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
76+
->getStartColor()->setARGB(Color::COLOR_YELLOW);
7777
$yellowStyle->getFont()->setColor(new Color(Color::COLOR_BLUE));
7878
$greenStyle = new Style(false, true);
7979
$greenStyle->getFill()
8080
->setFillType(Fill::FILL_SOLID)
81-
->getEndColor()->setARGB(Color::COLOR_GREEN);
81+
->getStartColor()->setARGB(Color::COLOR_GREEN);
8282
$greenStyle->getFont()->setColor(new Color(Color::COLOR_DARKRED));
8383

8484
$greenStyleMoney = clone $greenStyle;

src/PhpSpreadsheet/Reader/Xls.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -7493,11 +7493,15 @@ private function getCFFillStyle(string $options, Style $style): void
74937493

74947494
// bit: 0-6; mask: 0x007F; type
74957495
$color1 = (0x007F & $fillColors) >> 0;
7496-
$style->getFill()->getStartColor()->setRGB(Xls\Color::map($color1, $this->palette, $this->version)['rgb']);
74977496

74987497
// bit: 7-13; mask: 0x3F80; type
74997498
$color2 = (0x3F80 & $fillColors) >> 7;
7500-
$style->getFill()->getEndColor()->setRGB(Xls\Color::map($color2, $this->palette, $this->version)['rgb']);
7499+
if ($fillPattern === Fill::FILL_SOLID) {
7500+
$style->getFill()->getStartColor()->setRGB(Xls\Color::map($color2, $this->palette, $this->version)['rgb']);
7501+
} else {
7502+
$style->getFill()->getStartColor()->setRGB(Xls\Color::map($color1, $this->palette, $this->version)['rgb']);
7503+
$style->getFill()->getEndColor()->setRGB(Xls\Color::map($color2, $this->palette, $this->version)['rgb']);
7504+
}
75017505
}
75027506
}
75037507

src/PhpSpreadsheet/Writer/Xls.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function save($filename, int $flags = 0): void
119119
// Initialise worksheet writers
120120
$countSheets = $this->spreadsheet->getSheetCount();
121121
for ($i = 0; $i < $countSheets; ++$i) {
122-
$this->writerWorksheets[$i] = new Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->spreadsheet->getSheet($i));
122+
$this->writerWorksheets[$i] = new Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->spreadsheet->getSheet($i), $this->writerWorkbook);
123123
}
124124

125125
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.

src/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
use PhpOffice\PhpSpreadsheet\Style\Color;
66

7+
/*
8+
* Static array incorrectly used by Xls Writer for Conditional Styles.
9+
*
10+
* @deprecated since version 2.2
11+
*
12+
* @codecoverageignore
13+
*/
14+
715
class ColorMap
816
{
917
/**
@@ -70,7 +78,7 @@ class ColorMap
7078

7179
public static function lookup(Color $color, int $defaultIndex = 0x00): int
7280
{
73-
$colorRgb = $color->getRGB();
81+
$colorRgb = strtoupper($color->getRGB());
7482
if (is_string($colorRgb) && array_key_exists("#{$colorRgb}", self::$colorMap)) {
7583
return self::$colorMap["#{$colorRgb}"];
7684
}

src/PhpSpreadsheet/Writer/Xls/Workbook.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font): int
272272
*
273273
* @return int Color index
274274
*/
275-
private function addColor(string $rgb): int
275+
public function addColor(string $rgb, int $default = 0): int
276276
{
277277
if (!isset($this->colors[$rgb])) {
278278
$color
@@ -298,7 +298,7 @@ private function addColor(string $rgb): int
298298
$this->colors[$rgb] = $colorIndex;
299299
} else {
300300
// no room for more custom colors, just map to black
301-
$colorIndex = 0;
301+
$colorIndex = $default;
302302
}
303303
}
304304
} else {

src/PhpSpreadsheet/Writer/Xls/Worksheet.php

+13-11
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ class Worksheet extends BIFFwriter
154154

155155
private int $printHeaders;
156156

157+
private ?Workbook $writerWorkbook;
158+
157159
/**
158160
* Constructor.
159161
*
@@ -165,7 +167,7 @@ class Worksheet extends BIFFwriter
165167
* @param bool $preCalculateFormulas Flag indicating whether formulas should be calculated or just written
166168
* @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet The worksheet to write
167169
*/
168-
public function __construct(int &$str_total, int &$str_unique, array &$str_table, array &$colors, Parser $parser, bool $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet)
170+
public function __construct(int &$str_total, int &$str_unique, array &$str_table, array &$colors, Parser $parser, bool $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet, ?Workbook $writerWorkbook = null)
169171
{
170172
// It needs to call its parent's constructor explicitly
171173
parent::__construct();
@@ -208,6 +210,7 @@ public function __construct(int &$str_total, int &$str_unique, array &$str_table
208210
if ($this->lastColumnIndex > 255) {
209211
$this->lastColumnIndex = 255;
210212
}
213+
$this->writerWorkbook = $writerWorkbook;
211214
}
212215

213216
/**
@@ -491,8 +494,6 @@ private function writeConditionalFormatting(): void
491494

492495
$arrConditionalStyles = $this->phpSheet->getConditionalStylesCollection();
493496
if (!empty($arrConditionalStyles)) {
494-
$arrConditional = [];
495-
496497
// Write ConditionalFormattingTable records
497498
foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) {
498499
$cfHeaderWritten = false;
@@ -506,10 +507,7 @@ private function writeConditionalFormatting(): void
506507
if ($cfHeaderWritten === false) {
507508
$cfHeaderWritten = $this->writeCFHeader($cellCoordinate, $conditionalStyles);
508509
}
509-
if ($cfHeaderWritten === true && !isset($arrConditional[$conditional->getHashCode()])) {
510-
// This hash code has been handled
511-
$arrConditional[$conditional->getHashCode()] = true;
512-
510+
if ($cfHeaderWritten === true) {
513511
// Write CFRULE record
514512
$this->writeCFRule($conditionalFormulaHelper, $conditional, $cellCoordinate);
515513
}
@@ -2971,8 +2969,7 @@ private function writeCFRule(
29712969
// Not used (3)
29722970
$dataBlockFont .= pack('vC', 0x0000, 0x00);
29732971
// Font color index
2974-
$colorIdx = Style\ColorMap::lookup($conditional->getStyle()->getFont()->getColor(), 0x00);
2975-
2972+
$colorIdx = $this->workbookColorIndex($conditional->getStyle()->getFont()->getColor()->getRgb(), 0);
29762973
$dataBlockFont .= pack('V', $colorIdx);
29772974
// Not used (4)
29782975
$dataBlockFont .= pack('V', 0x00000000);
@@ -3043,9 +3040,9 @@ private function writeCFRule(
30433040
// Fill Pattern Style
30443041
$blockFillPatternStyle = Style\CellFill::style($conditional->getStyle()->getFill());
30453042
// Background Color
3046-
$colorIdxBg = Style\ColorMap::lookup($conditional->getStyle()->getFill()->getStartColor(), 0x41);
3043+
$colorIdxBg = $this->workbookColorIndex($conditional->getStyle()->getFill()->getStartColor()->getRgb(), 0x41);
30473044
// Foreground Color
3048-
$colorIdxFg = Style\ColorMap::lookup($conditional->getStyle()->getFill()->getEndColor(), 0x40);
3045+
$colorIdxFg = $this->workbookColorIndex($conditional->getStyle()->getFill()->getEndColor()->getRgb(), 0x40);
30493046

30503047
$dataBlockFill = pack('v', $blockFillPatternStyle);
30513048
$dataBlockFill .= pack('v', $colorIdxFg | ($colorIdxBg << 7));
@@ -3142,4 +3139,9 @@ private function getDataBlockProtection(Conditional $conditional): int
31423139

31433140
return $dataBlockProtection;
31443141
}
3142+
3143+
private function workbookColorIndex(?string $rgb, int $default): int
3144+
{
3145+
return (empty($rgb) || $this->writerWorkbook === null) ? $default : $this->writerWorkbook->addColor($rgb, $default);
3146+
}
31453147
}

tests/PhpSpreadsheetTests/Calculation/XlfnFunctionsTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,24 @@ public function testXlfn(): void
5454
$condition0->setConditionType(Conditional::CONDITION_EXPRESSION);
5555
$condition0->addCondition('ABS(B3)<2');
5656
$condition0->getStyle()->getFill()->setFillType(Fill::FILL_SOLID);
57-
$condition0->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_RED);
57+
$condition0->getStyle()->getFill()->getStartColor()->setARGB(Color::COLOR_RED);
5858
$condition1 = new Conditional();
5959
$condition1->setConditionType(Conditional::CONDITION_EXPRESSION);
6060
$condition1->addCondition('ABS(B3)>2');
6161
$condition1->getStyle()->getFill()->setFillType(Fill::FILL_SOLID);
62-
$condition1->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_GREEN);
62+
$condition1->getStyle()->getFill()->getStartColor()->setARGB(Color::COLOR_GREEN);
6363
$cond = [$condition0, $condition1];
6464
$sheet->getStyle('B3:B5')->setConditionalStyles($cond);
6565
$condition0 = new Conditional();
6666
$condition0->setConditionType(Conditional::CONDITION_EXPRESSION);
6767
$condition0->addCondition('ISOWEEKNUM(A3)<10');
6868
$condition0->getStyle()->getFill()->setFillType(Fill::FILL_SOLID);
69-
$condition0->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_RED);
69+
$condition0->getStyle()->getFill()->getStartColor()->setARGB(Color::COLOR_RED);
7070
$condition1 = new Conditional();
7171
$condition1->setConditionType(Conditional::CONDITION_EXPRESSION);
7272
$condition1->addCondition('ISOWEEKNUM(A3)>40');
7373
$condition1->getStyle()->getFill()->setFillType(Fill::FILL_SOLID);
74-
$condition1->getStyle()->getFill()->getEndColor()->setARGB(Color::COLOR_GREEN);
74+
$condition1->getStyle()->getFill()->getStartColor()->setARGB(Color::COLOR_GREEN);
7575
$cond = [$condition0, $condition1];
7676
$sheet->getStyle('A3:A5')->setConditionalStyles($cond);
7777
$sheet->setSelectedCell('B1');

tests/PhpSpreadsheetTests/Cell/CellTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ public function testAppliedStyleWithRange(): void
195195
$yellowStyle = new Style(false, true);
196196
$yellowStyle->getFill()
197197
->setFillType(Fill::FILL_SOLID)
198-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
198+
->getStartColor()->setARGB(Color::COLOR_YELLOW);
199199
$greenStyle = new Style(false, true);
200200
$greenStyle->getFill()
201201
->setFillType(Fill::FILL_SOLID)
202-
->getEndColor()->setARGB(Color::COLOR_GREEN);
202+
->getStartColor()->setARGB(Color::COLOR_GREEN);
203203
$redStyle = new Style(false, true);
204204
$redStyle->getFill()
205205
->setFillType(Fill::FILL_SOLID)
206-
->getEndColor()->setARGB(Color::COLOR_RED);
206+
->getStartColor()->setARGB(Color::COLOR_RED);
207207

208208
$conditionalStyles = [];
209209
$wizardFactory = new Wizard($cellRange);
@@ -228,22 +228,22 @@ public function testAppliedStyleWithRange(): void
228228
$style = $sheet->getCell('A1')->getAppliedStyle();
229229
self::assertTrue($style->getFont()->getBold());
230230
self::assertEquals($redStyle->getFill()->getFillType(), $style->getFill()->getFillType());
231-
self::assertEquals($redStyle->getFill()->getEndColor()->getARGB(), $style->getFill()->getEndColor()->getARGB());
231+
self::assertEquals($redStyle->getFill()->getStartColor()->getARGB(), $style->getFill()->getStartColor()->getARGB());
232232

233233
$style = $sheet->getCell('A2')->getAppliedStyle();
234234
self::assertTrue($style->getFont()->getBold());
235235
self::assertEquals($yellowStyle->getFill()->getFillType(), $style->getFill()->getFillType());
236236
self::assertEquals(
237-
$yellowStyle->getFill()->getEndColor()->getARGB(),
238-
$style->getFill()->getEndColor()->getARGB()
237+
$yellowStyle->getFill()->getStartColor()->getARGB(),
238+
$style->getFill()->getStartColor()->getARGB()
239239
);
240240

241241
$style = $sheet->getCell('A3')->getAppliedStyle();
242242
self::assertTrue($style->getFont()->getBold());
243243
self::assertEquals($greenStyle->getFill()->getFillType(), $style->getFill()->getFillType());
244244
self::assertEquals(
245-
$greenStyle->getFill()->getEndColor()->getARGB(),
246-
$style->getFill()->getEndColor()->getARGB()
245+
$greenStyle->getFill()->getStartColor()->getARGB(),
246+
$style->getFill()->getStartColor()->getARGB()
247247
);
248248
}
249249

@@ -266,11 +266,11 @@ public function testAppliedStyleSingleCell(string $cellAddress, string $fillStyl
266266
$yellowStyle = new Style(false, true);
267267
$yellowStyle->getFill()
268268
->setFillType(Fill::FILL_SOLID)
269-
->getEndColor()->setARGB(Color::COLOR_YELLOW);
269+
->getStartColor()->setARGB(Color::COLOR_YELLOW);
270270
$redStyle = new Style(false, true);
271271
$redStyle->getFill()
272272
->setFillType(Fill::FILL_SOLID)
273-
->getEndColor()->setARGB(Color::COLOR_RED);
273+
->getStartColor()->setARGB(Color::COLOR_RED);
274274

275275
$conditionalCellRange = 'A1:C1';
276276
$conditionalStyles = [];
@@ -294,7 +294,7 @@ public function testAppliedStyleSingleCell(string $cellAddress, string $fillStyl
294294
self::assertTrue($style->getFont()->getBold());
295295
self::assertEquals($fillStyle, $style->getFill()->getFillType());
296296
if ($fillStyle === Fill::FILL_SOLID) {
297-
self::assertEquals($fillColor, $style->getFill()->getEndColor()->getARGB());
297+
self::assertEquals($fillColor, $style->getFill()->getStartColor()->getARGB());
298298
}
299299
}
300300

0 commit comments

Comments
 (0)