File tree 1 file changed +10
-0
lines changed
src/PhpSpreadsheet/Writer/Xls
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,10 @@ public function close()
281
281
{
282
282
$ phpSheet = $ this ->phpSheet ;
283
283
284
+ // Storing selected cells and active sheet because it changes while parsing cells with formulas.
285
+ $ selectedCells = $ this ->phpSheet ->getSelectedCells ();
286
+ $ activeSheetIndex = $ this ->phpSheet ->getParent ()->getActiveSheetIndex ();
287
+
284
288
// Write BOF record
285
289
$ this ->storeBof (0x0010 );
286
290
@@ -459,6 +463,9 @@ public function close()
459
463
// Append
460
464
$ this ->writeMsoDrawing ();
461
465
466
+ // Restoring active sheet.
467
+ $ this ->phpSheet ->getParent ()->setActiveSheetIndex ($ activeSheetIndex );
468
+
462
469
// Write WINDOW2 record
463
470
$ this ->writeWindow2 ();
464
471
@@ -471,6 +478,9 @@ public function close()
471
478
$ this ->writePanes ();
472
479
}
473
480
481
+ // Restoring selected cells.
482
+ $ this ->phpSheet ->setSelectedCells ($ selectedCells );
483
+
474
484
// Write SELECTION record
475
485
$ this ->writeSelection ();
476
486
You can’t perform that action at this time.
0 commit comments