{"record":{"id":"434da3b10e1baa48","repo":"qax-os/excelize","slug":"fill-pattern-value-must-be-between-0-and-18","errorCode":null,"errorMessage":"fill pattern value must be between 0 and 18","messagePattern":"fill pattern value must be between 0 and 18","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":77,"sourceCode":"\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\n\t// value exceeds limit.\n\tErrFormControlValue = fmt.Errorf(\"scroll value must be an integer from 0 to %d\", MaxFormControlValue)\n\t// ErrGroupSheets defined the error message on group sheets.\n\tErrGroupSheets = errors.New(\"group worksheet must contain an active worksheet\")\n\t// ErrImgExt defined the error message on receive an unsupported image\n\t// extension.\n\tErrImgExt = errors.New(\"unsupported image extension\")\n\t// ErrInvalidFormula defined the error message on receive an invalid\n\t// formula.\n\tErrInvalidFormula = errors.New(\"formula not valid\")\n\t// ErrMaxFilePathLength defined the error message on receive the file path\n\t// length overflow.","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L59-L95","documentation":"ErrFillPattern is returned by parseFormatStyleSet when Fill.Type is \"pattern\" and Fill.Pattern is outside the inclusive range 0-18. The pattern value selects which OOXML pattern style (solid, dots, stripes, etc.) to apply.","triggerScenarios":"Calling f.NewStyle(&Style{Fill: Fill{Type: \"pattern\", Pattern: 19}}) or passing a negative Pattern value.","commonSituations":"Using pattern constants from another library or a newer OOXML spec revision, computing pattern from user input, or off-by-one errors against the 0-18 valid range.","solutions":["Set Fill.Pattern to an integer between 0 and 18 inclusive (1 is the solid pattern).","Clamp the value to [0, 18] before calling NewStyle.","Map your pattern names to this library's 0-18 numbering explicitly."],"exampleFix":"// before\nf.NewStyle(&Style{Fill: Fill{Type: \"pattern\", Pattern: 19}})\n// after\nf.NewStyle(&Style{Fill: Fill{Type: \"pattern\", Pattern: 1}}) // 1 = solid","handlingStrategy":"validation","validationCode":"if fill.Type == \"pattern\" && (fill.Pattern < 0 || fill.Pattern > 18) {\n    return fmt.Errorf(\"pattern %d out of range 0-18\", fill.Pattern)\n}","typeGuard":"func validPattern(p int) bool { return p >= 0 && p <= 18 }","tryCatchPattern":"_, err := f.NewStyle(&Style{Fill: fill})\nif errors.Is(err, excelize.ErrFillPattern) {\n    fill.Pattern = 1 // default to solid\n    _, err = f.NewStyle(&Style{Fill: fill})\n}","preventionTips":["Define named Go constants for pattern values 0-18.","Clamp pattern values derived from user input.","Test boundary values 0, 18, and 19 in unit tests."],"tags":["go","excelize","style","pattern","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}