Fix XLSX reader when having a corrupt numeric cell data type (#1664)
* fix for read xlsx with somewhat corrupt cell data type
This commit is contained in:
parent
d28b7de1fc
commit
fa51a8590b
|
|
@ -128,6 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662)
|
- 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)
|
- 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)
|
- 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
|
## 1.14.1 - 2020-07-19
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace PhpOffice\PhpSpreadsheet\Reader;
|
namespace PhpOffice\PhpSpreadsheet\Reader;
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
|
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
|
||||||
use PhpOffice\PhpSpreadsheet\DefinedName;
|
use PhpOffice\PhpSpreadsheet\DefinedName;
|
||||||
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
use PhpOffice\PhpSpreadsheet\Reader\Security\XmlScanner;
|
||||||
|
|
@ -735,6 +736,10 @@ class Xlsx extends BaseReader
|
||||||
$cell = $docSheet->getCell($r);
|
$cell = $docSheet->getCell($r);
|
||||||
// Assign value
|
// Assign value
|
||||||
if ($cellDataType != '') {
|
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);
|
$cell->setValueExplicit($value, $cellDataType);
|
||||||
} else {
|
} else {
|
||||||
$cell->setValue($value);
|
$cell->setValue($value);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue