Expand description
rxls — a native Rust spreadsheet library: no JVM, no Apache POI, no subprocess.
Reads legacy .xls (BIFF8 & BIFF5/7 — [MS-XLS]), .xlsx (SpreadsheetML),
.xlsb (BIFF12), and .ods (OpenDocument); writes .xlsx. It surfaces
typed cells (Cell) — number, date, boolean, error, text, and formula (the
source is decompiled where supported, alongside the cached value).
Legacy .xls is an OLE2/CFB compound file whose Workbook stream is a sequence
of BIFF records; the OOXML/ODF formats are ZIP packages of XML (binary records
for .xlsb). The reader walks the shared-string table and the cell records of
each worksheet.
Two ways to consume a file: plain text for search/indexing, or typed
cells (Cell) for structured reading.
// Text:
let bytes = std::fs::read("book.xls").unwrap();
println!("{}", rxls::extract_text(&bytes).unwrap());
// Typed cells:
let wb = rxls::Workbook::open(&bytes).unwrap();
for sheet in &wb.sheets {
for (row, col, cell) in sheet.cells() {
match cell {
rxls::Cell::Number(n) => println!("{row},{col} = {n}"),
rxls::Cell::Date(serial) => println!("{row},{col} = serial {serial}"),
rxls::Cell::Text(t) => println!("{row},{col} = {t}"),
_ => {}
}
}
}For modern files (BIFF8) strings are UTF-16. For older BIFF5/7 files strings
are 8-bit in the workbook’s ANSI codepage (announced by the CODEPAGE
record); rxls decodes those correctly — e.g. Korean cp949 — via
encoding_rs. Use Workbook::open_with_codepage to force a codepage.
Date/time serials and percentages are rendered as Excel displays them
(2024-03-15, 50%) via the XF / FORMAT / DATEMODE records. The parser
is panic-free / bounds-checked: malformed input yields Error, never a crash.
Authoring (.xlsx, default feature) covers styles, merges, formulas, data
validation, conditional formatting, images, charts, tables, rich strings,
comments, defined names, and document properties — see Workbook::to_xlsx.
Modules§
- wasm
- Portable read-only adapter used by WebAssembly consumers.
Structs§
- Alignment
- Cell text alignment.
- Border
- Cell borders (per edge).
- Cell
Protection - Cell-level protection flags in an authored cell style.
- Cell
Style - Inline cell style for authoring. All
None/default ⇒ Excel “General”; the writer interns these into the workbook’s deduped style tables. - Chart
- A chart anchored to a cell box, plotting one or more data series from worksheet ranges. Used for authoring and populated by readers that surface chart metadata.
- Chart
Cached Point - One indexed value retained from an OOXML chart cache.
- Chart
Series Cache - Bounded cached inputs for one chart series.
- Chart
Series Style - Bounded visual metadata retained for one imported chart series.
- Chart
Text Style - Uniform effective text style retained for one semantic imported-chart role.
- Chart
Text Styles - Fixed-cardinality text-style sidecar for semantic imported-chart roles.
- Color
- An RGB color, emitted as an 8-hex ARGB string (
FF+RRGGBB). - Comment
- A legacy cell comment / note (authoring) — the yellow pop-up note anchored to
a cell, emitted as
xl/comments{N}.xmlplus a VML shape. - Comment
Author - Author input for
Sheet::add_comment. - Cond
Format - A conditional-formatting rule applied to a cell range (authoring).
- Conditional
Format Metadata - Read-side OOXML details retained beside a public
CondFormat. - CsvOptions
- Stable options for deterministic CSV export.
- Data
Validation - A data validation rule (authoring) — a dropdown list or a numeric/date/text constraint applied to a cell range.
- Dimensions
- Inclusive rectangular worksheet dimensions.
- Display
Cell - One deduplicated, display-ready worksheet cell.
- DocProperties
- Workbook document properties (Dublin Core + extended), read from OOXML
docProps/*, ODFmeta.xml, and legacy OLE property streams, and written todocProps/core.xmlanddocProps/app.xmlfor.xlsx. Every field is optional; only the set ones are emitted. - Drawing
Crop - Source drawing crop, normalized to parts per million of each edge.
- Drawing
Metadata - Bounded rendering sidecar for a worksheet drawing object.
- Excel
Date Time - Calendar date/time decoded from an Excel serial number.
- Fill
- Cell fill formatting.
- Font
- A cell font.
- Format
- Writer format object, compatible with the existing
CellStylemodel. - Formula
Range - A rectangular view over cells that contain formula source text.
- Formula
Range Row - A borrowed row view inside a
FormulaRange. - Formula
Range RowCells - Iterator over one borrowed
FormulaRangeRow’s formulas. - Formula
Range RowUsed Cells - Iterator over non-empty formulas in one borrowed
FormulaRangeRow. - Formula
Range Rows - Iterator over borrowed
FormulaRangeRowviews. - Header
Footer Metadata - Distinct source header/footer strings and their authored behavior flags.
- Image
- An embedded image (authoring). The bytes are stored as-is (no decoding); the image is anchored to a cell box and scaled to fit it.
- Local
Defined Name - A worksheet-scoped defined name retained independently from global names.
- Page
Setup - Print / page setup for a worksheet (authoring). All fields optional; an unset field uses Excel’s default.
- Parse
Provenance - Deterministic provenance retained after a successful workbook parse.
- Picture
- Workbook-level embedded picture metadata for calamine-style read facades.
- Print
Loss - One aggregated source print-metadata loss boundary.
- Print
Metadata - Bounded, loss-aware source print metadata retained beside
PageSetup. - Protection
Options - Granular worksheet-protection allowances (authoring). Each field, when
true, permits the corresponding action even while the sheet is protected; theDefault(allfalse) locks everything, matchingSheet::protect. Pass toSheet::protect_with. - Range
- A rectangular, calamine-style view over a worksheet’s effective cells.
- Range
Deserializer - Iterator returned by
RangeDeserializerBuilder. - Range
Deserializer Builder - Builds a typed row deserializer for a
Range. - Range
Row - A borrowed row view inside a
Range. - Range
RowCells - Iterator over one borrowed
RangeRow’s cells. - Range
RowUsed Cells - Iterator over non-empty cells in one borrowed
RangeRow. - Range
Rows - Iterator over borrowed
RangeRowviews. - Report
Evaluation - Bounded formula evaluation distribution used by library and CLI reports.
- Report
Features - Worksheet feature totals from metadata and surface APIs.
- Report
Properties - Document properties surfaced in the diagnose report.
- Report
Stats - Stable workbook stats used by the diagnose report.
- Series
- One chart data series. Ranges are A1 references into a sheet, e.g.
Sheet1!$B$2:$B$9. - Sheet
- One worksheet: a name, its non-empty cells, and layout/structure (authoring).
- Sheet
Metadata - Public workbook sheet metadata.
- Sheet
View - Public worksheet view metadata.
- Sparkline
- A sparkline (authoring): an in-cell mini chart that summarizes a source
range. The range is an A1 reference such as
Sheet1!$A$1:$A$12;locationis the destination cell. - Spreadsheet
- A workbook plus the original package bytes needed for no-loss
.xlsx/.xlsmsave. - Style
Loss - One aggregated source-style loss boundary.
- Table
- A worksheet table (authoring) — a styled, autofiltered range with named
header columns (the OOXML
<table>feature). - TextRun
- One run of a rich (mixed-format) string: a text fragment plus the font applied
to it. Author a multi-format cell with
Sheet::write_rich; readers retain supported run metadata throughSheet::rich_text_runs. - Workbook
- A workbook — parsed from
.xls/.xlsx, or built for authoring viaWorkbook::new. - Workbook
Metadata - Public workbook-level metadata.
- Workbook
Report - A compact, deterministic diagnose report for a workbook.
Enums§
- Border
Style - A single border edge style.
- Cell
- A typed cell value — the reader API. Mirrors the common spreadsheet cell
kinds; dates are pre-rendered to an ISO string (no
chronodependency). - Cell
Error Type - Calamine-style typed spreadsheet error value.
- CfRule
- A conditional-formatting rule.
- Chart
BarDirection - Orientation of an OOXML
barChartretained besideChartKind::Bar. - Chart
Frame Fill - Fill paint retained from an imported chart-space frame.
- Chart
Frame Style Loss Kind - Typed reason that an imported chart-frame style needs a rendering fallback.
- Chart
Kind - Chart kind.
- Chart
Marker Symbol - Marker shape retained for one imported chart series.
- Chart
Series Style Loss Kind - Typed reason that an imported chart-series style needs a rendering fallback.
- Chart
Unsupported Reason - Unsupported source-chart construct retained for explicit placeholder rendering.
- Container
Parse Mode - Container path used to produce a workbook.
- CsvExport
Error - Failure returned by
export_csv. - CsvFormula
Policy - Policy for text fields that spreadsheet programs may interpret as formulas.
- CsvNewline
- Record separator used by
export_csv. - Drawing
Anchor Behavior - How a drawing responds when its anchor cells are moved or resized.
- Drawing
Object Kind - Kind of object described by
DrawingMetadata. - DvKind
- Data-validation kind.
- DvOp
- Data-validation comparison operator.
- Edit
Capability - Edit/save capability for a
Spreadsheet. - Edit
Read Only Reason - Why a
Spreadsheetcannot be edited/saved package-preservingly. - Error
- Errors produced while opening, decoding, exporting, or editing a spreadsheet.
- Format
Pattern - Excel cell fill pattern.
- Format
Script - Font superscript/subscript setting.
- Formula
Evaluation - Result of evaluating a formula cell.
- Formula
Unsupported Reason - Why a formula could not be evaluated deterministically.
- HAlign
- Horizontal cell alignment.
- Header
Footer Kind - One of the six independently authored worksheet header/footer strings.
- Header
Row - Header-row selection policy for serde row deserialization.
- Image
Fmt - Image format for an embedded
Image. - Markup
Export Error - Failure returned by
export_htmlorexport_markdown. - Markup
Format - Markup format selected by a checked HTML or Markdown export.
- Print
Fidelity - Fidelity of source print metadata retained by a worksheet reader.
- Print
Loss Kind - Stable reason why source print metadata could not be represented exactly.
- Print
Page Order - Authored order used to traverse a worksheet’s printed pages.
- Recovery
Code - Stable reason that a successful parse used a bounded recovery path.
- Sheet
Type - Type of sheet in workbook metadata.
- Sheet
Visible - Sheet visibility state.
- Sparkline
Kind - Sparkline kind for an in-cell mini chart.
- Style
Fidelity - Fidelity of worksheet style information retained in the public model.
- Style
Loss Kind - A bounded, typed reason why source styling could not be represented exactly.
- VAlign
- Vertical cell alignment.
- Write
Error - The error type returned by
Workbook::to_xlsx_checked. A problem found by the checked validator before any.xlsxbytes are emitted.
Constants§
- DEFAULT_
EXPORT_ MAX_ BYTES - Default maximum size of one in-memory export result (256 MiB).
- MAX_
PARSE_ RECOVERY_ CODES - Maximum number of recovery codes retained for one successful parse.
- REPORT_
SCHEMA_ VERSION - Current public diagnose JSON contract version.
Traits§
- Data
Type - Calamine-style value inspection trait implemented by
Cell/Data. - Reader
- Calamine-style read facade for generic workbook consumers.
Functions§
- deserialize_
as_ date_ 1900_ or_ none - Deserialize a spreadsheet cell as a 1900-epoch chrono date, returning
Nonefor invalid cells. - deserialize_
as_ date_ 1900_ or_ string - Deserialize a spreadsheet cell as a 1900-epoch chrono date, preserving invalid cells as text.
- deserialize_
as_ date_ 1904_ or_ none - Deserialize a spreadsheet cell as a 1904-epoch chrono date, returning
Nonefor invalid cells. - deserialize_
as_ date_ 1904_ or_ string - Deserialize a spreadsheet cell as a 1904-epoch chrono date, preserving invalid cells as text.
- deserialize_
as_ datetime_ 1900_ or_ none - Deserialize a spreadsheet cell as a 1900-epoch chrono datetime, returning
Nonefor invalid cells. - deserialize_
as_ datetime_ 1900_ or_ string - Deserialize a spreadsheet cell as a 1900-epoch chrono datetime, preserving invalid cells as text.
- deserialize_
as_ datetime_ 1904_ or_ none - Deserialize a spreadsheet cell as a 1904-epoch chrono datetime, returning
Nonefor invalid cells. - deserialize_
as_ datetime_ 1904_ or_ string - Deserialize a spreadsheet cell as a 1904-epoch chrono datetime, preserving invalid cells as text.
- deserialize_
as_ duration_ or_ none - Deserialize a spreadsheet cell as a chrono duration, returning
Nonefor invalid cells. - deserialize_
as_ duration_ or_ string - Deserialize a spreadsheet cell as a chrono duration, preserving invalid cells as text.
- deserialize_
as_ f64_ or_ none - Deserialize a spreadsheet cell as
f64, returningNonefor invalid cells. - deserialize_
as_ f64_ or_ string - Deserialize a spreadsheet cell as
f64, preserving invalid cells as text. - deserialize_
as_ i64_ or_ none - Deserialize a spreadsheet cell as
i64, returningNonefor invalid cells. - deserialize_
as_ i64_ or_ string - Deserialize a spreadsheet cell as
i64, preserving invalid cells as text. - deserialize_
as_ time_ 1900_ or_ none - Deserialize a spreadsheet cell as a 1900-epoch chrono time, returning
Nonefor invalid cells. - deserialize_
as_ time_ 1900_ or_ string - Deserialize a spreadsheet cell as a 1900-epoch chrono time, preserving invalid cells as text.
- deserialize_
as_ time_ 1904_ or_ none - Deserialize a spreadsheet cell as a 1904-epoch chrono time, returning
Nonefor invalid cells. - deserialize_
as_ time_ 1904_ or_ string - Deserialize a spreadsheet cell as a 1904-epoch chrono time, preserving invalid cells as text.
- excel_
serial_ to_ datetime - Convert an Excel date/time serial to calendar parts.
- excel_
serial_ to_ duration - Convert an Excel duration serial to chrono’s
chrono::Duration. - excel_
serial_ to_ naive_ datetime - Convert an Excel date/time serial to chrono’s
chrono::NaiveDateTime. - export_
csv - Export one worksheet as deterministic, bounded CSV.
- export_
html - Export one worksheet as a bounded HTML table fragment.
- export_
markdown - Export one worksheet as bounded GitHub-flavored Markdown.
- extract_
text - Convenience: decode
.xlsbytes into normalized plain text. Errors withError::NoTextif nothing indexable was found.
Type Aliases§
- Data
- Calamine-style data value name for generic read-side code.
- DataRef
- Calamine-style borrowed data value name for generic read-side code.
- DeError
- Error type returned by range row deserialization.
- Format
Align - Writer alignment enum alias for format-builder APIs.
- Format
Border - Writer border enum alias for format-builder APIs.
- Result
- Convenience alias.