qax-os/excelize · error

ErrSheetNameBlank

ErrSheetNameBlank

Error message

the sheet name can not be blank

What it means

ErrSheetNameBlank is returned when a worksheet name is an empty string. checkSheetName (sheet.go:1514) rejects blank names because Excel requires every worksheet to have a non-empty name, and operations like copy or rename would produce a corrupt workbook.

Source

Thrown at errors.go:146

	// 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")
	// ErrPivotTableClassicLayout defined the error message on enable
	// ClassicLayout and CompactData in the same time.
	ErrPivotTableClassicLayout = errors.New("cannot enable ClassicLayout and CompactData in the same time")
	// ErrSave defined the error message for saving file.
	ErrSave = errors.New("no path defined for file, consider File.WriteTo or File.Write")
	// ErrSheetIdx defined the error message on receive the invalid worksheet
	// index.
	ErrSheetIdx = errors.New("invalid worksheet index")
	// ErrSheetNameBlank defined the error message on receive the blank sheet
	// name.
	ErrSheetNameBlank = errors.New("the sheet name can not be blank")
	// ErrSheetNameInvalid defined the error message on receive the sheet name
	// contains invalid characters.
	ErrSheetNameInvalid = errors.New("the sheet can not contain any of the characters :\\/?*[or]")
	// ErrSheetNameLength defined the error message on receiving the sheet
	// name length exceeds the limit.
	ErrSheetNameLength = fmt.Errorf("the sheet name length exceeds the %d characters limit", MaxSheetNameLength)
	// ErrSheetNameSingleQuote defined the error message on the first or last
	// character of the sheet name was a single quote.
	ErrSheetNameSingleQuote = errors.New("the first or last character of the sheet name can not be a single quote")
	// ErrSparkline defined the error message on receive the invalid sparkline
	// parameters.
	ErrSparkline = errors.New("must have the same number of 'Location' and 'Range' parameters")
	// ErrSparklineLocation defined the error message on missing Location
	// parameters
	ErrSparklineLocation = errors.New("parameter 'Location' is required")
	// ErrSparklineRange defined the error message on missing sparkline Range
	// parameters
	ErrSparklineRange = errors.New("parameter 'Range' is required")

View on GitHub (pinned to f2483381fb)

Solutions

  1. Check the sheet index/name before the call; use f.GetSheetName(index) to confirm the source sheet exists
  2. Ensure the sheet name string is non-empty (e.g. validate or default to "Sheet1")
  3. If copying, pass a valid source and target index of existing/new sheets

Example fix

// before
err := f.CopySheet(-1, -2)
// after
name := f.GetSheetName(srcIdx)
if name == "" {
    return fmt.Errorf("source sheet %d not found", srcIdx)
}
err := f.CopySheet(srcIdx, targetIdx)
Defensive patterns

Strategy: validation

When it happens

Trigger: Calling f.copySheet(-1, -2) with a source sheet index that resolves to no valid sheet name, or any API (CopySheet, rename helpers, etc.) that passes "" through checkSheetName before operating.

Common situations: Passing an out-of-range sheet index whose name lookup yields an empty string; building sheet names from configuration or user input that was never set; forgetting to initialize a name variable before calling sheet APIs.

Related errors


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