{"record":{"id":"0ca3bb66b2757acc","repo":"qax-os/excelize","slug":"errsparklinestyle","errorCode":"ErrSparklineStyle","errorMessage":"parameter 'Style' value must be an integer from 0 to 35","messagePattern":"parameter 'Style' value must be an integer from 0 to 35","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":167,"sourceCode":"\tErrSheetNameInvalid = errors.New(\"the sheet can not contain any of the characters :\\\\/?*[or]\")\n\t// ErrSheetNameLength defined the error message on receiving the sheet\n\t// name length exceeds the limit.\n\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\")","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L149-L185","documentation":"Sentinel error ErrSparklineStyle returned by AddSparkline when the SparklineOptions.Style parameter falls outside the supported range 0-35. It fires as a validation guard (opts.Style < 0 || 35 < opts.Style) before the sparkline is written to the worksheet, so an out-of-range style choice is rejected and the workbook is left unchanged.","triggerScenarios":"Calling f.AddSparkline(\"Sheet1\", &SparklineOptions{Location: [\"F3\"], Range: [\"Sheet2!A3:E3\"], Style: 36}) or Style < 0, via parseFormatAddSparklineSet.","commonSituations":"Hard-coding a style number taken from a 1-based UI list (Excel shows 1-36, the API expects 0-35); computing style from user input without clamping.","solutions":["Clamp Style into [0,35] before calling AddSparkline (e.g. opts.Style = 0 if unset)","If migrating from a 1-based scheme, subtract 1 from the displayed style number","Leave Style at 0 (the zero value) to use the default style"],"exampleFix":"// before\nopts.Style = 36\nf.AddSparkline(\"Sheet1\", opts)\n// after\nif opts.Style < 0 || opts.Style > 35 {\n    opts.Style = 0\n}\nf.AddSparkline(\"Sheet1\", opts)","handlingStrategy":"validation","validationCode":"if opts.Style < 0 || opts.Style > 35 {\n    opts.Style = 0\n}","typeGuard":"func sparklineStyleValid(s int) bool {\n    return s >= 0 && s <= 35\n}","tryCatchPattern":"if err := f.AddSparkline(\"Sheet1\", opts); err != nil {\n    if errors.Is(err, excelize.ErrSparklineStyle) {\n        opts.Style = 0 // fall back to default style\n        err = f.AddSparkline(\"Sheet1\", opts)\n    }\n    return err\n}","preventionTips":["Remember the API style is 0-based (0-35) while Excel's UI shows 1-36","Clamp style values taken from user input or config","Leave Style at 0 unless a specific scheme is needed"],"tags":["go","excelize","sparkline","validation","range"],"backgroundTag":"parameter-out-of-range","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}