Introduction
Excelize provides a pure Go implementation for reading and writing Office Open XML spreadsheet files. It lets backend services generate complex Excel reports, import user-uploaded spreadsheets, and process large datasets without relying on external binaries or COM automation.
What Excelize Does
- Reads and writes XLSX, XLSM, and XLTM files with full formula support
- Creates charts (bar, line, pie, scatter, and 50+ chart types)
- Generates pivot tables and applies conditional formatting rules
- Embeds images, shapes, and comments into cells
- Streams rows for writing spreadsheets with millions of rows in constant memory
Architecture Overview
Excelize operates on the underlying ZIP-packaged XML structure of Office Open XML files. It parses shared strings, style sheets, and worksheet XML into in-memory Go structs, applies edits, then serializes back to valid OOXML. The streaming writer bypasses full in-memory representation by flushing rows directly to the output, enabling constant-memory writes for large files.
Self-Hosting & Configuration
- Install via
go get github.com/xuri/excelize/v2 - Zero external dependencies beyond the Go standard library
- Use
StreamWriterfor files exceeding available RAM - Set default fonts, number formats, and date styles via
Stylestructs - Supports password-protected workbook decryption
Key Features
- Pure Go with no CGO or system dependencies
- Streaming writer handles millions of rows in constant memory
- 170+ formula functions evaluated natively
- 50+ chart types with full customization
- Thread-safe concurrent read access to workbooks
Comparison with Similar Tools
- Apache POI (Java) — mature but requires JVM; Excelize is a single Go binary
- openpyxl (Python) — Python-only; Excelize integrates into Go services natively
- SheetJS (JS) — browser-focused; Excelize targets server-side batch processing
- xlsx2csv — read-only conversion; Excelize supports full read-write-chart workflows
- Google Sheets API — cloud-dependent; Excelize works fully offline
FAQ
Q: Can Excelize handle very large files? A: Yes, the StreamWriter API writes rows incrementally, keeping memory constant regardless of row count.
Q: Does it support formulas? A: Excelize supports setting formula strings and evaluating 170+ built-in functions.
Q: Is Excelize thread-safe? A: Concurrent reads are safe. Writes to a single file should be serialized.
Q: Can I read password-protected Excel files? A: Yes, Excelize supports decrypting workbooks protected with a password.