Skip to content

Commit 86cca12

Browse files
authored
Merge pull request #4436 from oleibman/issue4435
Ods Reader No Datatype for Null Value
2 parents 1946564 + 5ce46da commit 86cca12

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
4040
- Ignore fractional part of Drawing Shadow Alpha. [Issue #4415](https://github.com/PHPOffice/PhpSpreadsheet/issues/4415) [PR #4417](https://github.com/PHPOffice/PhpSpreadsheet/pull/4417)
4141
- BIN2DEC, OCT2DEC, and HEX2DEC return numbers rather than strings. [Issue #4383](https://github.com/PHPOffice/PhpSpreadsheet/issues/4383) [PR #4389](https://github.com/PHPOffice/PhpSpreadsheet/pull/4389)
4242
- Fix TREND_BEST_FIT_NO_POLY. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
43+
- Ods Reader No DataType for Null Value. [Issue #4435](https://github.com/PHPOffice/PhpSpreadsheet/issues/4435) [PR #4436](https://github.com/PHPOffice/PhpSpreadsheet/pull/4436)
4344
- Column widths not preserved when using read filter. [Issue #4416](https://github.com/PHPOffice/PhpSpreadsheet/issues/4416) [PR #4423](https://github.com/PHPOffice/PhpSpreadsheet/pull/4423)
4445
- Fix typo in Style exportArray quotePrefix. [Issue #4422](https://github.com/PHPOffice/PhpSpreadsheet/issues/4422) [PR #4424](https://github.com/PHPOffice/PhpSpreadsheet/pull/4424)
4546
- Tweak Spreadsheet clone. [PR #4419](https://github.com/PHPOffice/PhpSpreadsheet/pull/4419)

src/PhpSpreadsheet/Reader/Ods.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Sp
616616
if ($cellDataType === 'array') {
617617
$cell->setFormulaAttributes(['t' => 'array', 'ref' => $cellDataRef]);
618618
}
619-
} else {
619+
} elseif ($type !== '' || $dataValue !== null) {
620620
$cell->setValueExplicit($dataValue, $type);
621621
}
622622

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpOffice\PhpSpreadsheetTests\Reader\Ods;
6+
7+
use PhpOffice\PhpSpreadsheet\Reader\Ods as OdsReader;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class Issue4435Test extends TestCase
11+
{
12+
private string $file = 'tests/data/Reader/Ods/issue.4435b.ods';
13+
14+
public function testNoHeaderFooterStyle(): void
15+
{
16+
// had been throwing exception when cell didn't have value-type
17+
$zipFile = 'zip://' . $this->file . '#content.xml';
18+
$contents = (string) file_get_contents($zipFile);
19+
self::assertStringContainsString(
20+
'<table:table-cell table:style-name="ce1">' . "\n"
21+
. '<text:p/>' . "\n"
22+
. '</table:table-cell>',
23+
$contents
24+
);
25+
$reader = new OdsReader();
26+
$spreadsheet = $reader->load($this->file);
27+
$sheet = $spreadsheet->getActiveSheet();
28+
self::assertNull($sheet->getCell('B1')->getValue());
29+
$spreadsheet->disconnectWorksheets();
30+
}
31+
}

tests/data/Reader/Ods/issue.4435b.ods

10.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)