An Excel/OpenDocument Spreadsheets file reader/deserializer, in pure Rust.
calamine is a pure Rust library to read and deserialize any spreadsheet file:
- excel like (
- opendocument spreadsheets (
As long as your files are simple enough, this library should just work. For anything else, please file an issue with a failing test or send a pull request!
It is as simple as:
Note if you want to deserialize a column that may have invalid types (i.e. a float where some values may be strings), you can use Serde's
deserialize_with field attribute:
// Convert value cell to Some(f64) if float or int, else None
let mut excel: = open_workbook.unwrap;
if let Some = excel.worksheet_range
Reader: More complex
- the file type (xls, xlsx ...) cannot be known at static time
- we need to get all data from the workbook
- we need to parse the vba
- we need to see the defined names
- and the formula!
// opens a new workbook
let path = ...; // we do not know the file type
let mut workbook = open_workbook_auto.expect;
// Read whole worksheet data and provide some statistics
if let Some = workbook.worksheet_range
// Check if the workbook has a vba project
if let Some = workbook.vba_project
// You can also get defined names definition (string representation only)
for name in workbook.defined_names
// Now get all formula!
let sheets = workbook.sheet_names.to_owned;
for s in sheets
dates: Add date related fn to
picture: Extract picture data.
Browse the examples directory.
While there is no official benchmark yet, my first tests show a significant boost compared to official C# libraries:
- Reading cell values: at least 3 times faster
- Reading vba code: calamine does not read all sheets when opening your workbook, this is not fair
Many (most) part of the specifications are not implemented, the focus has been put on reading cell values and vba code.
The main unsupported items are:
- no support for writing excel files, this is a read-only library
- no support for reading extra contents, such as formatting, excel parameter, encrypted components etc ...
- no support for reading VB for opendocuments
Thanks to xlsx-js developers! This library is by far the simplest open source implementation I could find and helps making sense out of official documentation.
Thanks also to all the contributors!