Fix print area parser for XLSX reader
XLSX workbook references may not contains quotes in print area Fixes #733 Fixes #734
This commit is contained in:
parent
79d86ef5cc
commit
fdc224af7c
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Support numeric condition in SUMIF, SUMIFS, AVERAGEIF, COUNTIF, MAXIF and MINIF - [#683](https://github.com/PHPOffice/PhpSpreadsheet/issues/683)
|
- Support numeric condition in SUMIF, SUMIFS, AVERAGEIF, COUNTIF, MAXIF and MINIF - [#683](https://github.com/PHPOffice/PhpSpreadsheet/issues/683)
|
||||||
- SUMIFS containing multiple conditions - [#704](https://github.com/PHPOffice/PhpSpreadsheet/issues/704)
|
- SUMIFS containing multiple conditions - [#704](https://github.com/PHPOffice/PhpSpreadsheet/issues/704)
|
||||||
- Csv reader avoid notice when the file is empty - [#743](https://github.com/PHPOffice/PhpSpreadsheet/pull/743)
|
- Csv reader avoid notice when the file is empty - [#743](https://github.com/PHPOffice/PhpSpreadsheet/pull/743)
|
||||||
|
- Fix print area parser for XLSX reader - [#734](https://github.com/PHPOffice/PhpSpreadsheet/pull/734)
|
||||||
|
|
||||||
## [1.5.0] - 2018-10-21
|
## [1.5.0] - 2018-10-21
|
||||||
|
|
||||||
|
|
|
@ -1830,7 +1830,7 @@ class Xlsx extends BaseReader
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '_xlnm.Print_Area':
|
case '_xlnm.Print_Area':
|
||||||
$rangeSets = preg_split("/'(.*?)'(?:![A-Z0-9]+:[A-Z0-9]+,?)/", $extractedRange, PREG_SPLIT_NO_EMPTY);
|
$rangeSets = preg_split("/('?(?:.*?)'?(?:![A-Z0-9]+:[A-Z0-9]+)),?/", $extractedRange, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||||
$newRangeSets = [];
|
$newRangeSets = [];
|
||||||
foreach ($rangeSets as $rangeSet) {
|
foreach ($rangeSets as $rangeSet) {
|
||||||
list($sheetName, $rangeSet) = Worksheet::extractSheetTitle($rangeSet, true);
|
list($sheetName, $rangeSet) = Worksheet::extractSheetTitle($rangeSet, true);
|
||||||
|
|
|
@ -32,13 +32,18 @@ class PrintAreaTest extends AbstractFunctional
|
||||||
$sheet->getPageSetup()->setPrintArea("A$i:B$i");
|
$sheet->getPageSetup()->setPrintArea("A$i:B$i");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$worksheet4 = $spreadsheet->createSheet()->setTitle('Sheet 4');
|
||||||
|
$worksheet4->getPageSetup()->setPrintArea('A4:B4,D1:E4');
|
||||||
|
|
||||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (BaseReader $reader) {
|
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (BaseReader $reader) {
|
||||||
$reader->setLoadSheetsOnly(['Sheet 1', 'Sheet 3']);
|
$reader->setLoadSheetsOnly(['Sheet 1', 'Sheet 3', 'Sheet 4']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$actual1 = $reloadedSpreadsheet->getSheetByName('Sheet 1')->getPageSetup()->getPrintArea();
|
$actual1 = $reloadedSpreadsheet->getSheetByName('Sheet 1')->getPageSetup()->getPrintArea();
|
||||||
$actual3 = $reloadedSpreadsheet->getSheetByName('Sheet 3')->getPageSetup()->getPrintArea();
|
$actual3 = $reloadedSpreadsheet->getSheetByName('Sheet 3')->getPageSetup()->getPrintArea();
|
||||||
|
$actual4 = $reloadedSpreadsheet->getSheetByName('Sheet 4')->getPageSetup()->getPrintArea();
|
||||||
self::assertSame('A1:B1', $actual1, 'should be able to write and read normal page setup');
|
self::assertSame('A1:B1', $actual1, 'should be able to write and read normal page setup');
|
||||||
self::assertSame('A3:B3', $actual3, 'should be able to write and read page setup even when skipping sheets');
|
self::assertSame('A3:B3', $actual3, 'should be able to write and read page setup even when skipping sheets');
|
||||||
|
self::assertSame('A4:B4,D1:E4', $actual4, 'should be able to write and read page setup with multiple print areas');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue