81 $endColumn = $endColumn ?: $this->worksheet->getHighestColumn();
95 public function seek(
string $column =
'A')
99 if ($this->onlyExistingCells && !($this->worksheet->cellExistsByColumnAndRow($column, $this->rowIndex))) {
100 throw new PhpSpreadsheetException(
'In "IterateOnlyExistingCells" mode and Cell does not exist');
102 if (($column < $this->startColumnIndex) || ($column > $this->endColumnIndex)) {
103 throw new PhpSpreadsheetException(
"Column $columnx is out of range ({$this->startColumnIndex} - {$this->endColumnIndex})");
105 $this->currentColumnIndex = $column;
123 return $this->worksheet->getCellByColumnAndRow($this->currentColumnIndex, $this->rowIndex);
129 public function key(): string
141 }
while (($this->onlyExistingCells) && (!$this->worksheet->cellExistsByColumnAndRow($this->currentColumnIndex, $this->rowIndex)) && ($this->currentColumnIndex <= $this->endColumnIndex));
151 }
while (($this->onlyExistingCells) && (!$this->worksheet->cellExistsByColumnAndRow($this->currentColumnIndex, $this->rowIndex)) && ($this->currentColumnIndex >= $this->startColumnIndex));
161 return $this->currentColumnIndex <= $this->endColumnIndex && $this->currentColumnIndex >=
$this->startColumnIndex;
177 if ($this->onlyExistingCells) {
178 while ((!$this->worksheet->cellExistsByColumnAndRow($this->startColumnIndex, $this->rowIndex)) && ($this->startColumnIndex <= $this->endColumnIndex)) {
181 while ((!$this->worksheet->cellExistsByColumnAndRow($this->endColumnIndex, $this->rowIndex)) && ($this->endColumnIndex >= $this->startColumnIndex)) {
An exception for terminatinating execution or to throw for unit testing.
Helper class to manipulate cell coordinates.
static columnIndexFromString($pString)
Column index from string.
static stringFromColumnIndex($columnIndex)
String from column index.
prev()
Set the iterator to its previous value.
adjustForExistingOnlyRange()
Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary.
valid()
Indicate if more columns exist in the worksheet range of columns that we're iterating.
next()
Set the iterator to its next value.
resetStart(string $startColumn='A')
(Re)Set the start column and the current column pointer.
__construct(?Worksheet $worksheet=null, $rowIndex=1, $startColumn='A', $endColumn=null)
Create a new column iterator.
getCurrentColumnIndex()
Return the current iterator position.
resetEnd($endColumn=null)
(Re)Set the end column.
key()
Return the current iterator key.
seek(string $column='A')
Set the column pointer to the selected column.
current()
Return the current cell in this worksheet row.
rewind()
Rewind the iterator to the starting column.