{"record":{"id":"931a67443c8585b9","repo":"qax-os/excelize","slug":"unsupported-chart-type-d","errorCode":null,"errorMessage":"unsupported chart type %d","messagePattern":"unsupported chart type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":405,"sourceCode":"\treturn fmt.Errorf(\"row %d has already been written\", row)\n}\n\n// newStreamSetRowOrderError defined the error message on calling the SetRow\n// function before the order function.\nfunc newStreamSetRowOrderError(name string) error {\n\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)","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L387-L423","documentation":"Excelize throws this when a ChartType value passed to AddChart/AddChartSheet is not among the chart types the library can generate, or when a parsed chart XML contains a type the writer cannot map back. getChartOptions rejects the chartType during option building.","triggerScenarios":"Calling f.AddChart(sheet, cell, &excelize.Chart{Type: someChartType}) or f.AddChartSheet with an invalid, zero, or out-of-range ChartType constant; or loading a workbook whose chart XML uses an unsupported chart type and re-saving it.","commonSituations":"Hand-casting an int to ChartType; upgrading/downgrading excelize so a chart constant moved or was removed; copying Chart structs between library versions; reading third-party XLSX files with exotic chart kinds.","solutions":["Use one of the exported excelize chart constants (e.g. excelize.Col, excelize.Line, excelize.Pie3D) instead of raw integers.","Check your excelize version (go list -m github.com/xuri/excelize/v2) and update so the desired chart constant exists.","Verify the Chart.Type field is not left at its zero value after constructing the struct with named fields only.","If the error comes from a loaded file, replace or remove the unsupported chart before re-saving."],"exampleFix":"// before\nerr := f.AddChart(\"Sheet1\", \"A1\", &excelize.Chart{Type: 9999})\n// after\nerr := f.AddChart(\"Sheet1\", \"A1\", &excelize.Chart{Type: excelize.Col})","handlingStrategy":"type-guard","validationCode":"var knownChartTypes = map[excelize.ChartType]bool{\n    excelize.Area: true, excelize.AreaStacked: true,\n    excelize.Bar: true, excelize.Col: true,\n    excelize.Line: true, excelize.Pie: true, excelize.Pie3D: true,\n    excelize.Doughnut: true, excelize.Radar: true,\n    excelize.Scatter: true, excelize.Surface3D: true,\n}\nfunc isKnownChartType(t excelize.ChartType) bool { return knownChartTypes[t] }","typeGuard":"func chartTypeGuard(t excelize.ChartType) (excelize.ChartType, bool) {\n    if isKnownChartType(t) {\n        return t, true\n    }\n    return excelize.Col, false // default fallback\n}","tryCatchPattern":"if err := f.AddChart(sheet, cell, chart); err != nil {\n    if strings.Contains(err.Error(), \"unsupported chart type\") {\n        log.Printf(\"chart type %d unsupported; falling back to column chart\", chart.Type)\n        chart.Type = excelize.Col\n        return f.AddChart(sheet, cell, chart)\n    }\n    return err\n}","preventionTips":["Always assign chart types from exported excelize constants","Never cast raw ints to excelize.ChartType","Pin and review excelize version upgrades in CI","Add a table-driven test enumerating every chart type your app uses"],"tags":["go","excelize","chart","enum"],"backgroundTag":"unsupported-chart-type","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}