Skip to content

Commit

Permalink
Fix wrong calculation of highest column
Browse files Browse the repository at this point in the history
issue #700
  • Loading branch information
BenKewell committed Jan 20, 2019
1 parent bf00f0c commit ef39af1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Collection/Cells.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function getHighestColumn($row = null)
$columnList[] = Coordinate::columnIndexFromString($c);
}

return Coordinate::stringFromColumnIndex(max($columnList) + 1);
return Coordinate::stringFromColumnIndex(max($columnList));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand All @@ -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;
}
}
}
}
Expand Down

0 comments on commit ef39af1

Please sign in to comment.