PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Exception
Sparkline location must be a single cell, not a range
Error message
Sparkline location must be a single cell, not a range
What it means
Error "Sparkline location must be a single cell, not a range" thrown in PHPOffice/PhpSpreadsheet.
Source
Thrown at src/PhpSpreadsheet/Worksheet/Sparkline/Sparkline.php:54
if ($location !== '') {
$this->setLocation($location);
}
$this->setDataRange($dataRange);
}
public function getLocation(): string
{
return $this->location;
}
/**
* Set the cell the sparkline is drawn in. Must be a single cell, not a range.
*/
public function setLocation(CellAddress|string $location): self
{
$location = (string) $location;
if (str_contains($location, ':')) {
throw new PhpSpreadsheetException('Sparkline location must be a single cell, not a range');
}
// Normalise: strip absolute markers and any sheet qualifier.
$location = str_replace('$', '', $location);
if (str_contains($location, '!')) {
$location = substr($location, strrpos($location, '!') + 1);
}
// Validate by attempting to resolve the coordinate.
Coordinate::indexesFromString($location);
$this->location = strtoupper($location);
return $this;
}
public function getDataRange(): string
{
return $this->dataRange;
}
View on GitHub (pinned to 65b080eef4)
When it happens
Trigger: Thrown at src/PhpSpreadsheet/Worksheet/Sparkline/Sparkline.php:54 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/ba334c5f6e36961b.
Report an issue: GitHub.