PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Reader\Exception

Not a cell range address

Error message

Not a cell range address

What it means

BIFF8 variant of the range sanity check: an 8-byte cell-range record with 2-byte row and column fields decoded with first row > last row or first column > last column. Since Excel stores ranges low-to-high, an inverted pair means misaligned or corrupt data rather than a legitimate range.

Source

Thrown at src/PhpSpreadsheet/Reader/Xls/Biff8.php:223

     * section 2.5.14.
     */
    protected static function readBIFF8CellRangeAddressFixed(string $subData): string
    {
        // offset: 0; size: 2; index to first row
        $fr = self::getUInt2d($subData, 0) + 1;

        // offset: 2; size: 2; index to last row
        $lr = self::getUInt2d($subData, 2) + 1;

        // offset: 4; size: 2; index to first column
        $fc = self::getUInt2d($subData, 4);

        // offset: 6; size: 2; index to last column
        $lc = self::getUInt2d($subData, 6);

        // check values
        if ($fr > $lr || $fc > $lc) {
            throw new ReaderException('Not a cell range address');
        }

        // column index to letter
        $fc = Coordinate::stringFromColumnIndex($fc + 1);
        $lc = Coordinate::stringFromColumnIndex($lc + 1);

        if ($fr == $lr && $fc == $lc) {
            return "$fc$fr";
        }

        return "$fc$fr:$lc$lr";
    }

    /**
     * Reads a cell range address in BIFF8 e.g. 'A2:B6' or '$A$2:$B$6'
     * there are flags indicating whether column/row index is relative
     * section 3.3.4.
     */

View on GitHub (pinned to 65b080eef4)

Solutions

  1. Convert/re-save the workbook through Excel or LibreOffice to rebuild the records
  2. Recover a clean copy from source (re-download, re-export) and confirm it opens in Excel
  3. Load with setReadDataOnly(true) or restrict loaded sheets via setLoadSheetsOnly() to isolate the damaged sheet
Defensive patterns

Strategy: try-catch

Try / catch

try {
    $spreadsheet = IOFactory::load($path);
} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
    if (str_contains($e->getMessage(), 'Not a cell range address')) {
        // isolate sheets with setLoadSheetsOnly() or convert the file, then retry
    }
}

Prevention

When it happens

Trigger: Stream misalignment caused by an earlier mis-sized record, corrupt range records (dimensions, selection, merged cells, autofilter), or 0xFFFF deleted-reference markers landing in range fields.

Common situations: Damaged .xls uploads; files from unreliable exporters; workbooks whose records a prior tool rewrote incorrectly.

Related errors


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