qax-os/excelize · warning
ErrUnprotectWorkbook
ErrUnprotectWorkbook
Error message
workbook has set no protect
What it means
ErrUnprotectWorkbook indicates that UnprotectWorkbook was called with a password argument on a workbook that has no workbook-level protection (or no password set). The library throws it because there is no workbook protection to remove.
Source
Thrown at errors.go:188
ErrSparklineType = errors.New("parameter 'Type' value must be one of 'line', 'column' or 'win_loss'")
// ErrTotalSheetHyperlinks defined the error message on hyperlinks count
// overflow.
ErrTotalSheetHyperlinks = errors.New("over maximum limit hyperlinks in a worksheet")
// ErrTransparency defined the error message for receiving a transparency
// value exceeds limit.
ErrTransparency = errors.New("transparency value must be an integer from 0 to 100")
// ErrUnknownEncryptMechanism defined the error message on unsupported
// encryption mechanism.
ErrUnknownEncryptMechanism = errors.New("unknown encryption mechanism")
// ErrUnprotectSheet defined the error message on worksheet has set no
// protection.
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")View on GitHub (pinned to f2483381fb)
Solutions
- Call UnprotectWorkbook() with no arguments when the workbook was protected without a password
- Check WorkbookProtection state before calling
- Ignore this sentinel error if the goal is idempotent unprotection
Example fix
// before
err := f.UnprotectWorkbook("password") // workbook not password-protected
// after
err := f.UnprotectWorkbook() // no password needed Defensive patterns
Strategy: try-catch
Validate before calling
// only pass a password if workbook protection has a password hash // wb.WorkbookProtection != nil && wb.WorkbookProtection.WorkbookHashValue != ""
Try / catch
if err := f.UnprotectWorkbook("pw"); err != nil && !errors.Is(err, excelize.ErrUnprotectWorkbook) {
return err
} Prevention
- Call UnprotectWorkbook() without arguments when no password was set
- Check protection state before attempting unprotection
- Ignore ErrUnprotectWorkbook for idempotent cleanup
When it happens
Trigger: Calling f.UnprotectWorkbook("password") on a workbook whose WorkbookProtection is nil or has no password hash; test path: unprotect then call again with a password.
Common situations: Calling UnprotectWorkbook with a password on an unprotected workbook; calling it twice without checking state.
Related errors
- ErrUnprotectWorkbookPassword
- 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/e0a96213335a6c74.
Report an issue: GitHub.