qax-os/excelize · error

ErrUnsupportedPivotTableShowValuesAsType

ErrUnsupportedPivotTableShowValuesAsType

Error message

unsupported pivot table show values as type

What it means

ErrUnsupportedPivotTableShowValuesAsType indicates that the ShowDataAs value in PivotTableOptions is not a recognized "show values as" type. setPivotTableShowValuesAs checks the value against pivotTableShowValuesAsMap and returns this error on miss (pivotTable.go:907).

Source

Thrown at errors.go:203

	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 {
	return fmt.Sprintf("sheet %s does not exist", err.SheetName)
}

View on GitHub (pinned to f2483381fb)

Solutions

  1. Use one of the documented ShowDataAs constants/strings accepted by excelize
  2. Omit ShowDataAs (defaults to "normal")
  3. Check pivotTableShowValuesAsMap in pivotTable.go for valid values

Example fix

// before
opt.ShowDataAs = "PercentOfTotal" // not a valid token
// after
opt.ShowDataAs = "percent" // valid value from pivotTableShowValuesAsMap
f.AddPivotTable(opt)
Defensive patterns

Strategy: validation

Validate before calling

valid := map[string]bool{"normal": true, "difference": true, "percent": true, /* see pivotTableShowValuesAsMap */}
if opt.ShowDataAs != "" && !valid[opt.ShowDataAs] {
	return fmt.Errorf("invalid ShowDataAs: %s", opt.ShowDataAs)
}

Try / catch

err := f.AddPivotTable(opt)
if errors.Is(err, excelize.ErrUnsupportedPivotTableShowValuesAsType) {
	return fmt.Errorf("ShowDataAs %q not supported; check docs", opt.ShowDataAs)
}

Prevention

When it happens

Trigger: Calling f.AddPivotTable(&PivotTableOptions{... ShowDataAs: "invalidType" ...}) with a string not in the supported map (e.g. not "normal", "percent", etc.).

Common situations: Typo in ShowDataAs; copying values from Excel UI naming that differs from excelize's accepted constants.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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