qax-os/excelize · error
ErrUnsupportedNumberFormat
ErrUnsupportedNumberFormat
Error message
unsupported number format token
What it means
ErrUnsupportedNumberFormat indicates that a date/time pattern supplied in Options (LongDatePattern, LongTimePattern, ShortDatePattern) is not a valid number format token sequence. The library validates the pattern against its number format parser and rejects invalid tokens.
Source
Thrown at errors.go:200
ErrUnprotectSheet = errors.New("worksheet has set no protect")
// ErrUnprotectSheetPassword defined the error message on remove sheet
// protection with password verification failed.
ErrUnprotectSheetPassword = errors.New("worksheet protect password not match")
// ErrUnprotectWorkbook defined the error message on workbook has set no
// protection.
ErrUnprotectWorkbook = errors.New("workbook has set no protect")
// ErrUnprotectWorkbookPassword defined the error message on remove workbook
// protection with password verification failed.
ErrUnprotectWorkbookPassword = errors.New("workbook protect password not match")
// ErrUnsupportedEncryptMechanism defined the error message on unsupported
// encryption mechanism.
ErrUnsupportedEncryptMechanism = errors.New("unsupported encryption mechanism")
// ErrUnsupportedHashAlgorithm defined the error message on unsupported
// hash algorithm.
ErrUnsupportedHashAlgorithm = errors.New("unsupported hash algorithm")
// ErrUnsupportedNumberFormat defined the error message on unsupported
// number format expression.
ErrUnsupportedNumberFormat = errors.New("unsupported number format token")
// ErrUnsupportedPivotTableShowValuesAsType defined the error message on
// receiving the unsupported pivot table "show values as" type.
ErrUnsupportedPivotTableShowValuesAsType = errors.New("unsupported pivot table show values as type")
// ErrWorkbookFileFormat defined the error message on receive an
// unsupported workbook file format.
ErrWorkbookFileFormat = errors.New("unsupported workbook file format")
// ErrWorkbookPassword defined the error message on receiving the incorrect
// workbook password.
ErrWorkbookPassword = errors.New("the supplied open workbook password is not correct")
)
// ErrSheetNotExist defined an error of sheet that does not exist.
type ErrSheetNotExist struct {
SheetName string
}
// Error returns the error message on receiving the non existing sheet name.
func (err ErrSheetNotExist) Error() string {View on GitHub (pinned to f2483381fb)
Solutions
- Use a valid date/time pattern (e.g. "yyyy-mm-dd", "hh:mm:ss") instead of numeric format codes
- Omit the pattern options to use defaults
- Check the number format token table in the excelize docs
Example fix
// before
f, err := OpenFile("Book1.xlsx", Options{LongDatePattern: "0.00"})
// after
f, err := OpenFile("Book1.xlsx", Options{LongDatePattern: "yyyy-mm-dd"}) Defensive patterns
Strategy: validation
Validate before calling
// validate patterns contain date/time tokens before passing to Options
func isDatePattern(p string) bool {
for _, t := range []string{"yy", "mm", "dd", "hh", "ss"} {
if strings.Contains(p, t) { return true }
}
return false
} Try / catch
f, err := excelize.OpenFile(path, excelize.Options{LongDatePattern: pat})
if errors.Is(err, excelize.ErrUnsupportedNumberFormat) {
return retryWithDefaultPattern(path)
} Prevention
- Use locale-style date patterns, not raw numFmt codes like 0.00
- Test OpenFile options patterns in CI with a sample workbook
- Omit pattern options unless customization is required
When it happens
Trigger: OpenFile/Open with Options{LongDatePattern: "0.00"} or similar numeric-only patterns passed as date/time patterns; also TestNumFmt invalid token cases.
Common situations: Passing a raw Excel numFmt code (like 0.00) where a locale-style date pattern is expected; copy-pasted pattern strings from other systems.
Related errors
- the value of UnzipSizeLimit should be greater than or equal
- 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
- fill color value must be empty or an array of one color for
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/46983da460b94ed9.
Report an issue: GitHub.