Vendor updates

This commit is contained in:
2018-10-17 22:28:29 -04:00
parent 98ea166a22
commit c34d4eafd9
42 changed files with 1759 additions and 213 deletions

View File

@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.4.1] - 2018-09-30
### Fixed
- Remove locale from formatting string - [#644](https://github.com/PHPOffice/PhpSpreadsheet/pull/644)
- Allow iterators to go out of bounds with prev - [#587](https://github.com/PHPOffice/PhpSpreadsheet/issues/587)
- Fix warning when reading xlsx without styles - [#631](https://github.com/PHPOffice/PhpSpreadsheet/pull/631)
- Fix broken sample links on windows due to $baseDir having backslash - [#653](https://github.com/PHPOffice/PhpSpreadsheet/pull/653)
## [1.4.0] - 2018-08-06
### Added

View File

@ -61,7 +61,7 @@
"suggest": {
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"tecnick.com/tcpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer",
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers"
},
"autoload": {

View File

@ -43,7 +43,7 @@ usage of PhpSpreadsheet.
## Common use cases
PhpSpreadsheet does not ship with alternative cache implementation. It is up to
you to select the most appropriate implementation for your environnement. You
you to select the most appropriate implementation for your environment. You
can either implement [PSR-16](http://www.php-fig.org/psr/psr-16/) from scratch,
or use [pre-existing libraries](https://packagist.org/search/?q=psr-16).

View File

@ -82,7 +82,7 @@ class Sample
$files = [];
foreach ($regex as $file) {
$file = str_replace($baseDir . '/', '', $file[0]);
$file = str_replace(str_replace('\\', '/', $baseDir) . '/', '', str_replace('\\', '/', $file[0]));
$info = pathinfo($file);
$category = str_replace('_', ' ', $info['dirname']);
$name = str_replace('_', ' ', preg_replace('/(|\.php)/', '', $info['filename']));

View File

@ -1127,7 +1127,7 @@ class Xls extends BaseReader
// TODO: Why is there no BSE Index? Is this a new Office Version? Password protected field?
// More likely : a uncompatible picture
if (!$BSEindex) {
continue;
continue 2;
}
$BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();

View File

@ -643,7 +643,7 @@ class Xlsx extends BaseReader
$excel->addCellXf($objStyle);
}
foreach ($xmlStyles->cellStyleXfs->xf as $xf) {
foreach (isset($xmlStyles->cellStyleXfs->xf) ? $xmlStyles->cellStyleXfs->xf : [] as $xf) {
$numFmt = NumberFormat::FORMAT_GENERAL;
if ($numFmts && $xf['numFmtId']) {
$tmpNumFmt = self::getArrayItem($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));

View File

@ -320,7 +320,7 @@ class OLE
break;
default:
continue;
break;
}
fseek($fh, 1, SEEK_CUR);
$pps->Type = $type;

View File

@ -691,6 +691,9 @@ class NumberFormat extends Supervisor
// Strip #
$format = preg_replace('/\\#/', '0', $format);
// Remove locale code [$-###]
$format = preg_replace('/\[\$\-.*\]/', '', $format);
$n = '/\\[[^\\]]+\\]/';
$m = preg_replace($n, '', $format);
$number_regex = '/(0+)(\\.?)(0*)/';

View File

@ -153,10 +153,6 @@ class ColumnCellIterator extends CellIterator
*/
public function prev()
{
if ($this->currentRow <= $this->startRow) {
throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}
do {
--$this->currentRow;
} while (($this->onlyExistingCells) &&
@ -171,7 +167,7 @@ class ColumnCellIterator extends CellIterator
*/
public function valid()
{
return $this->currentRow <= $this->endRow;
return $this->currentRow <= $this->endRow && $this->currentRow >= $this->startRow;
}
/**

View File

@ -157,14 +157,9 @@ class ColumnIterator implements \Iterator
/**
* Set the iterator to its previous value.
*
* @throws PhpSpreadsheetException
*/
public function prev()
{
if ($this->currentColumnIndex <= $this->startColumnIndex) {
throw new PhpSpreadsheetException('Column is already at the beginning of range (' . Coordinate::stringFromColumnIndex($this->endColumnIndex) . ' - ' . Coordinate::stringFromColumnIndex($this->endColumnIndex) . ')');
}
--$this->currentColumnIndex;
}
@ -175,6 +170,6 @@ class ColumnIterator implements \Iterator
*/
public function valid()
{
return $this->currentColumnIndex <= $this->endColumnIndex;
return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >= $this->startColumnIndex;
}
}

View File

@ -25,7 +25,7 @@ class Iterator implements \Iterator
*
* @param Spreadsheet $subject
*/
public function __construct(Spreadsheet $subject = null)
public function __construct(Spreadsheet $subject)
{
// Set subject
$this->subject = $subject;
@ -82,6 +82,6 @@ class Iterator implements \Iterator
*/
public function valid()
{
return $this->position < $this->subject->getSheetCount();
return $this->position < $this->subject->getSheetCount() && $this->position >= 0;
}
}

View File

@ -155,9 +155,6 @@ class RowCellIterator extends CellIterator
*/
public function prev()
{
if ($this->currentColumnIndex <= $this->startColumnIndex) {
throw new PhpSpreadsheetException('Column is already at the beginning of range (' . Coordinate::stringFromColumnIndex($this->endColumnIndex) . ' - ' . Coordinate::stringFromColumnIndex($this->endColumnIndex) . ')');
}
do {
--$this->currentColumnIndex;
} while (($this->onlyExistingCells) && (!$this->worksheet->cellExistsByColumnAndRow($this->currentColumnIndex, $this->rowIndex)) && ($this->currentColumnIndex >= $this->startColumnIndex));
@ -170,7 +167,7 @@ class RowCellIterator extends CellIterator
*/
public function valid()
{
return $this->currentColumnIndex <= $this->endColumnIndex;
return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >= $this->startColumnIndex;
}
/**

View File

@ -152,15 +152,9 @@ class RowIterator implements \Iterator
/**
* Set the iterator to its previous value.
*
* @throws PhpSpreadsheetException
*/
public function prev()
{
if ($this->position <= $this->startRow) {
throw new PhpSpreadsheetException("Row is already at the beginning of range ({$this->startRow} - {$this->endRow})");
}
--$this->position;
}
@ -171,6 +165,6 @@ class RowIterator implements \Iterator
*/
public function valid()
{
return $this->position <= $this->endRow;
return $this->position <= $this->endRow && $this->position >= $this->startRow;
}
}

View File

@ -78,9 +78,8 @@ class ColumnCellIteratorTest extends TestCase
public function testPrevOutOfRange()
{
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
$iterator->prev();
self::assertFalse($iterator->valid());
}
}

View File

@ -77,9 +77,8 @@ class ColumnIteratorTest extends TestCase
public function testPrevOutOfRange()
{
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
$iterator->prev();
self::assertFalse($iterator->valid());
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Iterator;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PHPUnit\Framework\TestCase;
class IteratorTest extends TestCase
{
public function testIteratorFullRange()
{
$spreadsheet = new Spreadsheet();
$spreadsheet->createSheet();
$spreadsheet->createSheet();
$iterator = new Iterator($spreadsheet);
$columnIndexResult = 0;
self::assertEquals($columnIndexResult, $iterator->key());
foreach ($iterator as $key => $column) {
self::assertEquals($columnIndexResult++, $key);
self::assertInstanceOf(Worksheet::class, $column);
}
self::assertSame(3, $columnIndexResult);
}
}

View File

@ -80,9 +80,8 @@ class RowCellIteratorTest extends TestCase
public function testPrevOutOfRange()
{
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
$iterator->prev();
self::assertFalse($iterator->valid());
}
}

View File

@ -75,9 +75,8 @@ class RowIteratorTest extends TestCase
public function testPrevOutOfRange()
{
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
$iterator = new RowIterator($this->mockWorksheet, 2, 4);
$iterator->prev();
self::assertFalse($iterator->valid());
}
}

View File

@ -186,4 +186,24 @@ return [
-1234567.8899999999,
'0000:00.00',
],
[
'18.952',
18.952,
'[$-409]General',
],
[
'9.98',
9.98,
'[$-409]#,##0.00;-#,##0.00',
],
[
'18.952',
18.952,
'[$-1010409]General',
],
[
'9.98',
9.98,
'[$-1010409]#,##0.00;-#,##0.00',
],
];

View File

@ -62,4 +62,14 @@ return [
43270.603472222,
'hh:mm:ss\ AM/PM',
],
[
'8/20/2018',
43332,
'[$-409]m/d/yyyy',
],
[
'8/20/2018',
43332,
'[$-1010409]m/d/yyyy',
],
];