Skip to main content

excel_rs/
lib.rs

1//! A fast, low-allocation library for writing XLSX (Excel Open XML) files.
2//!
3//! `excel-rs-xlsx` streams cell data directly into a ZIP-compressed XLSX
4//! archive, flushing to the underlying writer in batches.  It never
5//! materialises the full file in memory, which makes it suitable for large
6//! datasets.
7//!
8//! # Quick start
9//!
10//! ```no_run
11//! use std::fs::File;
12//! use excel_rs::{WorkBook, sheet::CellType};
13//!
14//! let file = File::create("output.xlsx").unwrap();
15//! let mut wb = WorkBook::new(file);
16//!
17//! let mut sheet = wb.new_worksheet("Sales".to_string()).unwrap();
18//! sheet.write_row([b"Name".as_ref(), b"Revenue"].into_iter(), None).unwrap();
19//! sheet.write_row([b"Alice".as_ref(), b"42000"].into_iter(), Some(&[CellType::String, CellType::Number])).unwrap();
20//! sheet.close().unwrap();
21//!
22//! wb.finish().unwrap();
23//! ```
24//!
25//! # Limits
26//!
27//! These match the OOXML / Excel specification:
28//!
29//! | Limit | Value |
30//! |---|---|
31//! | Rows per sheet | 1 048 576 |
32//! | Columns per sheet | 16 384 |
33//! | Sheets per workbook | 65 535 |
34
35pub mod error;
36mod format;
37pub mod sheet;
38pub mod workbook;
39
40pub use error::{ExcelError, Result};
41pub use workbook::WorkBook;
42
43/// Maximum number of rows per worksheet (Excel limit).
44pub const MAX_ROWS: u32 = 1048576; // 2^20
45
46/// Maximum number of columns per worksheet (Excel limit).
47pub const MAX_COLS: usize = 16384; // 2^14
48
49/// Maximum number of worksheets per workbook (Excel limit).
50pub const MAX_SHEETS: usize = u16::MAX as usize; // 2^16