PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Exception
Invalid column index $columnIndex
Error message
Invalid column index $columnIndex
What it means
Error "Invalid column index $columnIndex" thrown in PHPOffice/PhpSpreadsheet.
Source
Thrown at src/PhpSpreadsheet/Cell/Coordinate.php:469
}
private const LOOKUP_CACHE = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ';
/**
* String from column index.
*
* @param int|numeric-string $columnIndex Column index (A = 1)
*/
public static function stringFromColumnIndex(int|string $columnIndex, bool $tolerateZero = false): string
{
/** @var string[] */
static $indexCache = [];
$columnIndex2 = (int) $columnIndex;
if ($columnIndex2 === 0 && $tolerateZero) {
return '';
}
if ($columnIndex2 < 1 || $columnIndex2 > AddressRange::MAX_COLUMN_INT) {
throw new Exception("Invalid column index $columnIndex");
}
$columnIndex = $columnIndex2;
if (!isset($indexCache[$columnIndex])) {
$indexValue = $columnIndex;
$base26 = '';
do {
$characterValue = ($indexValue % 26) ?: 26;
$indexValue = ($indexValue - $characterValue) / 26;
$base26 = self::LOOKUP_CACHE[$characterValue] . $base26;
} while ($indexValue > 0);
$indexCache[$columnIndex] = $base26;
}
return $indexCache[$columnIndex];
}
/**View on GitHub (pinned to 65b080eef4)
When it happens
Trigger: Thrown at src/PhpSpreadsheet/Cell/Coordinate.php:469 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/2e3b7ef3bea22954.
Report an issue: GitHub.