diff --git a/CHANGELOG.md b/CHANGELOG.md index e5dd8dcfbc..1241d00edc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Problem rendering line chart with missing plot label. [PR #4074](https://github.com/PHPOffice/PhpSpreadsheet/pull/4074) - More RTL in Xlsx/Html Comments [Issue #4004](https://github.com/PHPOffice/PhpSpreadsheet/issues/4004) [PR #4065](https://github.com/PHPOffice/PhpSpreadsheet/pull/4065) - Empty String in sharedStrings. [Issue #4063](https://github.com/PHPOffice/PhpSpreadsheet/issues/4063) [PR #4064](https://github.com/PHPOffice/PhpSpreadsheet/pull/4064) +- Xlsx Writer RichText and TYPE_STRING. [Issue #476](https://github.com/PHPOffice/PhpSpreadsheet/issues/476) [PR #4094](https://github.com/PHPOffice/PhpSpreadsheet/pull/4094) +- Ods boolean data. [Issue #460](https://github.com/PHPOffice/PhpSpreadsheet/issues/460) [PR #4093](https://github.com/PHPOffice/PhpSpreadsheet/pull/4093) - Html Writer Minor Fixes. [PR #4089](https://github.com/PHPOffice/PhpSpreadsheet/pull/4089) - Changes to INDEX function. [Issue #64](https://github.com/PHPOffice/PhpSpreadsheet/issues/64) [PR #4088](https://github.com/PHPOffice/PhpSpreadsheet/pull/4088) - Ods Reader and Whitespace Text Nodes. [Issue #804](https://github.com/PHPOffice/PhpSpreadsheet/issues/804) [PR #4087](https://github.com/PHPOffice/PhpSpreadsheet/pull/4087) diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index a1940f329c..bd6eec367f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -1528,7 +1528,7 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksh break; case 's': // String - $this->writeCellString($objWriter, $mappedType, $cellValueString, $flippedStringTable); + $this->writeCellString($objWriter, $mappedType, ($cellValue instanceof RichText) ? $cellValue : $cellValueString, $flippedStringTable); break; case 'f': // Formula diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/Issue476Test.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/Issue476Test.php new file mode 100644 index 0000000000..513fe7940b --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/Issue476Test.php @@ -0,0 +1,30 @@ +load('tests/data/Writer/XLSX/issue.476.xlsx'); + + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); + $spreadsheet->disconnectWorksheets(); + + $sheet = $reloadedSpreadsheet->getActiveSheet(); + $richText = $sheet->getCell('A1')->getValue(); + self::assertInstanceOf(RichText::class, $richText); + $plainText = $richText->getPlainText(); + self::assertSame("Art. 1A of the Geneva Refugee Convention and Protocol or other international or national instruments.\n", $plainText); + + $reloadedSpreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/data/Writer/XLSX/issue.476.xlsx b/tests/data/Writer/XLSX/issue.476.xlsx new file mode 100644 index 0000000000..f76f2d227f Binary files /dev/null and b/tests/data/Writer/XLSX/issue.476.xlsx differ