diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php
index 362eae000d..68e200f580 100644
--- a/src/PhpSpreadsheet/Writer/Html.php
+++ b/src/PhpSpreadsheet/Writer/Html.php
@@ -940,8 +940,8 @@ public function buildCSS($generateSurroundingHTML = true)
// Calculate cell style hashes
foreach ($this->spreadsheet->getCellXfCollection() as $index => $style) {
- $css['td.style' . $index] = $this->createCSSStyle($style);
- $css['th.style' . $index] = $this->createCSSStyle($style);
+ $css['td.style' . $index . ', th.style' . $index] = $this->createCSSStyle($style);
+ //$css['th.style' . $index] = $this->createCSSStyle($style);
}
// Fetch sheets
@@ -1094,9 +1094,10 @@ private function createCSSStyleFill(Fill $fill)
$css = [];
// Create CSS
- $value = $fill->getFillType() == Fill::FILL_NONE ?
- 'white' : '#' . $fill->getStartColor()->getRGB();
- $css['background-color'] = $value;
+ if ($fill->getFillType() !== Fill::FILL_NONE) {
+ $value = '#' . $fill->getStartColor()->getRGB();
+ $css['background-color'] = $value;
+ }
return $css;
}
diff --git a/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php
index c5d4da68c8..1c1ffb0698 100644
--- a/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php
+++ b/tests/PhpSpreadsheetTests/Writer/Html/VisibilityTest.php
@@ -99,11 +99,11 @@ public function testDefaultRowHeight(): void
self::assertEquals(1, $rowsrch);
$rowsrch = preg_match('/^\\s*table[.]sheet0 tr[.]row1 [{] height:25pt [}]\\s*$/m', $html);
self::assertEquals(1, $rowsrch);
- $rowsrch = preg_match('/^\\s*td[.]style1 [{].*text-decoration:line-through;.*[}]\\s*$/m', $html);
+ $rowsrch = preg_match('/^\\s*td[.]style1, th[.]style1 [{].*text-decoration:line-through;.*[}]\\s*$/m', $html);
self::assertEquals(1, $rowsrch);
- $rowsrch = preg_match('/^\\s*td[.]style2 [{].*text-decoration:underline line-through;.*[}]\\s*$/m', $html);
+ $rowsrch = preg_match('/^\\s*td[.]style2, th[.]style2 [{].*text-decoration:underline line-through;.*[}]\\s*$/m', $html);
self::assertEquals(1, $rowsrch);
- $rowsrch = preg_match('/^\\s*td[.]style3 [{].*text-decoration:underline;.*[}]\\s*$/m', $html);
+ $rowsrch = preg_match('/^\\s*td[.]style3, th[.]style3 [{].*text-decoration:underline;.*[}]\\s*$/m', $html);
self::assertEquals(1, $rowsrch);
$this->writeAndReload($spreadsheet, 'Html');