{"record":{"id":"3325674f47051908","repo":"qax-os/excelize","slug":"errworkbookfileformat","errorCode":"ErrWorkbookFileFormat","errorMessage":"unsupported workbook file format","messagePattern":"unsupported workbook file format","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":206,"sourceCode":"\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\")\n\t// ErrWorkbookPassword defined the error message on receiving the incorrect\n\t// workbook password.\n\tErrWorkbookPassword = errors.New(\"the supplied open workbook password is not correct\")\n)\n\n// ErrSheetNotExist defined an error of sheet that does not exist.\ntype ErrSheetNotExist struct {\n\tSheetName string\n}\n\n// Error returns the error message on receiving the non existing sheet name.\nfunc (err ErrSheetNotExist) Error() string {\n\treturn fmt.Sprintf(\"sheet %s does not exist\", err.SheetName)\n}\n\n// newAddCommentError defined the error message on the comment already exist in\n// the cell.\nfunc newAddCommentError(cell string) error {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L188-L224","documentation":"ErrWorkbookFileFormat indicates that an encrypted workbook's EncryptedPackage stream is malformed — specifically shorter than packageOffset bytes — so the library cannot parse the package. decryptPackage and openReaderAt return it when the encrypted file structure does not meet the minimum size requirements.","triggerScenarios":"OpenReader/OpenFile on an encrypted OLE compound file with an empty or undersized EncryptedPackage stream (test builds compoundFile with EncryptionInfo but empty package); truncated encrypted files.","commonSituations":"Opening a non-workbook file renamed to .xlsx that is also a compound file; corrupted download; file encrypted by a tool writing incomplete streams.","solutions":["Verify the file is a genuine Excel workbook (encrypted or not) and not renamed/misgenerated","Re-obtain or re-save the file from its source","If the file is truly encrypted, decrypt it fully with the producing tool before opening"],"exampleFix":"// before\nf, err := OpenReader(brokenReader) // EncryptedPackage too short\n// after\nbuf, _ := io.ReadAll(src)\nif len(buf) < 1024 { return errors.New(\"file truncated\") }\nf, err := OpenReader(bytes.NewReader(buf))","handlingStrategy":"validation","validationCode":"data, _ := io.ReadAll(r)\nif len(data) < 1024 { return errors.New(\"encrypted package too small / truncated\") }","typeGuard":"func isCompoundFile(b []byte) bool {\n\treturn len(b) > 8 && bytes.Equal(b[:8], []byte{0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1})\n}","tryCatchPattern":"f, err := excelize.OpenReader(r)\nif errors.Is(err, excelize.ErrWorkbookFileFormat) {\n\treturn fmt.Errorf(\"file is not a valid encrypted workbook package\")\n}","preventionTips":["Confirm files are genuine .xlsx (ZIP) or properly encrypted compound files","Check file integrity (size/checksum) after transfer","Do not rename arbitrary files to .xlsx and open them"],"tags":["go","excelize","file-format","encryption","file-parsing"],"backgroundTag":"invalid-file-format","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}