{"record":{"id":"58a4b06a1f2b8f6c","repo":"qax-os/excelize","slug":"errsparklinetype","errorCode":"ErrSparklineType","errorMessage":"parameter 'Type' value must be one of 'line', 'column' or 'win_loss'","messagePattern":"parameter 'Type' value must be one of 'line', 'column' or 'win_loss'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":170,"sourceCode":"\tErrSheetNameLength = fmt.Errorf(\"the sheet name length exceeds the %d characters limit\", MaxSheetNameLength)\n\t// ErrSheetNameSingleQuote defined the error message on the first or last\n\t// character of the sheet name was a single quote.\n\tErrSheetNameSingleQuote = errors.New(\"the first or last character of the sheet name can not be a single quote\")\n\t// ErrSparkline defined the error message on receive the invalid sparkline\n\t// parameters.\n\tErrSparkline = errors.New(\"must have the same number of 'Location' and 'Range' parameters\")\n\t// ErrSparklineLocation defined the error message on missing Location\n\t// parameters\n\tErrSparklineLocation = errors.New(\"parameter 'Location' is required\")\n\t// ErrSparklineRange defined the error message on missing sparkline Range\n\t// parameters\n\tErrSparklineRange = errors.New(\"parameter 'Range' is required\")\n\t// ErrSparklineStyle defined the error message on receive the invalid\n\t// sparkline Style parameters.\n\tErrSparklineStyle = errors.New(\"parameter 'Style' value must be an integer from 0 to 35\")\n\t// ErrSparklineType defined the error message on receive the invalid\n\t// sparkline Type parameters.\n\tErrSparklineType = errors.New(\"parameter 'Type' value must be one of 'line', 'column' or 'win_loss'\")\n\t// ErrTotalSheetHyperlinks defined the error message on hyperlinks count\n\t// overflow.\n\tErrTotalSheetHyperlinks = errors.New(\"over maximum limit hyperlinks in a worksheet\")\n\t// ErrTransparency defined the error message for receiving a transparency\n\t// value exceeds limit.\n\tErrTransparency = errors.New(\"transparency value must be an integer from 0 to 100\")\n\t// ErrUnknownEncryptMechanism defined the error message on unsupported\n\t// encryption mechanism.\n\tErrUnknownEncryptMechanism = errors.New(\"unknown encryption mechanism\")\n\t// ErrUnprotectSheet defined the error message on worksheet has set no\n\t// protection.\n\tErrUnprotectSheet = errors.New(\"worksheet has set no protect\")\n\t// ErrUnprotectSheetPassword defined the error message on remove sheet\n\t// protection with password verification failed.\n\tErrUnprotectSheetPassword = errors.New(\"worksheet protect password not match\")\n\t// ErrUnprotectWorkbook defined the error message on workbook has set no\n\t// protection.\n\tErrUnprotectWorkbook = errors.New(\"workbook has set no protect\")","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L152-L188","documentation":"ErrSparklineType is returned when SparklineOptions.Type is set to an unrecognized value (sparkline.go:412). Only \"line\", \"column\", and \"win_loss\" are valid; anything else cannot be mapped to a sparkline element name.","triggerScenarios":"Calling f.AddSparkline(\"Sheet1\", &SparklineOptions{..., Type: \"bar\"}) or any Type string not in sparkTypes map, when Type != \"\" (empty means default/line).","commonSituations":"Typo variants like \"Line\" or \"winloss\"; guessing type names instead of using the documented constants; translating UI labels (e.g. 'bar') into the Type field.","solutions":["Use exactly \"line\", \"column\" or \"win_loss\" for Type","Leave Type as \"\" to get the default line sparkline","Normalize/case-fold user input to one of the three valid values before the call"],"exampleFix":"// before\nopts.Type = \"bar\"\nf.AddSparkline(\"Sheet1\", opts)\n// after\nopts.Type = \"column\" // one of: line, column, win_loss\nf.AddSparkline(\"Sheet1\", opts)","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"line\": true, \"column\": true, \"win_loss\": true}\nif opts.Type != \"\" && !valid[opts.Type] {\n    return fmt.Errorf(\"invalid sparkline type %q\", opts.Type)\n}","typeGuard":"func validSparklineType(t string) bool {\n    return t == \"\" || t == \"line\" || t == \"column\" || t == \"win_loss\"\n}","tryCatchPattern":"if err := f.AddSparkline(\"Sheet1\", opts); err != nil {\n    if errors.Is(err, excelize.ErrSparklineType) {\n        opts.Type = \"\" // default to line\n        err = f.AddSparkline(\"Sheet1\", opts)\n    }\n    return err\n}","preventionTips":["Use the exact strings line/column/win_loss; define them as constants","Leave Type empty for the default rather than guessing a name","Normalize case/underscores from UI labels before assigning Type"],"tags":["go","excelize","sparkline","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}