mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-15 12:36:32 +00:00
5e26de63a9
Fix #4063. Fix #1560. Fix #1293. PhpSpreadsheet is not accounting for an empty string in Xlsx sharedStrings.xml.The code which parses it in Reader/Xlsx looks for a `t` or `r` tag descending from `si`, but, in this case, the tag is coded as `<si/>`, with neither t nor r tag descending. An else clause is added to set the string to empty string in this case. I was surprised that this had not turned up before, and a search through the archives found at least 2 earlier reports from 4 years ago. Those had been marked stale; the stale indicator is removed, and the issues are re-opened, to be closed when this PR is merged.
25 lines
750 B
PHP
25 lines
750 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Issue4063Test extends TestCase
|
|
{
|
|
private static string $testbook = 'tests/data/Reader/XLSX/issue.4063.xlsx';
|
|
|
|
public function testSharedStringsWithEmptyString(): void
|
|
{
|
|
$spreadsheet = IOFactory::load(self::$testbook);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$data = $sheet->toArray(null, true, true, true);
|
|
$nbsp = "\u{00a0}";
|
|
self::assertSame(['A' => '226', 'B' => '', 'C' => $nbsp], $data[17]);
|
|
self::assertSame(['A' => '38873', 'B' => 'gg', 'C' => ' '], $data[22]);
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
}
|