{"record":{"id":"ff6d51ee9094c8d2","repo":"PHPOffice/PhpSpreadsheet","slug":"pivot-source-field-fieldname-does-not-exist-i","errorCode":null,"errorMessage":"Pivot source field '{$fieldName}' does not exist in range {$this->sourceRange}","messagePattern":"Pivot source field '(.+?)' does not exist in range (.+?)","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Worksheet/PivotTable/PivotTableBuilder.php","lineNumber":186,"sourceCode":"        }\n\n        $targetWorksheet->addPivotTable($pivotTable);\n\n        return $pivotTable;\n    }\n\n    private function place(string $fieldName, string $axis, ?string $subtotal, ?string $caption): self\n    {\n        $this->assertFieldExists($fieldName);\n        $this->placements[$fieldName] = ['axis' => $axis, 'subtotal' => $subtotal, 'caption' => $caption];\n\n        return $this;\n    }\n\n    private function assertFieldExists(string $fieldName): void\n    {\n        if (!in_array($fieldName, $this->fieldNames, true)) {\n            throw new PhpSpreadsheetException(\"Pivot source field '{$fieldName}' does not exist in range {$this->sourceRange}\");\n        }\n    }\n\n    private function assertHasDataField(): void\n    {\n        foreach ($this->placements as $placement) {\n            if ($placement['axis'] === PivotField::AXIS_VALUES) {\n                return;\n            }\n        }\n\n        throw new PhpSpreadsheetException('A pivot table requires at least one data (value) field');\n    }\n\n    /**\n     * @return string[]\n     */\n    private function readHeaderNames(): array","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Worksheet/PivotTable/PivotTableBuilder.php#L168-L204","documentation":"Error \"Pivot source field '{$fieldName}' does not exist in range {$this->sourceRange}\" thrown in PHPOffice/PhpSpreadsheet.","triggerScenarios":"Thrown at src/PhpSpreadsheet/Worksheet/PivotTable/PivotTableBuilder.php:186 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"}