diff --git a/CHANGELOG.md b/CHANGELOG.md index 963f01d8..8b1fcbd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Sheet title can contain exclamation mark - [#325](https://github.com/PHPOffice/PhpSpreadsheet/issues/325) +- Xls file cause the exception during open by Xls reader - [#402](https://github.com/PHPOffice/PhpSpreadsheet/issues/402) ## [1.4.1] - 2018-09-30 diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index 57554117..3af39700 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -326,10 +326,7 @@ class OLERead */ private static function getInt4d($data, $pos) { - if (trim($data) == '') { - // No data provided - throw new ReaderException('Parameter data is empty.'); - } elseif ($pos < 0) { + if ($pos < 0) { // Invalid position throw new ReaderException('Parameter pos=' . $pos . ' is invalid.'); } diff --git a/tests/PhpSpreadsheetTests/Reader/XlsTest.php b/tests/PhpSpreadsheetTests/Reader/XlsTest.php new file mode 100644 index 00000000..f629fed1 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/XlsTest.php @@ -0,0 +1,20 @@ +load($filename); + self::assertEquals('Title', $spreadsheet->getSheet(0)->getCell('A1')->getValue()); + } +} diff --git a/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php new file mode 100644 index 00000000..a004c4ae --- /dev/null +++ b/tests/PhpSpreadsheetTests/Shared/OLEReadTest.php @@ -0,0 +1,28 @@ +read('./data/Reader/XLS/sample.xls'); + self::assertEquals( + file_get_contents($dataDir . 'wrkbook'), + $ole->getStream($ole->wrkbook) + ); + self::assertEquals( + file_get_contents($dataDir . 'summary'), + $ole->getStream($ole->summaryInformation) + ); + self::assertEquals( + file_get_contents($dataDir . 'document'), + $ole->getStream($ole->documentSummaryInformation) + ); + } +} diff --git a/tests/data/Reader/XLS/sample.xls b/tests/data/Reader/XLS/sample.xls new file mode 100644 index 00000000..65fcba55 Binary files /dev/null and b/tests/data/Reader/XLS/sample.xls differ diff --git a/tests/data/Shared/OLERead/document b/tests/data/Shared/OLERead/document new file mode 100755 index 00000000..e69de29b diff --git a/tests/data/Shared/OLERead/summary b/tests/data/Shared/OLERead/summary new file mode 100755 index 00000000..e69de29b diff --git a/tests/data/Shared/OLERead/wrkbook b/tests/data/Shared/OLERead/wrkbook new file mode 100755 index 00000000..ad344aa5 Binary files /dev/null and b/tests/data/Shared/OLERead/wrkbook differ