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.
- 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. - Cond
Format - A conditional-formatting rule applied to a cell range (authoring).
- 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.
- 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. - 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 Rows - Iterator over borrowed
FormulaRangeRowviews. - 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.
- Page
Setup - Print / page setup for a worksheet (authoring). All fields optional; an unset field uses Excel’s default.
- Picture
- Workbook-level embedded picture metadata for calamine-style read facades.
- 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
Rows - Iterator over borrowed
RangeRowviews. - 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. - 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; on read a rich string surfaces as its concatenated text. - 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
Kind - Chart kind.
- 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 or decoding a
.xlsworkbook. - 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
Row - Header-row selection policy for serde row deserialization.
- Image
Fmt - Image format for an embedded
Image. - Sheet
Type - Type of sheet in workbook metadata.
- Sheet
Visible - Sheet visibility state.
- Sparkline
Kind - Sparkline kind for an in-cell mini chart.
- 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.
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. - 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.