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

  1. Use a valid date/time pattern (e.g. "yyyy-mm-dd", "hh:mm:ss") instead of numeric format codes
  2. Omit the pattern options to use defaults
  3. 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

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


AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02). Data as JSON: /api/errors/46983da460b94ed9. Report an issue: GitHub.