Skip to content

Commit

Permalink
Fix for Xls writer wrong cells and sheet selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy4o4 committed Nov 25, 2019
1 parent f734783 commit e0f5824
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/PhpSpreadsheet/Writer/Xls/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ public function close()
{
$phpSheet = $this->phpSheet;

// Storing selected cells and active sheet because it changes while parsing cells with formulas.
$selectedCells = $this->phpSheet->getSelectedCells();
$activeSheetIndex = $this->phpSheet->getParent()->getActiveSheetIndex();

// Write BOF record
$this->storeBof(0x0010);

Expand Down Expand Up @@ -459,6 +463,9 @@ public function close()
// Append
$this->writeMsoDrawing();

// Restoring active sheet.
$this->phpSheet->getParent()->setActiveSheetIndex($activeSheetIndex);

// Write WINDOW2 record
$this->writeWindow2();

Expand All @@ -471,6 +478,9 @@ public function close()
$this->writePanes();
}

// Restoring selected cells.
$this->phpSheet->setSelectedCells($selectedCells);

// Write SELECTION record
$this->writeSelection();

Expand Down

0 comments on commit e0f5824

Please sign in to comment.