qax-os/excelize · error
ErrUnprotectSheetPassword
ErrUnprotectSheetPassword
Error message
worksheet protect password not match
What it means
ErrUnprotectSheetPassword indicates that the password supplied to UnprotectSheet failed hash verification against the stored sheet protection password. The library throws it when the computed hash does not match WorkbookHashValue/sheet hash stored in the sheet protection settings.
Source
Thrown at errors.go:185
ErrSparklineStyle = errors.New("parameter 'Style' value must be an integer from 0 to 35")
// ErrSparklineType defined the error message on receive the invalid
// sparkline Type parameters.
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")View on GitHub (pinned to f2483381fb)
Solutions
- Supply the correct password that was used in ProtectSheet
- If the password is lost, clear protection by editing the XML or re-creating the sheet
- Call UnprotectSheet without a password only if no password was set
Example fix
// before
err := f.UnprotectSheet("Sheet1", "wrongPassword")
// after
err := f.UnprotectSheet("Sheet1", "password") // actual protection password Defensive patterns
Strategy: try-catch
Try / catch
if err := f.UnprotectSheet("Sheet1", pw); err != nil {
if errors.Is(err, excelize.ErrUnprotectSheetPassword) {
return fmt.Errorf("incorrect sheet password")
}
return err
} Prevention
- Store protection passwords securely alongside the file metadata
- Prompt the user for the password rather than hardcoding
- Verify the password with ProtectSheet's own round-trip in tests
When it happens
Trigger: Calling f.UnprotectSheet(sheetName, "wrongPassword") on a sheet protected with a password; hash comparison in UnprotectSheet fails.
Common situations: Typo in the password; user changed the protection password; password was set by another tool with a different algorithm variant.
Related errors
- ErrPasswordLengthInvalid
- ErrUnprotectSheet
- ErrUnprotectWorkbookPassword
- fill type value must be one of 'gradient' or 'pattern'
- fill color value must be an array of two colors for 'gradien
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/60cd002e305b51f5.
Report an issue: GitHub.