qax-os/excelize · error
custom number format can not be empty
Error message
custom number format can not be empty
What it means
ErrCustomNumFmt is returned when a Style specifies CustomNumFmt as a non-nil pointer to an empty string. The library treats a present-but-empty custom number format as invalid, since an empty format code cannot be applied to cells. It is raised in parseFormatStyleSet (styles.go) and surfaced via NewStyle/NewConditionalStyle.
Source
Thrown at errors.go:46
// characters length that exceeds the limit.
ErrCellCharsLength = fmt.Errorf("cell value must be 0-%d characters", TotalCellChars)
// ErrCellStyles defined the error message on cell styles exceeds the limit.
ErrCellStyles = fmt.Errorf("the cell styles exceeds the %d limit", MaxCellStyles)
// ErrChartTitle defined the error message on both formula and rich text for
// chart title.
ErrChartTitle = errors.New("cannot set both 'Formula' and 'Paragraph' for chart title")
// ErrColumnNumber defined the error message on receive an invalid column
// number.
ErrColumnNumber = fmt.Errorf("the column number must be greater than or equal to %d and less than or equal to %d", MinColumns, MaxColumns)
// ErrColumnWidth defined the error message on receive an invalid column
// width.
ErrColumnWidth = fmt.Errorf("the width of the column must be less than or equal to %d characters", MaxColumnWidth)
// ErrCoordinates defined the error message on invalid coordinates tuples
// length.
ErrCoordinates = errors.New("coordinates length must be 4")
// ErrCustomNumFmt defined the error message on receive the empty custom
// number format.
ErrCustomNumFmt = errors.New("custom number format can not be empty")
// ErrDataValidationFormulaLength defined the error message for receiving a
// data validation formula length that exceeds the limit.
ErrDataValidationFormulaLength = fmt.Errorf("data validation must be 0-%d characters", MaxFieldLength)
// ErrDataValidationRange defined the error message on set decimal range
// exceeds limit.
ErrDataValidationRange = errors.New("data validation range exceeds limit")
// ErrDefinedNameDuplicate defined the error message on the same name
// already exists on the scope.
ErrDefinedNameDuplicate = errors.New("the same name already exists on the scope")
// ErrDefinedNameScope defined the error message on not found defined name
// in the given scope.
ErrDefinedNameScope = errors.New("no defined name on the scope")
// ErrExistsSheet defined the error message on given sheet already exists.
ErrExistsSheet = errors.New("the same name sheet already exists")
// ErrExistsTableName defined the error message on given table already
// exists.
ErrExistsTableName = errors.New("the same name table already exists")
// ErrFillType defined the error message on receive an invalid fill type.View on GitHub (pinned to f2483381fb)
Solutions
- Set the CustomNumFmt string to a valid format code (e.g. "0.00", "yyyy-mm-dd") before calling NewStyle/NewConditionalStyle
- If no custom format is needed, leave CustomNumFmt nil instead of pointing at an empty string
- Validate the format string non-empty before constructing the Style
- Check where the value is sourced (config, template) to fix the upstream empty value
Example fix
// before
var exp string
_, err := f.NewConditionalStyle(&Style{CustomNumFmt: &exp}) // ErrCustomNumFmt
// after
numFmt := "0.00"
_, err := f.NewConditionalStyle(&Style{CustomNumFmt: &numFmt}) Defensive patterns
Strategy: validation
Validate before calling
func validCustomNumFmt(s *string) bool { return s == nil || *s != "" } Prevention
- Leave CustomNumFmt nil when unused
- Never take the address of a zero-value string variable
- Validate format strings at config-load time
- Source format codes from constants, not ad-hoc empty vars
When it happens
Trigger: Calling f.NewConditionalStyle(&Style{CustomNumFmt: &empty}) or f.NewStyle with CustomNumFmt pointing to "" — the pointer is non-nil so the field is 'set', but the string is empty.
Common situations: Declaring var fmt string (zero value "") and taking its address; template/config values that failed to populate leaving an empty string; copying a Style struct where the original had a valid format that got cleared.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/83878652b33845d8.
Report an issue: GitHub.