Update get cell logic in Cell Iterators

This commit is contained in:
MarkBaker 2022-05-05 16:53:56 +02:00
parent 4a071ce578
commit 7201ddd088
2 changed files with 10 additions and 2 deletions

View File

@ -120,7 +120,11 @@ class ColumnCellIterator extends CellIterator
*/ */
public function current(): ?Cell public function current(): ?Cell
{ {
return $this->worksheet->getCellByColumnAndRow($this->columnIndex, $this->currentRow); $cellAddress = Coordinate::stringFromColumnIndex($this->columnIndex) . $this->currentRow;
return $this->worksheet->getCellCollection()->has($cellAddress)
? $this->worksheet->getCellCollection()->get($cellAddress)
: $this->worksheet->createNewCell($cellAddress);
} }
/** /**

View File

@ -123,7 +123,11 @@ class RowCellIterator extends CellIterator
*/ */
public function current(): ?Cell public function current(): ?Cell
{ {
return $this->worksheet->getCellByColumnAndRow($this->currentColumnIndex, $this->rowIndex); $cellAddress = Coordinate::stringFromColumnIndex($this->currentColumnIndex) . $this->rowIndex;
return $this->worksheet->getCellCollection()->has($cellAddress)
? $this->worksheet->getCellCollection()->get($cellAddress)
: $this->worksheet->createNewCell($cellAddress);
} }
/** /**