PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Exception

Row $row is out of range ({$this->startRow} - {$this->endRow

Error message

Row $row is out of range ({$this->startRow} - {$this->endRow})

What it means

Error "Row $row is out of range ({$this->startRow} - {$this->endRow})" thrown in PHPOffice/PhpSpreadsheet.

Source

Thrown at src/PhpSpreadsheet/Worksheet/RowIterator.php:101

     */
    public function resetEnd(?int $endRow = null): static
    {
        $this->endRow = $endRow ?: $this->subject->getHighestRow();

        return $this;
    }

    /**
     * Set the row pointer to the selected row.
     *
     * @param int $row The row number to set the current pointer at
     *
     * @return $this
     */
    public function seek(int $row = 1): static
    {
        if (($row < $this->startRow) || ($row > $this->endRow)) {
            throw new PhpSpreadsheetException("Row $row is out of range ({$this->startRow} - {$this->endRow})");
        }
        $this->position = $row;

        return $this;
    }

    /**
     * Rewind the iterator to the starting row.
     */
    public function rewind(): void
    {
        $this->position = $this->startRow;
    }

    /**
     * Return the current row in this worksheet.
     */
    public function current(): Row

View on GitHub (pinned to 65b080eef4)

When it happens

Trigger: Thrown at src/PhpSpreadsheet/Worksheet/RowIterator.php:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of PHPOffice/PhpSpreadsheet@65b080eef4 (2026-08-17). Data as JSON: /api/errors/47ab2b7b9229dbe9. Report an issue: GitHub.