Excelerate
Read, write and recalculate spreadsheets in pure Rust.
Opens .xlsx, .xlsb, .xls, .ods, .csv, .html, .slk, .gnumeric
and SpreadsheetML 2003, hands you the workbook as a plain Rust struct, evaluates
formulas (518 Excel functions and counting) and writes the whole thing back.
No Excel, no LibreOffice, no COM, no headless anything - just the crate.
[]
= "0.11"
use reader;
let book = read?;
let sheet = book.active_sheet.unwrap;
println!;
# Ok::
Why you might want it
- The format is sniffed, not guessed from the extension.
reader::readlooks at the bytes first, so a.txtthat is secretly a zip package still opens as xlsx. The extension only gets a vote when the bytes stay quiet. - Formulas actually run. Recalculate the whole book, one sheet, or just what an edit touched - the incremental path is roughly 20x cheaper on a book with 20k formulas.
- Round-trips without eating your file. Read -> write -> read keeps styles, merges, conditional formatting, protection, autofilters and print setup. Charts, pictures, shapes and comments are modelled and written back; anything the crate does not model yet rides through byte for byte along with its relationships.
- Builds for WebAssembly, so the same reader runs in Node.
- No
unsafe,clippy::pedanticclean, and the deps arezip,quick-xml,flate2,thiserror,regexfor theREGEX*functions, andsha1/sha2/getrandomfor password hashes - all butregexalready come withzip.
Sixty-second tour
use CellRef;
use recalculate;
use Options;
use ;
use write_xlsx;
let mut book = empty;
let mut sheet = new?;
sheet.set;
sheet.set;
sheet.set;
sheet.set;
sheet.set;
sheet.set;
book.add_sheet?;
recalculate; // B3 is now 360
write_xlsx?;
# Ok::
Converting between formats is a two-liner - the output format comes from the extension you ask for:
use ;
let book = read?;
write_ods?;
write_csv?;
# Ok::
Formats
| Format | Read | Write |
|---|---|---|
| xlsx (OOXML) | ✅ | ✅ |
| xls (BIFF8) | ✅ | ✅ |
| xls (BIFF5, Excel 5 and 95) | ✅ | — |
| xlsb (BIFF12) | ✅ | — |
| ods (OpenDocument) | ✅ | ✅ |
| CSV | ✅ | ✅ |
| HTML | ✅ | ✅ |
SYLK (.slk) |
✅ | — |
| Gnumeric | ✅ | — |
SpreadsheetML 2003 (.xml) |
✅ | — |
Every format has its own sharp edges; they are all written down in docs/formats.md rather than left for you to find at 3am.
Docs
| Page | What's in it |
|---|---|
| Getting started | install, read a file, write one, the whole loop |
| Recipes | short answers: read a value, convert a file, recalculate one cell |
| Workbook model | workbook, sheet, cell, addresses and ranges |
| Editing the grid | inserting and removing rows, columns and sheets, and what moves with them |
| Sheet features | merges, comments, tables, protection, filters, validation, print setup |
| File formats | what each format carries and what it drops |
| Formulas | evaluation, incremental recalc, driving the engine yourself |
| Styles and number formats | fonts, fills, borders, format strings |
| Long operations | progress, custom functions, what each step costs |
| Links to other workbooks | [1]Sheet1!A1, the value cache, plugging in a live file |
| WebAssembly | building for Node and reading a book from JS |
Building
cargo test
cargo clippy --all-targets -- -D warnings
Status
Formats, styles, the formula engine and the xlsx object model (protection, autofilters, validation, conditional formatting, print setup, tables, charts, pictures, shapes, comments, pivot tables) are in. xls keeps formulas and styles both ways. See docs/formats.md for the exact line between "modelled" and "carried".
License
MIT - see LICENSE.