qax-os/excelize · error
unzip size exceeds the %d bytes limit
Error message
unzip size exceeds the %d bytes limit
What it means
Excelize enforces a limit on the total uncompressed size of the parts of an XLSX (Zip) archive when opening files, set via SetUnzipSizeLimit. This error is thrown when the decompressed size of the workbook's contents exceeds that limit, to prevent zip-bomb style memory exhaustion.
Source
Thrown at errors.go:417
return fmt.Errorf("unknown operator: %s", token)
}
// newUnsupportedChartType defined the error message on receiving the chart
// type are unsupported.
func newUnsupportedChartType(chartType ChartType) error {
return fmt.Errorf("unsupported chart type %d", chartType)
}
// newUnsupportedPivotCacheSourceType defined the error message on receiving the
// source type of pivot table cache.
func newUnsupportedPivotCacheSourceType(sourceType string) error {
return fmt.Errorf("unsupported pivot table cache source type: %s", sourceType)
}
// newUnzipSizeLimitError defined the error message on unzip size exceeds the
// limit.
func newUnzipSizeLimitError(unzipSizeLimit int64) error {
return fmt.Errorf("unzip size exceeds the %d bytes limit", unzipSizeLimit)
}
// newViewIdxError defined the error message on receiving a invalid sheet view
// index.
func newViewIdxError(viewIndex int) error {
return fmt.Errorf("view index %d out of range", viewIndex)
}
View on GitHub (pinned to f2483381fb)
Solutions
- Raise the limit with excelize.SetUnzipSizeLimit(largerBytes) before opening the file, sized to your largest expected workbook.
- Audit the workbook for unexpectedly huge embedded media or duplicated sheets; strip unneeded parts.
- If the file is truly enormous, split it into smaller workbooks or stream-process sheet data instead of loading it whole.
- Verify no other code path in the process lowered the global unzip limit (it is package-level, not per-file).
Example fix
// before
excelize.SetUnzipSizeLimit(16 << 20) // 16 MiB, too small
f, err := excelize.OpenFile("big.xlsx")
// after
excelize.SetUnzipSizeLimit(1 << 30) // 1 GiB
f, err := excelize.OpenFile("big.xlsx") Defensive patterns
Strategy: validation
Validate before calling
func openWithSizeLimit(path string, limit int64) (*excelize.File, error) {
if st, err := os.Stat(path); err == nil && st.Size() > limit*50 {
// compressed size hints at a likely zip-bomb; refuse early
return nil, fmt.Errorf("file %s suspiciously large for limit %d", path, limit)
}
excelize.SetUnzipSizeLimit(limit)
return excelize.OpenFile(path)
} Try / catch
f, err := excelize.OpenFile(path)
if err != nil {
if strings.Contains(err.Error(), "unzip size exceeds") {
log.Printf("workbook %s exceeds unzip limit; raising limit or splitting file", path)
excelize.SetUnzipSizeLimit(1 << 30)
f, err = excelize.OpenFile(path)
}
} Prevention
- Size SetUnzipSizeLimit to your largest expected workbook, not the smallest
- Remember the limit is package-global; centralize it in one init function
- Audit workbooks for huge embedded media before bulk processing
- Keep a hard ceiling to stay protected against zip bombs while allowing legitimate large files
When it happens
Trigger: Calling f.Open / f.OpenReader on a workbook whose decompressed parts total more than the value previously passed to excelize.SetUnzipSizeLimit(n).
Common situations: Processing very large workbooks with a low (or previously lowered) size limit; shared pipelines where one job lowered the global limit; archives with many embedded images or sheets.
Related errors
- 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
- fill pattern value must be between 0 and 18
AI-assisted analysis of qax-os/excelize@f2483381fb (2026-09-02).
Data as JSON: /api/errors/c97c8a242683d14b.
Report an issue: GitHub.