{"record":{"id":"178e7f0d965f37ca","repo":"qax-os/excelize","slug":"fill-type-value-must-be-one-of-gradient-or-patt","errorCode":null,"errorMessage":"fill type value must be one of 'gradient' or 'pattern'","messagePattern":"fill type value must be one of 'gradient' or 'pattern'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":65,"sourceCode":"\t// ErrDataValidationFormulaLength defined the error message for receiving a\n\t// data validation formula length that exceeds the limit.\n\tErrDataValidationFormulaLength = fmt.Errorf(\"data validation must be 0-%d characters\", MaxFieldLength)\n\t// ErrDataValidationRange defined the error message on set decimal range\n\t// exceeds limit.\n\tErrDataValidationRange = errors.New(\"data validation range exceeds limit\")\n\t// ErrDefinedNameDuplicate defined the error message on the same name\n\t// already exists on the scope.\n\tErrDefinedNameDuplicate = errors.New(\"the same name already exists on the scope\")\n\t// ErrDefinedNameScope defined the error message on not found defined name\n\t// in the given scope.\n\tErrDefinedNameScope = errors.New(\"no defined name on the scope\")\n\t// ErrExistsSheet defined the error message on given sheet already exists.\n\tErrExistsSheet = errors.New(\"the same name sheet already exists\")\n\t// ErrExistsTableName defined the error message on given table already\n\t// exists.\n\tErrExistsTableName = errors.New(\"the same name table already exists\")\n\t// ErrFillType defined the error message on receive an invalid fill type.\n\tErrFillType = errors.New(\"fill type value must be one of 'gradient' or 'pattern'\")\n\t// ErrFillGradientColor defined the error message on receive an invalid fill\n\t// color for 'gradient' type.\n\tErrFillGradientColor = errors.New(\"fill color value must be an array of two colors for 'gradient' type\")\n\t// ErrFillGradientShading defined the error message on receive an invalid\n\t// fill shading for 'gradient' type.\n\tErrFillGradientShading = errors.New(\"fill shading value must be between 0 and 16 for 'gradient' type\")\n\t// ErrFillPatternColor defined the error message on receive an invalid fill\n\t// color for 'pattern' type.\n\tErrFillPatternColor = errors.New(\"fill color value must be empty or an array of one color for 'pattern' type\")\n\t// ErrFillPattern defined the error message on receive an invalid fill\n\t// pattern.\n\tErrFillPattern = errors.New(\"fill pattern value must be between 0 and 18\")\n\t// ErrFontLength defined the error message on the length of the font\n\t// family name overflow.\n\tErrFontLength = fmt.Errorf(\"the length of the font family name must be less than or equal to %d\", MaxFontFamilyLength)\n\t// ErrFontSize defined the error message on the size of the font is invalid.\n\tErrFontSize = fmt.Errorf(\"font size must be an integer from %d to %d points\", MinFontSize, MaxFontSize)\n\t// ErrFormControlValue defined the error message for receiving a scroll","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L47-L83","documentation":"ErrFillType is returned by parseFormatStyleSet when Style.Fill.Type is not an accepted value. The library only supports the fill types 'gradient' and 'pattern'; any other non-empty string is rejected when creating a style via NewStyle. An empty type is allowed and defaults to no fill.","triggerScenarios":"Calling f.NewStyle(&Style{Fill: Fill{Type: \"solid\", ...}}) or any Fill.Type string other than \"gradient\", \"pattern\", or \"\".","commonSituations":"Copy-pasting fill type names from other spreadsheet libraries (e.g. 'solid', which is an OOXML pattern value, not a valid Type here), typos like 'Gradient' (case-sensitive), or hand-written style configs.","solutions":["Set Fill.Type to exactly \"pattern\" (case-sensitive lowercase) for solid/standard fills.","Set Fill.Type to \"gradient\" for gradient fills.","Leave Fill.Type as the empty string \"\" when no fill is desired.","Remove a constant imported from another library (e.g. 'solid') that does not match this API."],"exampleFix":"// before\nstyle, err := f.NewStyle(&Style{Fill: Fill{Type: \"solid\", Color: []string{\"FFFF00\"}}})\n// after\nstyle, err := f.NewStyle(&Style{Fill: Fill{Type: \"pattern\", Pattern: 1, Color: []string{\"FFFF00\"}}})","handlingStrategy":"validation","validationCode":"func validFillType(t string) bool { return t == \"\" || t == \"gradient\" || t == \"pattern\" }\nif !validFillType(fill.Type) { return errors.New(\"Fill.Type must be \\\"gradient\\\", \\\"pattern\\\", or empty\") }","typeGuard":"func isFillType(v string) bool { return v == \"\" || v == \"gradient\" || v == \"pattern\" }","tryCatchPattern":"if _, err := f.NewStyle(&Style{Fill: fill}); err != nil {\n    if errors.Is(err, excelize.ErrFillType) {\n        // fix or log the invalid fill type\n    }\n    return err\n}","preventionTips":["Define your own constants for \"gradient\" and \"pattern\" and only use those.","Never copy fill-type strings from other spreadsheet libraries.","Remember the type match is case-sensitive lowercase."],"tags":["go","excelize","style","fill","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}