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:
bayzhanov 2018-10-07 18:38:13 +11:00 committed by Adrien Crivelli
parent ae9dd13aa0
commit 08b4456641
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
8 changed files with 50 additions and 4 deletions

View File

@ -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

View File

@ -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.');
}

View 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());
}
}

View 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)
);
}
}

Binary file not shown.

View File

View File

BIN
tests/data/Shared/OLERead/wrkbook Executable file

Binary file not shown.