diff --git a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php index 61b93a1..4752239 100644 --- a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php +++ b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php @@ -237,6 +237,8 @@ EOD; if ($cell->isString()) { $cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue()); + } elseif ($cell->isDate()) { + $cellXML .= ' t="d">' . $cell->getValue()->format(\DateTimeInterface::ATOM) . ''; } elseif ($cell->isBoolean()) { $cellXML .= ' t="b">' . (int) ($cell->getValue()) . ''; } elseif ($cell->isNumeric()) { diff --git a/tests/Spout/Writer/XLSX/WriterTest.php b/tests/Spout/Writer/XLSX/WriterTest.php index 26b3792..1948ffe 100644 --- a/tests/Spout/Writer/XLSX/WriterTest.php +++ b/tests/Spout/Writer/XLSX/WriterTest.php @@ -365,7 +365,7 @@ class WriterTest extends TestCase { $fileName = 'test_add_row_should_support_multiple_types_of_data.xlsx'; $dataRows = $this->createRowsFromValues([ - ['xlsx--11', true, '', 0, 10.2, null], + ['xlsx--11', true, '', 0, 10.2, null, new \DateTime('2021-01-01'), new \DateTimeImmutable('2021-02-02')], ]); $this->writeToXLSXFile($dataRows, $fileName, $shouldUseInlineStrings = false);