Skip to content

Commit fcf03b9

Browse files
authored
Merge pull request #4094 from oleibman/issue476
Xlsx Writer Rich Text and TYPE_STRING
2 parents f4ef625 + 73eeba0 commit fcf03b9

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
4141
- Problem rendering line chart with missing plot label. [PR #4074](https://github.com/PHPOffice/PhpSpreadsheet/pull/4074)
4242
- More RTL in Xlsx/Html Comments [Issue #4004](https://github.com/PHPOffice/PhpSpreadsheet/issues/4004) [PR #4065](https://github.com/PHPOffice/PhpSpreadsheet/pull/4065)
4343
- Empty String in sharedStrings. [Issue #4063](https://github.com/PHPOffice/PhpSpreadsheet/issues/4063) [PR #4064](https://github.com/PHPOffice/PhpSpreadsheet/pull/4064)
44+
- Xlsx Writer RichText and TYPE_STRING. [Issue #476](https://github.com/PHPOffice/PhpSpreadsheet/issues/476) [PR #4094](https://github.com/PHPOffice/PhpSpreadsheet/pull/4094)
45+
- Ods boolean data. [Issue #460](https://github.com/PHPOffice/PhpSpreadsheet/issues/460) [PR #4093](https://github.com/PHPOffice/PhpSpreadsheet/pull/4093)
4446
- Html Writer Minor Fixes. [PR #4089](https://github.com/PHPOffice/PhpSpreadsheet/pull/4089)
4547
- Changes to INDEX function. [Issue #64](https://github.com/PHPOffice/PhpSpreadsheet/issues/64) [PR #4088](https://github.com/PHPOffice/PhpSpreadsheet/pull/4088)
4648
- Ods Reader and Whitespace Text Nodes. [Issue #804](https://github.com/PHPOffice/PhpSpreadsheet/issues/804) [PR #4087](https://github.com/PHPOffice/PhpSpreadsheet/pull/4087)

src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksh
15281528

15291529
break;
15301530
case 's': // String
1531-
$this->writeCellString($objWriter, $mappedType, $cellValueString, $flippedStringTable);
1531+
$this->writeCellString($objWriter, $mappedType, ($cellValue instanceof RichText) ? $cellValue : $cellValueString, $flippedStringTable);
15321532

15331533
break;
15341534
case 'f': // Formula
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpOffice\PhpSpreadsheetTests\Writer\Xlsx;
6+
7+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
8+
use PhpOffice\PhpSpreadsheet\RichText\RichText;
9+
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
10+
11+
class Issue476Test extends AbstractFunctional
12+
{
13+
public function testIssue476(): void
14+
{
15+
// RichText written in a way usually used only by strings.
16+
$reader = new XlsxReader();
17+
$spreadsheet = $reader->load('tests/data/Writer/XLSX/issue.476.xlsx');
18+
19+
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
20+
$spreadsheet->disconnectWorksheets();
21+
22+
$sheet = $reloadedSpreadsheet->getActiveSheet();
23+
$richText = $sheet->getCell('A1')->getValue();
24+
self::assertInstanceOf(RichText::class, $richText);
25+
$plainText = $richText->getPlainText();
26+
self::assertSame("Art. 1A of the Geneva Refugee Convention and Protocol or other international or national instruments.\n", $plainText);
27+
28+
$reloadedSpreadsheet->disconnectWorksheets();
29+
}
30+
}

tests/data/Writer/XLSX/issue.476.xlsx

8.82 KB
Binary file not shown.

0 commit comments

Comments
 (0)