{"record":{"id":"24da957a7a84c529","repo":"qax-os/excelize","slug":"sheet-s-is-not-a-worksheet","errorCode":null,"errorMessage":"sheet %s is not a worksheet","messagePattern":"sheet (.+?) is not a worksheet","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":345,"sourceCode":"\treturn fmt.Errorf(\"invalid style ID %d\", styleID)\n}\n\n// newNoExistSlicerError defined the error message on receiving the non existing\n// slicer name.\nfunc newNoExistSlicerError(name string) error {\n\treturn fmt.Errorf(\"slicer %s does not exist\", name)\n}\n\n// newNoExistTableError defined the error message on receiving the non existing\n// table name.\nfunc newNoExistTableError(name string) error {\n\treturn fmt.Errorf(\"table %s does not exist\", name)\n}\n\n// newNotWorksheetError defined the error message on receiving a sheet which\n// not a worksheet.\nfunc newNotWorksheetError(name string) error {\n\treturn fmt.Errorf(\"sheet %s is not a worksheet\", name)\n}\n\n// newPivotTableColFieldsError defined the error message on same data field\n// appears both in the pivot table column fields and filter fields.\nfunc newPivotTableColFieldsError(data []string) error {\n\treturn fmt.Errorf(\"data fields %s appear both in the pivot table column fields and filter fields\", strings.Join(data, \", \"))\n}\n\n// newPivotTableRowFieldsError defined the error message on same data field\n// appears both in the pivot table row fields and filter fields.\nfunc newPivotTableRowFieldsError(data []string) error {\n\treturn fmt.Errorf(\"data fields %s appear both in the pivot table row fields and filter fields\", strings.Join(data, \", \"))\n}\n\n// newPivotTableDataRangeError defined the error message on receiving the\n// invalid pivot table data range.\nfunc newPivotTableDataRangeError(msg string) error {\n\treturn fmt.Errorf(\"parameter 'DataRange' parsing error: %s\", msg)","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L327-L363","documentation":"Returned by newNotWorksheetError when a sheet name resolves to a chart sheet (or other non-worksheet sheet type) instead of a regular worksheet. Many APIs that read or write cell data, column/row dimensions, data validations, array formulas, or linked values only operate on worksheets, so the library refuses the operation. It is a misuse-of-input error: the sheet exists but is of the wrong type.","triggerScenarios":"Calling adjustColDimensions, adjustRowDimensions, adjustDataValidations, setArrayFormulaCells, workSheetReader, or UpdateLinkedValue with a sheet name that points to a chartsheet rather than a worksheet, e.g. f.UpdateLinkedValue on a sheet created via AddChartSheet.","commonSituations":"Developers add a chart sheet with a name that later collides with or is mistakenly used in place of a data sheet; scripts iterate all sheets from GetSheetMap (which includes chart sheets) and apply cell operations to every one; renaming/reorganizing workbooks where the data moved off a chartsheet tab.","solutions":["Confirm the target sheet is a worksheet (e.g. via f.GetSheetIndex / workbook sheet type) and pass a regular worksheet name","If you must process all sheets, skip non-worksheet types such as chart sheets","If the data sheet is missing, create it with NewSheet and move the data before calling the API","If you intended a chart, use the chart APIs instead of cell-level worksheet APIs"],"exampleFix":"// before\nfor _, name := range f.GetSheetMap() {\n    _ = f.UpdateLinkedValue(name) // panics/errors on chart sheets\n}\n// after\nfor _, name := range f.GetSheetMap() {\n    if f.GetSheetIndex(name) >= 0 && isWorksheet(f, name) {\n        _ = f.UpdateLinkedValue(name)\n    }\n}","handlingStrategy":"validation","validationCode":"func isWorksheet(f *excelize.File, sheet string) bool {\n    idx, err := f.GetSheetIndex(sheet)\n    return err == nil && idx >= 0 && !strings.HasSuffix(sheet, \" (chart)\") // track chart sheets you created\n}\n// safer: keep an explicit set of chart-sheet names you created via AddChartSheet","typeGuard":"// Go has no runtime type on the name; guard by tracking chart sheets:\nvar chartSheets = map[string]bool{}\nfunc isWorksheet(sheet string) bool { return !chartSheets[sheet] }","tryCatchPattern":"if err := f.UpdateLinkedValue(sheet); err != nil {\n    if strings.Contains(err.Error(), \"is not a worksheet\") {\n        continue // skip chart sheets\n    }\n    return err\n}","preventionTips":["Track which sheets were created with AddChartSheet and never pass them to cell-level APIs","Filter GetSheetMap results to worksheet-type sheets before bulk operations","Use constants for data-sheet names instead of free-form strings"],"tags":["go","excelize","worksheet","sheet-type"],"backgroundTag":"sheet-not-a-worksheet","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}