Guides
Workbook Edits and Batching
Use batch writes and action grouping to reduce recalculation churn and keep undo/redo behavior predictable.
Formualizer supports both single-cell edits and grouped updates. Use the grouped path whenever you are importing or editing many cells at once.
Choose the right edit path
- Single edit:
set_value/set_formula(simple and direct). - Rectangular batch write:
set_values,set_formulas, orwrite_range(Rust);set_values_batch/set_formulas_batch(Python);setValues/setFormulas(JS sheet facade). - Atomic multi-step edit:
Workbook::action(...)in Rust rolls back all changes if one step fails. - Undo/redo grouping:
begin_action(...)+end_action(...)groups many writes into one user-visible action.
Batch write, then evaluate
Seed a pricing block and evaluate
use formualizer_common::LiteralValue;use formualizer_workbook::Workbook;let mut wb = Workbook::new();wb.add_sheet("S")?;wb.set_changelog_enabled(true);wb.action("seed pricing block", |tx| { tx.set_value("S", 1, 1, LiteralValue::Number(100.0))?; tx.set_value("S", 2, 1, LiteralValue::Number(0.1))?; tx.set_formula("S", 1, 2, "=A1*(1-A2)")?; Ok(())})?;let out = wb.evaluate_cells(&[("S", 1, 2)])?;assert_eq!(out[0], LiteralValue::Number(90.0));Practical notes
- Batch helpers reduce repeated graph/editor churn compared with many per-cell calls.
- In Python/JS bindings, batch helpers internally wrap writes in an action for cleaner undo history.
- After staging formulas, run
evaluate_cell,evaluate_cells, orevaluate_allexplicitly where your flow needs computed values. - For large imports, evaluate only target cells first (
evaluate_cells) before full-sheet recomputation.