qax-os/excelize · error
sheet %s is not a worksheet
Error message
sheet %s is not a worksheet
What it means
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.
Source
Thrown at errors.go:345
return fmt.Errorf("invalid style ID %d", styleID)
}
// newNoExistSlicerError defined the error message on receiving the non existing
// slicer name.
func newNoExistSlicerError(name string) error {
return fmt.Errorf("slicer %s does not exist", name)
}
// newNoExistTableError defined the error message on receiving the non existing
// table name.
func newNoExistTableError(name string) error {
return fmt.Errorf("table %s does not exist", name)
}
// newNotWorksheetError defined the error message on receiving a sheet which
// not a worksheet.
func newNotWorksheetError(name string) error {
return fmt.Errorf("sheet %s is not a worksheet", name)
}
// newPivotTableColFieldsError defined the error message on same data field
// appears both in the pivot table column fields and filter fields.
func newPivotTableColFieldsError(data []string) error {
return fmt.Errorf("data fields %s appear both in the pivot table column fields and filter fields", strings.Join(data, ", "))
}
// newPivotTableRowFieldsError defined the error message on same data field
// appears both in the pivot table row fields and filter fields.
func newPivotTableRowFieldsError(data []string) error {
return fmt.Errorf("data fields %s appear both in the pivot table row fields and filter fields", strings.Join(data, ", "))
}
// newPivotTableDataRangeError defined the error message on receiving the
// invalid pivot table data range.
func newPivotTableDataRangeError(msg string) error {
return fmt.Errorf("parameter 'DataRange' parsing error: %s", msg)View on GitHub (pinned to f2483381fb)
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
Example fix
// before
for _, name := range f.GetSheetMap() {
_ = f.UpdateLinkedValue(name) // panics/errors on chart sheets
}
// after
for _, name := range f.GetSheetMap() {
if f.GetSheetIndex(name) >= 0 && isWorksheet(f, name) {
_ = f.UpdateLinkedValue(name)
}
} Defensive patterns
Strategy: validation
Validate before calling
func isWorksheet(f *excelize.File, sheet string) bool {
idx, err := f.GetSheetIndex(sheet)
return err == nil && idx >= 0 && !strings.HasSuffix(sheet, " (chart)") // track chart sheets you created
}
// safer: keep an explicit set of chart-sheet names you created via AddChartSheet Type guard
// Go has no runtime type on the name; guard by tracking chart sheets:
var chartSheets = map[string]bool{}
func isWorksheet(sheet string) bool { return !chartSheets[sheet] } Try / catch
if err := f.UpdateLinkedValue(sheet); err != nil {
if strings.Contains(err.Error(), "is not a worksheet") {
continue // skip chart sheets
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- group worksheet must contain an active worksheet
- ErrSheetIdx
- fill type value must be one of 'gradient' or 'pattern'
- fill color value must be an array of two colors for 'gradien
- fill shading value must be between 0 and 16 for 'gradient' t
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/24da957a7a84c529.
Report an issue: GitHub.