Skip to content

Commit a86ad55

Browse files
authored
Merge pull request #2806 from PHPOffice/Performance-Xls-Writer
Memory Experiment in Xls Writer
2 parents b72b423 + 1b71e75 commit a86ad55

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/PhpSpreadsheet/Writer/Xls.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
66
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
7+
use PhpOffice\PhpSpreadsheet\Cell\Cell;
78
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
89
use PhpOffice\PhpSpreadsheet\RichText\RichText;
910
use PhpOffice\PhpSpreadsheet\RichText\Run;
@@ -161,8 +162,9 @@ public function save($filename, int $flags = 0): void
161162

162163
// add fonts from rich text eleemnts
163164
for ($i = 0; $i < $countSheets; ++$i) {
164-
foreach ($this->writerWorksheets[$i]->phpSheet->getCoordinates() as $coordinate) {
165-
$cell = $this->writerWorksheets[$i]->phpSheet->getCell($coordinate);
165+
foreach ($this->writerWorksheets[$i]->phpSheet->getCellCollection()->getCoordinates() as $coordinate) {
166+
/** @var Cell $cell */
167+
$cell = $this->writerWorksheets[$i]->phpSheet->getCellCollection()->get($coordinate);
166168
$cVal = $cell->getValue();
167169
if ($cVal instanceof RichText) {
168170
$elements = $cVal->getRichTextElements();

src/PhpSpreadsheet/Writer/Xls/Worksheet.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PhpOffice\PhpSpreadsheet\Writer\Xls;
44

55
use GdImage;
6+
use PhpOffice\PhpSpreadsheet\Cell\Cell;
67
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
78
use PhpOffice\PhpSpreadsheet\Cell\DataType;
89
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
@@ -406,8 +407,9 @@ public function close(): void
406407
}
407408

408409
// Write Cells
409-
foreach ($phpSheet->getCoordinates() as $coordinate) {
410-
$cell = $phpSheet->getCell($coordinate);
410+
foreach ($phpSheet->getCellCollection()->getSortedCoordinates() as $coordinate) {
411+
/** @var Cell $cell */
412+
$cell = $phpSheet->getCellCollection()->get($coordinate);
411413
$row = $cell->getRow() - 1;
412414
$column = Coordinate::columnIndexFromString($cell->getColumn()) - 1;
413415

0 commit comments

Comments
 (0)