{"record":{"id":"ba334c5f6e36961b","repo":"PHPOffice/PhpSpreadsheet","slug":"sparkline-location-must-be-a-single-cell-not-a-ra","errorCode":null,"errorMessage":"Sparkline location must be a single cell, not a range","messagePattern":"Sparkline location must be a single cell, not a range","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Worksheet/Sparkline/Sparkline.php","lineNumber":54,"sourceCode":"        if ($location !== '') {\n            $this->setLocation($location);\n        }\n        $this->setDataRange($dataRange);\n    }\n\n    public function getLocation(): string\n    {\n        return $this->location;\n    }\n\n    /**\n     * Set the cell the sparkline is drawn in. Must be a single cell, not a range.\n     */\n    public function setLocation(CellAddress|string $location): self\n    {\n        $location = (string) $location;\n        if (str_contains($location, ':')) {\n            throw new PhpSpreadsheetException('Sparkline location must be a single cell, not a range');\n        }\n        // Normalise: strip absolute markers and any sheet qualifier.\n        $location = str_replace('$', '', $location);\n        if (str_contains($location, '!')) {\n            $location = substr($location, strrpos($location, '!') + 1);\n        }\n        // Validate by attempting to resolve the coordinate.\n        Coordinate::indexesFromString($location);\n        $this->location = strtoupper($location);\n\n        return $this;\n    }\n\n    public function getDataRange(): string\n    {\n        return $this->dataRange;\n    }\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Worksheet/Sparkline/Sparkline.php#L36-L72","documentation":"Error \"Sparkline location must be a single cell, not a range\" thrown in PHPOffice/PhpSpreadsheet.","triggerScenarios":"Thrown at src/PhpSpreadsheet/Worksheet/Sparkline/Sparkline.php:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}