PHPOffice/PhpSpreadsheet · error · Exception

Only single cell references may be passed to this method.

Error message

Only single cell references may be passed to this method.

What it means

Error "Only single cell references may be passed to this method." thrown in PHPOffice/PhpSpreadsheet.

Source

Thrown at src/PhpSpreadsheet/CellReferenceHelper.php:56

        $this->beforeRow = (int) $beforeRow;
    }

    public function beforeCellAddress(): string
    {
        return $this->beforeCellAddress;
    }

    public function refreshRequired(string $beforeCellAddress, int $numberOfColumns, int $numberOfRows): bool
    {
        return $this->beforeCellAddress !== $beforeCellAddress
            || $this->numberOfColumns !== $numberOfColumns
            || $this->numberOfRows !== $numberOfRows;
    }

    public function updateCellReference(string $cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false, ?bool $topLeft = null): string
    {
        if (Coordinate::coordinateIsRange($cellReference)) {
            throw new Exception('Only single cell references may be passed to this method.');
        }

        // Get coordinate of $cellReference
        [$newColumn, $newRow] = Coordinate::coordinateFromString($cellReference);
        $newColumnIndex = Coordinate::columnIndexFromString(str_replace('$', '', $newColumn));
        $newRowIndex = (int) str_replace('$', '', $newRow);

        $absoluteColumn = $newColumn[0] === '$' ? '$' : '';
        $absoluteRow = $newRow[0] === '$' ? '$' : '';
        // Verify which parts should be updated
        if ($onlyAbsoluteReferences === true) {
            $updateColumn = (($absoluteColumn === '$') && $newColumnIndex >= $this->beforeColumn);
            $updateRow = (($absoluteRow === '$') && $newRowIndex >= $this->beforeRow);
        } elseif ($includeAbsoluteReferences === false) {
            $updateColumn = (($absoluteColumn !== '$') && $newColumnIndex >= $this->beforeColumn);
            $updateRow = (($absoluteRow !== '$') && $newRowIndex >= $this->beforeRow);
        } else {
            $newColumnIndex = $this->computeNewColumnIndex($newColumnIndex, $topLeft);

View on GitHub (pinned to 65b080eef4)

When it happens

Trigger: Thrown at src/PhpSpreadsheet/CellReferenceHelper.php:56 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/5def97c9f219a4ea. Report an issue: GitHub.