diff --git a/CHANGELOG.md b/CHANGELOG.md index 7483ac3a..ed362653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Improved memory usage and performance when loading large spreadsheets - [#822](https://github.com/PHPOffice/PhpSpreadsheet/pull/822) - Improved performance when loading large spreadsheets - [#825](https://github.com/PHPOffice/PhpSpreadsheet/pull/825) - Improved performance when loading large spreadsheets - [#824](https://github.com/PHPOffice/PhpSpreadsheet/pull/824) +- Fix color from CSS when reading from HTML - [#831](https://github.com/PHPOffice/PhpSpreadsheet/pull/831) ## [1.5.2] - 2018-11-25 diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 35c93aab..d9f25a31 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -634,7 +634,7 @@ class Html extends BaseReader break; case 'color': - $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "$style_color}"]]]); + $sheet->getStyle($column . $row)->applyFromArray(['font' => ['color' => ['rgb' => "{$style_color}"]]]); break; } diff --git a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php index 9f9b11eb..060c1e60 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php @@ -43,4 +43,22 @@ class HtmlTest extends TestCase self::assertSame($expected, $actual); } + + public function testBackgroundColorInRanding() + { + $html = ' + + + +
Blue background
'; + $filename = tempnam(sys_get_temp_dir(), 'html'); + file_put_contents($filename, $html); + $reader = new Html(); + $spreadsheet = $reader->load($filename); + $firstSheet = $spreadsheet->getSheet(0); + $style = $firstSheet->getCell('A1')->getStyle(); + + self::assertEquals('FFFFFF', $style->getFont()->getColor()->getRGB()); + unlink($filename); + } }