Files
oleibman 5b799dbbed Ods Reader No Datatype for Null Value
Issue #4435 was initially described incorrectly. While investigating the original description, I came upon this problem. Ods Reader is trying to set some cells to null without supplying a valid DataType to setValueExplicit, causing that method to throw an exception. Reader is changed to no longer call that method when value is null and DataType is null-string.
2025-04-03 19:55:33 -07:00

32 lines
987 B
PHP

<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Ods;
use PhpOffice\PhpSpreadsheet\Reader\Ods as OdsReader;
use PHPUnit\Framework\TestCase;
class Issue4435Test extends TestCase
{
private string $file = 'tests/data/Reader/Ods/issue.4435b.ods';
public function testNoHeaderFooterStyle(): void
{
// had been throwing exception when cell didn't have value-type
$zipFile = 'zip://' . $this->file . '#content.xml';
$contents = (string) file_get_contents($zipFile);
self::assertStringContainsString(
'<table:table-cell table:style-name="ce1">' . "\n"
. '<text:p/>' . "\n"
. '</table:table-cell>',
$contents
);
$reader = new OdsReader();
$spreadsheet = $reader->load($this->file);
$sheet = $spreadsheet->getActiveSheet();
self::assertNull($sheet->getCell('B1')->getValue());
$spreadsheet->disconnectWorksheets();
}
}