Skip to content

Ods Reader No Datatype for Null Value #4436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- 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)
- 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)
- Fix TREND_BEST_FIT_NO_POLY. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
- 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)
- 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)
- Fix typo in Style exportArray quotePrefix. [Issue #4422](https://github.com/PHPOffice/PhpSpreadsheet/issues/4422) [PR #4424](https://github.com/PHPOffice/PhpSpreadsheet/pull/4424)
- Tweak Spreadsheet clone. [PR #4419](https://github.com/PHPOffice/PhpSpreadsheet/pull/4419)
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Reader/Ods.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Sp
if ($cellDataType === 'array') {
$cell->setFormulaAttributes(['t' => 'array', 'ref' => $cellDataRef]);
}
} else {
} elseif ($type !== '' || $dataValue !== null) {
$cell->setValueExplicit($dataValue, $type);
}

Expand Down
31 changes: 31 additions & 0 deletions tests/PhpSpreadsheetTests/Reader/Ods/Issue4435Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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();
}
}
Binary file added tests/data/Reader/Ods/issue.4435b.ods
Binary file not shown.