Expand description
Spreadsheet engine API.
This module provides the core computation engine for the spreadsheet:
Cell,CellType,Grid- Data structures for cell storageCellRef- Cell reference parsing (A1 notation ↔ row/col indices)detect_cycle- Circular dependency detectionextract_dependencies- Parse formula dependenciespreprocess_script- Transform formulas for Rhai evaluationcreate_engine- Create a Rhai engine with built-in functionsformat_dynamic- Format values for display
Structs§
- AST
- Compiled AST (abstract syntax tree) of a Rhai script.
- Cell
- A cell in the spreadsheet grid.
- CellRef
- A reference to a cell by row and column indices (0-indexed).
- Dynamic
- Dynamic type containing any value.
Enums§
- Cell
Type - The type of content stored in a cell.
- Shift
Operation - Operation for shifting cell references in formulas.
Functions§
- create_
engine - Create a Rhai engine with built-ins registered.
- create_
engine_ with_ functions - Create a Rhai engine with built-ins registered. Optionally compiles custom functions from the provided script. Returns the engine, compiled AST (if any), and any error message.
- create_
engine_ with_ functions_ and_ spill - Create a Rhai engine with built-ins, custom functions, and shared maps. Returns the engine, compiled AST (if any), and any error message.
- create_
engine_ with_ spill - Create a Rhai engine with built-ins registered and shared maps.
- detect_
cycle - Detect circular dependencies starting from a cell. Returns Some(cycle_path) if a cycle is found, None otherwise.
- eval_
with_ functions - Evaluate a formula, optionally with custom functions AST.
- extract_
dependencies - Extract all cell references from a script as dependencies.
- format_
dynamic - Format a Dynamic value for display.
- format_
number - Format a number for display.
- parse_
range - Parse a cell range like “A1:B5” and return (start_row, start_col, end_row, end_col).
- preprocess_
script - Replace cell references like “A1” with Rhai function calls like “cell(0, 0)”. Typed refs like “@A1” become “value(0, 0)” (returns Dynamic). Also transforms range functions like SUM(A1:B5, …) into sum_range(0, 0, 4, 1, …).
- preprocess_
script_ with_ context - Preprocess script with optional current cell context for ROW()/COL(). When context is provided, ROW() and COL() are replaced with 1-based row/col values.
- shift_
formula_ references - Shift cell references in a formula when rows/cols are inserted/deleted. Returns the updated formula string.
Type Aliases§
- Computed
Map - Thread-safe storage for computed formula cell values. Maps cell positions to their evaluated Dynamic values. This allows cell references to use pre-computed values instead of re-evaluating.
- Grid
- Thread-safe sparse grid storage.
- Spill
Map - Thread-safe storage for spill cell values. Maps cell positions to their computed Dynamic values.