
formualizer-workbook
Ergonomic workbook API with sheets, evaluation, undo/redo, and file I/O.
formualizer-workbook is the recommended high-level interface for Formualizer. It wraps the calculation engine with workbook-friendly APIs for managing sheets, editing cells, evaluating formulas, tracking changes, and importing/exporting files.
When to use this crate
Use formualizer-workbook for most integrations:
- Set cell values and formulas, evaluate cells and ranges
- Load and save XLSX, CSV, and JSON workbooks
- Undo/redo with automatic action grouping
- Batch operations with transactional semantics
- This is the API that the Python and WASM bindings expose
Use formualizer-eval instead if you need direct engine access with custom resolvers.
Quick start
use LiteralValue;
use Workbook;
let mut wb = new;
wb.add_sheet?;
wb.set_value?;
wb.set_value?;
wb.set_formula?;
let result = wb.evaluate_cell?;
assert_eq!;
Workbook-local custom functions
You can register callbacks directly on a Workbook:
register_custom_function(name, options, handler)unregister_custom_function(name)list_custom_functions()
Semantics:
- Names are case-insensitive and canonicalized to uppercase.
- Workbook-local custom functions resolve before global built-ins.
- Overriding a built-in is blocked unless
CustomFnOptions { allow_override_builtin: true, .. }is set. - Args are by value (
LiteralValue); range args are materialized asLiteralValue::Array. - Returning
LiteralValue::Arrayspills like dynamic-array formulas. - Handler errors propagate as
ExcelErrorvalues.
Runnable example:
WASM plugin support (native Rust, workbook-local):
- Effect-free inspect APIs:
inspect_wasm_module_bytes(...)inspect_wasm_module_file(...)(native only)inspect_wasm_modules_dir(...)(native only)
- Explicit workbook-local attach APIs:
attach_wasm_module_bytes(...)attach_wasm_module_file(...)(native only)attach_wasm_modules_dir(...)(native only)
- Bind formula names explicitly:
bind_wasm_function(name, options, spec)
Runtime notes:
- With
wasm_pluginsonly, default runtime remains pending and bind returnsExcelErrorKind::NImpl. - With
wasm_runtime_wasmtimeon native targets, you can calluse_wasmtime_runtime()and execute compatible exports.
Runnable plugin examples:
Features
- Mutable workbook model — add sheets, edit cells, and track staged formula changes without rebuilding the entire dependency graph.
- 320+ Excel functions — all built-ins from
formualizer-evalare available through the workbook surface. - Changelog + undo/redo — opt into change logging with automatic action grouping. Single edits are individually undoable; batch operations group as one step.
- I/O backends — pluggable readers/writers behind feature flags:
calamine— XLSX/ODS readingumya— XLSX reading/writing with round-trip supportjson— structured JSON serializationcsv— CSV/TSV import/export
- Batch transactions — atomic multi-cell operations with rollback.
- Evaluation planning — inspect the dependency schedule before computing.
License
Dual-licensed under MIT or Apache-2.0, at your option.