Expand description
xlsxparser — a lightweight, high-performance .xlsx (OOXML) parser
library, purpose-built for the kind of files common in Japanese business
systems: sheets with an extreme number of rows/columns (“grid-paper
Excel”) and heavy use of merged cells.
let workbook = xlsxparser::parse_workbook("book.xlsx")?;
let json = xlsxparser::to_json_string(&workbook)?;§Security: CSV / formula injection
Cell string values (including formula-computed result strings, t="str")
pass through into CellValue::Text and the JSON output unchanged, with
no sanitization at any stage — this is safe as JSON output (serde_json
escapes correctly) but not necessarily as CSV or another spreadsheet
format. Callers who re-export parsed values into CSV or .xlsx are
responsible for their own formula-injection mitigations (e.g. escaping a
value that starts with =, +, -, or @), since a .xlsx input is
untrusted and this library performs no rewriting of cell content.
Structs§
- Cell
- A single entry in the sparse matrix. Only cells that hold data or
formatting exist in
Sheet(blank cells are not instantiated). - CellRef
- Cell coordinates. 1-based, matching Excel (A1 = row:1, col:1).
- Date
Time Value - Placeholder type for a resolved date/time value. The concrete type is undecided (docs/design/model/cell.en.md Open Question 4); this stand-in carries no data yet.
- Merged
Region - A merged range. Holds the top-left (origin cell) and bottom-right coordinates.
- Resolved
Style - Format information once a style ID has been resolved.
- Sheet
- Sparse matrix data for a single sheet.
- Size
Limits - Public configuration type callers use to set the Zip Bomb size caps.
lib.rsre-exports this at the crate root and uses it as the argument toparse_workbook_with_limits/parse_workbook_reader_with_limits.DefaultreusesDEFAULT_MAX_UNCOMPRESSED_SIZE/DEFAULT_MAX_TOTAL_UNCOMPRESSED_SIZEas-is, so the default-cap public functions (parse_workbook/parse_workbook_reader) need only passSizeLimits::default()rather than duplicating the values. - Workbook
- The final resolved output model. The return value of
lib.rs::parse_workbook.
Enums§
- Cell
Value - A cell’s value. Has a variant corresponding to each OOXML
tattribute (cell type). - Error
- The common error type used throughout the library. Every module’s failure
modes, including
parse_workbook’sResult::Err, are consolidated into this type. Marked#[non_exhaustive]so future variants can be added without a breaking change. - Sheet
Visibility - A sheet’s visibility (
workbook.xml’s<sheet state="...">).
Functions§
- parse_
workbook - Parses
.xlsxfrom a file path — the most common public entry point. Uses the default Zip Bomb size cap (SizeLimits::default()). To specify the cap explicitly, useparse_workbook_with_limits. - parse_
workbook_ reader - Parses
.xlsxfrom anyRead + Seekinput (an in-memory buffer, a fully-read HTTP response body, etc.) — a general-purpose entry point for callers that don’t go through the filesystem. Requiring a seekable input to read the ZIP central directory simply carries forwardZipContainer::open_reader’s constraint (a purely streamingRead-only input cannot be opened this way). Uses the default Zip Bomb size cap (SizeLimits::default()). To specify the cap explicitly, useparse_workbook_reader_with_limits. - parse_
workbook_ reader_ with_ limits parse_workbook_reader, plus letting the caller specify the Zip Bomb size cap explicitly.parse_workbook_readeris a thin wrapper that simply delegates here withSizeLimits::default().- parse_
workbook_ with_ limits parse_workbook, plus letting the caller specify the Zip Bomb size cap explicitly.parse_workbookis a thin wrapper that simply delegates here withSizeLimits::default(); the actual logic — opening astd::fs::Fileand delegating to the internal pipeline — lives only in this function. Beyond a failure ofFile::openitself, any I/O error arising during ZIP extraction or XML streaming withpathleft unset (None) is backfilled with the file path this function already knows before being returned.- to_
json_ string - A convenience version of
to_json_writerthat targets an in-memoryVec<u8>. Since the entire output must be held as oneString, additional memory usage is O(n) in the output size (unliketo_json_writer’s O(1) — preferto_json_writerwhenever the caller can write directly to a file, HTTP response, etc.). - to_
json_ writer - Streams
workbookout as JSON towriter. Each element of thecellsarray is converted fromSheet::iter_cellsand written out one at a time, without buffering a whole sheet’sVec<JsonCell>in memory. Ifwriteris, say, aBufWriter<File>, additional memory usage stays at O(1) — one cell’s worth at a time.