Memory Experiment in Xlsx Writer
This commit is contained in:
parent
48b5d83ee8
commit
d686a991db
|
|
@ -5250,11 +5250,6 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Offset int\\<1, max\\> on array\\<string, non\\-empty\\-array\\<int, string\\>\\> in isset\\(\\) does not exist\\.$#"
|
|
||||||
count: 2
|
|
||||||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#"
|
message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
|
||||||
|
|
@ -1145,11 +1145,15 @@ class Worksheet extends WriterPart
|
||||||
// Highest row number
|
// Highest row number
|
||||||
$highestRow = $worksheet->getHighestRow();
|
$highestRow = $worksheet->getHighestRow();
|
||||||
|
|
||||||
// Loop through cells
|
// Loop through cells building a comma-separated list of the columns in each row
|
||||||
|
// This is a trade-off between the memory usage that is required for a full array of columns,
|
||||||
|
// and execution speed
|
||||||
|
/** @var array<int, string> $cellsByRow */
|
||||||
$cellsByRow = [];
|
$cellsByRow = [];
|
||||||
foreach ($worksheet->getCoordinates() as $coordinate) {
|
foreach ($worksheet->getCoordinates() as $coordinate) {
|
||||||
$cellAddress = Coordinate::coordinateFromString($coordinate);
|
[$column, $row] = Coordinate::coordinateFromString($coordinate);
|
||||||
$cellsByRow[$cellAddress[1]][] = $coordinate;
|
$cellsByRow[$row] = $cellsByRow[$row] ?? '';
|
||||||
|
$cellsByRow[$row] .= "{$column},";
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentRow = 0;
|
$currentRow = 0;
|
||||||
|
|
@ -1195,9 +1199,12 @@ class Worksheet extends WriterPart
|
||||||
|
|
||||||
// Write cells
|
// Write cells
|
||||||
if (isset($cellsByRow[$currentRow])) {
|
if (isset($cellsByRow[$currentRow])) {
|
||||||
foreach ($cellsByRow[$currentRow] as $cellAddress) {
|
// We have a comma-separated list of column names (with a trailing entry); split to an array
|
||||||
|
$columnsInRow = explode(',', $cellsByRow[$currentRow]);
|
||||||
|
array_pop($columnsInRow);
|
||||||
|
foreach ($columnsInRow as $column) {
|
||||||
// Write cell
|
// Write cell
|
||||||
$this->writeCell($objWriter, $worksheet, $cellAddress, $aFlippedStringTable);
|
$this->writeCell($objWriter, $worksheet, "{$column}{$currentRow}", $aFlippedStringTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue