qax-os/excelize · error
ErrOutlineLevel
ErrOutlineLevel
Error message
invalid outline level
What it means
ErrOutlineLevel is returned when an outline (grouping) level outside the valid range 1-7 is passed to SetColOutlineLevel or SetRowOutlineLevel. Excel only supports 7 outline levels per sheet, so level 0 or any value above 7 is rejected.
Source
Thrown at errors.go:117
ErrMaxRowHeight = fmt.Errorf("the height of the row must be less than or equal to %d points", MaxRowHeight)
// ErrMaxRows defined the error message on receive a row number exceeds
// maximum limit.
ErrMaxRows = errors.New("row number exceeds maximum limit")
// ErrNameLength defined the error message on receiving the defined name or
// table name length exceeds the limit.
ErrNameLength = fmt.Errorf("the name length exceeds the %d characters limit", MaxFieldLength)
// ErrMaxGraphicAltTextLength defined the error message on receiving the
// graphic alt text length exceeds the limit.
ErrMaxGraphicAltTextLength = fmt.Errorf("the alt text length exceeds the %d characters limit", MaxGraphicAltTextLength)
// ErrMaxGraphicNameLength defined the error message on receiving the
// graphic name length exceeds the limit.
ErrMaxGraphicNameLength = fmt.Errorf("the name length exceeds the %d characters limit", MaxGraphicNameLength)
// ErrOptionsUnzipSizeLimit defined the error message for receiving
// invalid UnzipSizeLimit and UnzipXMLSizeLimit.
ErrOptionsUnzipSizeLimit = errors.New("the value of UnzipSizeLimit should be greater than or equal to UnzipXMLSizeLimit")
// ErrOutlineLevel defined the error message on receive an invalid outline
// level number.
ErrOutlineLevel = errors.New("invalid outline level")
// ErrPageSetupAdjustTo defined the error message for receiving a page setup
// adjust to value exceeds limit.
ErrPageSetupAdjustTo = errors.New("adjust to value must be an integer from 0 to 400")
// ErrParameterInvalid defined the error message on receive the invalid
// parameter.
ErrParameterInvalid = errors.New("parameter is invalid")
// ErrParameterRequired defined the error message on receive the empty
// parameter.
ErrParameterRequired = errors.New("parameter is required")
// ErrPasswordLengthInvalid defined the error message on invalid password
// length.
ErrPasswordLengthInvalid = errors.New("password length invalid")
// ErrPivotTableShowValuesAsBaseField defined the error message on enable
// this kind of "show values as" type requires a base field.
ErrPivotTableShowValuesAsBaseField = errors.New("this kind of show values as type requires a base field")
// ErrPivotTableShowValuesAsBaseItem defined the error message on enable
// this kind of "show values as" type and base field requires a base item.
ErrPivotTableShowValuesAsBaseItem = errors.New("this kind of show values as type and base field requires a base item")View on GitHub (pinned to f2483381fb)
Solutions
- Clamp or validate the outline level to 1..7 before calling the setter
- Skip calls with an out-of-range level instead of passing it
- Merge deep grouping hierarchies to at most 7 levels
Example fix
// before
f.SetRowOutlineLevel("Sheet1", i+1, uint8(depth)) // depth can be 8+
// after
if depth >= 1 && depth <= 7 {
if err := f.SetRowOutlineLevel("Sheet1", i+1, uint8(depth)); err != nil { return err }
} Defensive patterns
Strategy: validation
Validate before calling
func validOutlineLevel(l uint8) bool { return l >= 1 && l <= 7 }
if validOutlineLevel(level) { err := f.SetColOutlineLevel(sheet, col, level) } Type guard
func validOutlineLevel(l uint8) bool { return l >= 1 && l <= 7 } Prevention
- Clamp computed depths to 1..7 before calling outline setters
- Skip level 0 (no grouping) instead of passing it
- Remember Excel caps outline depth at 7 levels
When it happens
Trigger: Calling File.SetColOutlineLevel(sheet, col, level) or File.SetRowOutlineLevel(sheet, row, level) with level == 0 or level > 7 (e.g. SetColOutlineLevel("Sheet1","D",8)); also hit internally by marshalAttrs when serializing invalid outline attributes.
Common situations: Looping over computed nesting depths (e.g. depth from a tree algorithm) that can exceed 7; off-by-one loops like for i := 0; i <= 7; i++ that pass 0 or 8; porting data from other formats with deeper grouping.
Related errors
- ErrPageSetupAdjustTo
- ErrParameterInvalid
- fill type value must be one of 'gradient' or 'pattern'
- fill color value must be an array of two colors for 'gradien
- fill shading value must be between 0 and 16 for 'gradient' t
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/5b76395b7dc2a101.
Report an issue: GitHub.