Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix freeze pane for xlsx files #261

Closed
wants to merge 10 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix old ReferenceHelper
Adrien Cohen committed Nov 2, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 49b13f36ce06b592678bae65f1cbc17e87462220
10 changes: 4 additions & 6 deletions src/PhpSpreadsheet/ReferenceHelper.php
Original file line number Diff line number Diff line change
@@ -585,18 +585,16 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee
// Update worksheet: freeze pane
if ($pSheet->getFreezePane()) {
$splitCell = Cell::stringFromColumnIndex($pSheet->getColSplit()) . ($pSheet->getRowSplit() + 1);
$topLeftCell = Cell::stringFromColumnIndex($pSheet->getLeftMostColumn()) . ($pSheet->getTopRow() + 1);
$topLeftCell = $pSheet->getTopLeftCell();

$colSplit = $rowSplit = $leftMostColumn = $topRow = 0;
$colSplit = $rowSplit = 0;
list($colSplit, $rowSplit) = Cell::coordinateFromString($this->updateCellReference($splitCell, $pBefore, $pNumCols, $pNumRows));
list($leftMostColumn, $topRow) = Cell::coordinateFromString($this->updateCellReference($topLeftCell, $pBefore, $pNumCols, $pNumRows));

$colSplit = Cell::columnIndexFromString($colSplit) - 1;
$leftMostColumn = Cell::columnIndexFromString($leftMostColumn) - 1;
$rowSplit = $rowSplit - 1;
$topRow = $topRow - 1;
$topLeftCell = $this->updateCellReference($topLeftCell, $pBefore, $pNumCols, $pNumRows);

$pSheet->createFreezePane($colSplit, $rowSplit, $leftMostColumn, $topRow);
$pSheet->createFreezePane($colSplit, $rowSplit, $topLeftCell);
}

// Page setup
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Worksheet/Worksheet.php
Original file line number Diff line number Diff line change
@@ -2009,9 +2009,7 @@ public function createFreezePane($colSplit, $rowSplit, $topLeftCell = null)
$topLeftCell = Cell::stringFromColumnIndex($colSplit) . ($rowSplit + 1);
}

if (strpos($topLeftCell, ':') === false && strpos($topLeftCell, ',') === false) {
$this->freezePane = $topLeftCell;
} else {
if (!(strpos($topLeftCell, ':') === false && strpos($topLeftCell, ',') === false)) {
throw new Exception('Freeze pane can not be set on a range of cells.');
}