Skip to content
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

Fix XLSX reader when having a corrupt numeric cell data type #1664

Merged
merged 5 commits into from Feb 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662)
- ReverseSort bug, exposed but not caused by PHP8 [#1660](https://github.com/phpoffice/phpspreadsheet/pull/1660)
- Bug setting Superscript/Subscript to false [#1567](https://github.com/phpoffice/phpspreadsheet/pull/1567)
- Fix XLSX reader when having a corrupt numeric cell data type [#1664](https://github.com/phpoffice/phpspreadsheet/pull/1664)

## 1.14.1 - 2020-07-19

Expand Down Expand Up @@ -581,4 +582,4 @@ For a comprehensive list of all class changes, and a semi-automated migration pa

## Previous versions of PHPExcel

The changelog for the project when it was called PHPExcel is [still available](./CHANGELOG.PHPExcel.md).
The changelog for the project when it was called PHPExcel is [still available](./CHANGELOG.PHPExcel.md).
5 changes: 5 additions & 0 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Expand Up @@ -3,6 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Reader;

use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
use PhpOffice\PhpSpreadsheet\DefinedName;
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
Expand Down Expand Up @@ -732,6 +733,10 @@ public function load($pFilename)
$cell = $docSheet->getCell($r);
// Assign value
if ($cellDataType != '') {
// it is possible, that datatype is numeric but with an empty string, which result in an error
if ($cellDataType === DataType::TYPE_NUMERIC && $value === '') {
$cellDataType = DataType::TYPE_STRING;
}
$cell->setValueExplicit($value, $cellDataType);
} else {
$cell->setValue($value);
Expand Down