{"record":{"id":"b4f7216326d33c60","repo":"qax-os/excelize","slug":"errtransparency","errorCode":"ErrTransparency","errorMessage":"transparency value must be an integer from 0 to 100","messagePattern":"transparency value must be an integer from 0 to 100","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":176,"sourceCode":"\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\")\n\t// ErrUnprotectWorkbookPassword defined the error message on remove workbook\n\t// protection with password verification failed.\n\tErrUnprotectWorkbookPassword = errors.New(\"workbook protect password not match\")\n\t// ErrUnsupportedEncryptMechanism defined the error message on unsupported\n\t// encryption mechanism.\n\tErrUnsupportedEncryptMechanism = errors.New(\"unsupported encryption mechanism\")","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L158-L194","documentation":"ErrTransparency is returned when a chart or shape fill Transparency value is outside 0-100. parseChartOptions/parseSeries (chart.go:593, 617) and parseShapeOptions validate it because Excel stores transparency as a percentage and out-of-range values produce invalid XML.","triggerScenarios":"Calling f.AddChart or f.AddShape with opts.Fill.Transparency < 0 or > 100, or any series whose series.Fill.Transparency is out of range (chart.go:617).","commonSituations":"Confusing opacity (0-100, opaque first) with transparency (0-100, transparent last) and passing 100-opacity as transparency; computing alpha (0-255 or 0.0-1.0) and forgetting to convert to percent.","solutions":["Clamp Transparency into [0,100] before AddChart/AddShape","Convert opacity to transparency: transparency = 100 - opacity","Convert fractional alpha: transparency = int(alpha * 100)"],"exampleFix":"// before\nchartOpts.Fill.Transparency = 128 // alpha-style value\nf.AddChart(\"Sheet1\", \"A1\", chartOpts)\n// after\nt := 100 - opacityPercent\nif t < 0 { t = 0 } else if t > 100 { t = 100 }\nchartOpts.Fill.Transparency = t\nf.AddChart(\"Sheet1\", \"A1\", chartOpts)","handlingStrategy":"validation","validationCode":"if t < 0 || t > 100 {\n    t = 0\n}\nopts.Fill.Transparency = t","typeGuard":"func transparencyValid(t int) bool {\n    return t >= 0 && t <= 100\n}","tryCatchPattern":"if _, err := f.AddChart(\"Sheet1\", \"A1\", opts); err != nil {\n    if errors.Is(err, excelize.ErrTransparency) {\n        // clamp fill and all series transparency values, then retry\n    }\n    return err\n}","preventionTips":["Clamp Transparency for the chart fill AND every series fill","Convert opacity/alpha to the 0-100 transparency scale before use","Validate style values in one place (an options normalizer) before AddChart/AddShape"],"tags":["go","excelize","chart","shape","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"}