From ef39af1cb6bac8f3101aa52a6336d736910d387b Mon Sep 17 00:00:00 2001 From: Benjamin Yau Date: Mon, 21 Jan 2019 00:22:07 +0800 Subject: [PATCH] Fix wrong calculation of highest column issue #700 --- src/PhpSpreadsheet/Collection/Cells.php | 2 +- src/PhpSpreadsheet/Reader/Xlsx.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 80a4322098..465a0698c6 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -259,7 +259,7 @@ public function getHighestColumn($row = null) $columnList[] = Coordinate::columnIndexFromString($c); } - return Coordinate::stringFromColumnIndex(max($columnList) + 1); + return Coordinate::stringFromColumnIndex(max($columnList)); } /** diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 335f5d7e99..92c837f5b7 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -2525,6 +2525,10 @@ private function readColumnsAndRowsAttributes(SimpleXMLElement $xmlSheet, Worksh if (isset($xmlSheet->cols) && !$this->readDataOnly) { foreach ($xmlSheet->cols->col as $col) { for ($i = (int) ($col['min']); $i <= (int) ($col['max']); ++$i) { + if ((int) ($col['max']) == 16384) { + break; + } + if ($col['style'] && !$this->readDataOnly) { $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['xfIndex'] = (int) $col['style']; } @@ -2538,10 +2542,6 @@ private function readColumnsAndRowsAttributes(SimpleXMLElement $xmlSheet, Worksh $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['outlineLevel'] = (int) $col['outlineLevel']; } $columnsAttributes[Coordinate::stringFromColumnIndex($i)]['width'] = (float) $col['width']; - - if ((int) ($col['max']) == 16384) { - break; - } } } }