PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Exception
Row number must be a positive integer
Error message
Row number must be a positive integer
What it means
Error "Row number must be a positive integer" thrown in PHPOffice/PhpSpreadsheet.
Source
Thrown at src/PhpSpreadsheet/Collection/Cells.php:275
}
/**
* Get highest worksheet column.
*
* @param null|int|string $row Return the highest column for the specified row,
* or the highest column of any row if no row number is passed
*
* @return string Highest column name
*/
public function getHighestColumn($row = null): string
{
if ($row === null) {
return $this->getHighestRowAndColumn()['column'];
}
$row = (int) $row;
if ($row <= 0) {
throw new PhpSpreadsheetException('Row number must be a positive integer');
}
$maxColumn = 1;
$toRow = $row * AddressRange::MAX_COLUMN_INT;
$fromRow = --$row * AddressRange::MAX_COLUMN_INT;
foreach ($this->index as $coordinate) {
if ($coordinate < $fromRow || $coordinate >= $toRow) {
continue;
}
$column = ($coordinate % AddressRange::MAX_COLUMN_INT) ?: AddressRange::MAX_COLUMN_INT;
$maxColumn = max($column, $maxColumn);
}
return Coordinate::stringFromColumnIndex($maxColumn);
}
/**
* Get highest worksheet row.View on GitHub (pinned to 65b080eef4)
When it happens
Trigger: Thrown at src/PhpSpreadsheet/Collection/Cells.php:275 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/daae4690de420c49.
Report an issue: GitHub.