-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for the BIFF-8 Xls colour mappings in the Reader (#2156)
* Fix for the BIFF-8 Xls colour mappings in the Reader * Unit test for reading colours, writing hen rereading and ensuring that the RGB values have not changed
- Loading branch information
Mark Baker
authored
Jun 13, 2021
1 parent
b98b9c7
commit 74b02fb
Showing
3 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xls; | ||
use PhpOffice\PhpSpreadsheet\Spreadsheet; | ||
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional; | ||
|
||
class ColourTest extends AbstractFunctional | ||
{ | ||
/** | ||
* @var Spreadsheet | ||
*/ | ||
private $spreadsheet; | ||
|
||
protected function setup(): void | ||
{ | ||
$filename = 'tests/data/Reader/XLS/Colours.xls'; | ||
$reader = new Xls(); | ||
$this->spreadsheet = $reader->load($filename); | ||
} | ||
|
||
public function testColours(): void | ||
{ | ||
$colours = []; | ||
|
||
$worksheet = $this->spreadsheet->getActiveSheet(); | ||
for ($row = 1; $row <= 7; ++$row) { | ||
for ($column = 'A'; $column !== 'J'; ++$column) { | ||
$cellAddress = "{$column}{$row}"; | ||
$colours[$cellAddress] = $worksheet->getStyle($cellAddress)->getFill()->getStartColor()->getRGB(); | ||
} | ||
} | ||
|
||
$newSpreadsheet = $this->writeAndReload($this->spreadsheet, 'Xls'); | ||
$newWorksheet = $newSpreadsheet->getActiveSheet(); | ||
foreach ($colours as $cellAddress => $expectedColourValue) { | ||
$actualColourValue = $newWorksheet->getStyle($cellAddress)->getFill()->getStartColor()->getRGB(); | ||
self::assertSame($expectedColourValue, $actualColourValue); | ||
} | ||
} | ||
} |
Binary file not shown.