Fix zoom scale problems on reading bad xlsx files
Some computer programs will output xlsx files that do not compare 100% to the standards. Excel will open the file without any problem. setZoomScaleNormal() should throw exception when manually setting the scale to less than or equals 0, but when reading files, we should be able to read a file with such error, as Excel does. Closes #350
This commit is contained in:
parent
608a2edba7
commit
2e37578971
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- HTML writer creates a generator meta tag - [#312](https://github.com/PHPOffice/PhpSpreadsheet/issues/312)
|
- HTML writer creates a generator meta tag - [#312](https://github.com/PHPOffice/PhpSpreadsheet/issues/312)
|
||||||
|
- Support invalid zoom value in XLSX format - [#350](https://github.com/PHPOffice/PhpSpreadsheet/pull/350)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -702,10 +702,24 @@ class Xlsx extends BaseReader
|
||||||
|
|
||||||
if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) {
|
if (isset($xmlSheet->sheetViews, $xmlSheet->sheetViews->sheetView)) {
|
||||||
if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
|
if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
|
||||||
$docSheet->getSheetView()->setZoomScale((int) ($xmlSheet->sheetViews->sheetView['zoomScale']));
|
$zoomScale = (int) ($xmlSheet->sheetViews->sheetView['zoomScale']);
|
||||||
|
if ($zoomScale <= 0) {
|
||||||
|
// setZoomScale will throw an Exception if the scale is less than or equals 0
|
||||||
|
// that is OK when manually creating documents, but we should be able to read all documents
|
||||||
|
$zoomScale = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
$docSheet->getSheetView()->setZoomScale($zoomScale);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) {
|
if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) {
|
||||||
$docSheet->getSheetView()->setZoomScaleNormal((int) ($xmlSheet->sheetViews->sheetView['zoomScaleNormal']));
|
$zoomScaleNormal = (int) ($xmlSheet->sheetViews->sheetView['zoomScaleNormal']);
|
||||||
|
if ($zoomScaleNormal <= 0) {
|
||||||
|
// setZoomScaleNormal will throw an Exception if the scale is less than or equals 0
|
||||||
|
// that is OK when manually creating documents, but we should be able to read all documents
|
||||||
|
$zoomScaleNormal = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
$docSheet->getSheetView()->setZoomScaleNormal($zoomScaleNormal);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->sheetViews->sheetView['view'])) {
|
if (isset($xmlSheet->sheetViews->sheetView['view'])) {
|
||||||
$docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']);
|
$docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']);
|
||||||
|
|
Loading…
Reference in New Issue