{"record":{"id":"e0a96213335a6c74","repo":"qax-os/excelize","slug":"errunprotectworkbook","errorCode":"ErrUnprotectWorkbook","errorMessage":"workbook has set no protect","messagePattern":"workbook has set no protect","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"errors.go","lineNumber":188,"sourceCode":"\tErrSparklineType = errors.New(\"parameter 'Type' value must be one of 'line', 'column' or 'win_loss'\")\n\t// ErrTotalSheetHyperlinks defined the error message on hyperlinks count\n\t// overflow.\n\tErrTotalSheetHyperlinks = errors.New(\"over maximum limit hyperlinks in a worksheet\")\n\t// ErrTransparency defined the error message for receiving a transparency\n\t// value exceeds limit.\n\tErrTransparency = errors.New(\"transparency value must be an integer from 0 to 100\")\n\t// ErrUnknownEncryptMechanism defined the error message on unsupported\n\t// encryption mechanism.\n\tErrUnknownEncryptMechanism = errors.New(\"unknown encryption mechanism\")\n\t// ErrUnprotectSheet defined the error message on worksheet has set no\n\t// protection.\n\tErrUnprotectSheet = errors.New(\"worksheet has set no protect\")\n\t// ErrUnprotectSheetPassword defined the error message on remove sheet\n\t// protection with password verification failed.\n\tErrUnprotectSheetPassword = errors.New(\"worksheet protect password not match\")\n\t// ErrUnprotectWorkbook defined the error message on workbook has set no\n\t// protection.\n\tErrUnprotectWorkbook = errors.New(\"workbook has set no protect\")\n\t// ErrUnprotectWorkbookPassword defined the error message on remove workbook\n\t// protection with password verification failed.\n\tErrUnprotectWorkbookPassword = errors.New(\"workbook protect password not match\")\n\t// ErrUnsupportedEncryptMechanism defined the error message on unsupported\n\t// encryption mechanism.\n\tErrUnsupportedEncryptMechanism = errors.New(\"unsupported encryption mechanism\")\n\t// ErrUnsupportedHashAlgorithm defined the error message on unsupported\n\t// hash algorithm.\n\tErrUnsupportedHashAlgorithm = errors.New(\"unsupported hash algorithm\")\n\t// ErrUnsupportedNumberFormat defined the error message on unsupported\n\t// number format expression.\n\tErrUnsupportedNumberFormat = errors.New(\"unsupported number format token\")\n\t// ErrUnsupportedPivotTableShowValuesAsType defined the error message on\n\t// receiving the unsupported pivot table \"show values as\" type.\n\tErrUnsupportedPivotTableShowValuesAsType = errors.New(\"unsupported pivot table show values as type\")\n\t// ErrWorkbookFileFormat defined the error message on receive an\n\t// unsupported workbook file format.\n\tErrWorkbookFileFormat = errors.New(\"unsupported workbook file format\")","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L170-L206","documentation":"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.","triggerScenarios":"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.","commonSituations":"Calling UnprotectWorkbook with a password on an unprotected workbook; calling it twice without checking state.","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"],"exampleFix":"// before\nerr := f.UnprotectWorkbook(\"password\") // workbook not password-protected\n// after\nerr := f.UnprotectWorkbook() // no password needed","handlingStrategy":"try-catch","validationCode":"// only pass a password if workbook protection has a password hash\n// wb.WorkbookProtection != nil && wb.WorkbookProtection.WorkbookHashValue != \"\"","typeGuard":null,"tryCatchPattern":"if err := f.UnprotectWorkbook(\"pw\"); err != nil && !errors.Is(err, excelize.ErrUnprotectWorkbook) {\n\treturn err\n}","preventionTips":["Call UnprotectWorkbook() without arguments when no password was set","Check protection state before attempting unprotection","Ignore ErrUnprotectWorkbook for idempotent cleanup"],"tags":["go","excelize","workbook-protection"],"backgroundTag":"workbook-not-protected","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}