Xls file threw exception during open by Xls reader
Ignore some exception in property, if stream is empty Fixes #402 Fixes #659
This commit is contained in:
parent
ae9dd13aa0
commit
08b4456641
@ -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
|
||||
|
||||
|
@ -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.');
|
||||
}
|
||||
|
20
tests/PhpSpreadsheetTests/Reader/XlsTest.php
Normal file
20
tests/PhpSpreadsheetTests/Reader/XlsTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xls;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class XlsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test load Xls file.
|
||||
*/
|
||||
public function testLoadXlsSample()
|
||||
{
|
||||
$filename = './data/Reader/XLS/sample.xls';
|
||||
$reader = new Xls();
|
||||
$spreadsheet = $reader->load($filename);
|
||||
self::assertEquals('Title', $spreadsheet->getSheet(0)->getCell('A1')->getValue());
|
||||
}
|
||||
}
|
28
tests/PhpSpreadsheetTests/Shared/OLEReadTest.php
Normal file
28
tests/PhpSpreadsheetTests/Shared/OLEReadTest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\OLERead;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class OLEReadTest extends TestCase
|
||||
{
|
||||
public function testReadOleStreams()
|
||||
{
|
||||
$dataDir = './data/Shared/OLERead/';
|
||||
$ole = new OLERead();
|
||||
$ole->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)
|
||||
);
|
||||
}
|
||||
}
|
BIN
tests/data/Reader/XLS/sample.xls
Normal file
BIN
tests/data/Reader/XLS/sample.xls
Normal file
Binary file not shown.
0
tests/data/Shared/OLERead/document
Executable file
0
tests/data/Shared/OLERead/document
Executable file
0
tests/data/Shared/OLERead/summary
Executable file
0
tests/data/Shared/OLERead/summary
Executable file
BIN
tests/data/Shared/OLERead/wrkbook
Executable file
BIN
tests/data/Shared/OLERead/wrkbook
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user