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
|
### Fixed
|
||||||
|
|
||||||
- Sheet title can contain exclamation mark - [#325](https://github.com/PHPOffice/PhpSpreadsheet/issues/325)
|
- 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
|
## [1.4.1] - 2018-09-30
|
||||||
|
|
||||||
|
|
|
@ -326,10 +326,7 @@ class OLERead
|
||||||
*/
|
*/
|
||||||
private static function getInt4d($data, $pos)
|
private static function getInt4d($data, $pos)
|
||||||
{
|
{
|
||||||
if (trim($data) == '') {
|
if ($pos < 0) {
|
||||||
// No data provided
|
|
||||||
throw new ReaderException('Parameter data is empty.');
|
|
||||||
} elseif ($pos < 0) {
|
|
||||||
// Invalid position
|
// Invalid position
|
||||||
throw new ReaderException('Parameter pos=' . $pos . ' is invalid.');
|
throw new ReaderException('Parameter pos=' . $pos . ' is invalid.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.
Binary file not shown.
Loading…
Reference in New Issue