{"record":{"id":"c57560ed99b2a6f9","repo":"qax-os/excelize","slug":"unsupported-pivot-table-cache-source-type-s","errorCode":null,"errorMessage":"unsupported pivot table cache source type: %s","messagePattern":"unsupported pivot table cache source type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":411,"sourceCode":"\treturn fmt.Errorf(\"must call the %s function before the SetRow function\", name)\n}\n\n// newUnknownFilterTokenError defined the error message on receiving a unknown\n// filter operator token.\nfunc newUnknownFilterTokenError(token string) error {\n\treturn fmt.Errorf(\"unknown operator: %s\", token)\n}\n\n// newUnsupportedChartType defined the error message on receiving the chart\n// type are unsupported.\nfunc newUnsupportedChartType(chartType ChartType) error {\n\treturn fmt.Errorf(\"unsupported chart type %d\", chartType)\n}\n\n// newUnsupportedPivotCacheSourceType defined the error message on receiving the\n// source type of pivot table cache.\nfunc newUnsupportedPivotCacheSourceType(sourceType string) error {\n\treturn fmt.Errorf(\"unsupported pivot table cache source type: %s\", sourceType)\n}\n\n// newUnzipSizeLimitError defined the error message on unzip size exceeds the\n// limit.\nfunc newUnzipSizeLimitError(unzipSizeLimit int64) error {\n\treturn fmt.Errorf(\"unzip size exceeds the %d bytes limit\", unzipSizeLimit)\n}\n\n// newViewIdxError defined the error message on receiving a invalid sheet view\n// index.\nfunc newViewIdxError(viewIndex int) error {\n\treturn fmt.Errorf(\"view index %d out of range\", viewIndex)\n}\n","sourceCodeStart":393,"sourceCodeEnd":425,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L393-L425","documentation":"Excelize supports pivot caches built from worksheet ranges; this error is thrown when a pivot cache in the workbook declares a source type other than the supported worksheet source (e.g. an external data connection or OLAP cube), which the library cannot read or reconstruct.","triggerScenarios":"Calling f.GetPivotTable (or iterating pivot tables) on a workbook whose pivot cacheDefinition XML has a cacheSource type like 'external' or 'scenario' rather than 'worksheet', typically in files produced by Excel connected to external data.","commonSituations":"Opening corporate XLSX templates whose pivot tables pull from SQL Server/OLAP connections and calling GetPivotTable; copying pivot sheets between workbooks with external caches.","solutions":["Convert the pivot table's data source to a plain worksheet range inside the workbook (Data > Change Data Source) before processing it with excelize.","Guard GetPivotTable calls and skip pivot tables whose cache source is external, logging them instead of failing.","Remove or recreate external-connection pivot tables in Excel before handing the file to excelize.","If you need external-source pivots, keep them in a separate workbook not processed by the library."],"exampleFix":"// before\npivots, err := f.GetPivotTable(\"Sheet1\", \"A3\") // panics on external cache source\n// after\nif isWorksheetRangeSource(cacheXML) {\n    pivots, err = f.GetPivotTable(\"Sheet1\", \"A3\")\n} else {\n    log.Printf(\"skipping pivot with unsupported source type %s\", sourceType)\n}","handlingStrategy":"try-catch","validationCode":"// No public pre-check API for pivot cache source type; inspect the package XML\n// before calling GetPivotTable in untrusted files:\n// unzip xl/pivotCache/pivotCacheDefinition*.xml and confirm\n// <cacheSource type=\"worksheet\"> before processing.","typeGuard":null,"tryCatchPattern":"pivots, err := f.GetPivotTable(sheet, cell)\nif err != nil {\n    if strings.Contains(err.Error(), \"unsupported pivot table cache source type\") {\n        log.Printf(\"skipping pivot at %s!%s: external/unsupported cache source\", sheet, cell)\n        return nil // treat as non-fatal\n    }\n    return err\n}","preventionTips":["Preprocess workbooks so pivots use in-workbook worksheet ranges","Treat GetPivotTable errors as non-fatal when scanning third-party files","Document that excelize only reads worksheet-range pivot caches","Keep external-connection pivots in workbooks not processed by excelize"],"tags":["go","excelize","pivot-table","data-source"],"backgroundTag":"unsupported-pivot-cache-source","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}