Merge pull request #2806 from PHPOffice/Performance-Xls-Writer

Memory Experiment in Xls Writer
This commit is contained in:
Mark Baker 2022-05-05 13:53:53 +02:00 committed by GitHub
commit a86ad55a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Writer;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
use PhpOffice\PhpSpreadsheet\RichText\Run;
@ -161,8 +162,9 @@ class Xls extends BaseWriter
// add fonts from rich text eleemnts
for ($i = 0; $i < $countSheets; ++$i) {
foreach ($this->writerWorksheets[$i]->phpSheet->getCoordinates() as $coordinate) {
$cell = $this->writerWorksheets[$i]->phpSheet->getCell($coordinate);
foreach ($this->writerWorksheets[$i]->phpSheet->getCellCollection()->getCoordinates() as $coordinate) {
/** @var Cell $cell */
$cell = $this->writerWorksheets[$i]->phpSheet->getCellCollection()->get($coordinate);
$cVal = $cell->getValue();
if ($cVal instanceof RichText) {
$elements = $cVal->getRichTextElements();

View File

@ -3,6 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Xls;
use GdImage;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
@ -406,8 +407,9 @@ class Worksheet extends BIFFwriter
}
// Write Cells
foreach ($phpSheet->getCoordinates() as $coordinate) {
$cell = $phpSheet->getCell($coordinate);
foreach ($phpSheet->getCellCollection()->getSortedCoordinates() as $coordinate) {
/** @var Cell $cell */
$cell = $phpSheet->getCellCollection()->get($coordinate);
$row = $cell->getRow() - 1;
$column = Coordinate::columnIndexFromString($cell->getColumn()) - 1;