ganit-core
Spreadsheet formula engine — parser and evaluator for Excel-compatible formulas.
Also available as a WebAssembly npm package: @tryganit/core
Install
[]
= "0.1"
Or via cargo:
Usage
Evaluate a formula
use HashMap;
use ;
let mut vars = new;
vars.insert;
vars.insert;
let result = evaluate;
assert_eq!;
Pattern match on the result
use HashMap;
use ;
let mut vars = new;
vars.insert;
match evaluate
Validate without evaluating
use validate;
match validate
Parse to an AST
use parse;
let expr = parse.expect;
// expr is an Expr tree you can walk yourself
Types
Value
| Variant | Description |
|---|---|
Number(f64) |
Finite numeric value (never NaN or infinity) |
Text(String) |
String value |
Bool(bool) |
Boolean value |
Error(ErrorKind) |
Formula error (e.g. #DIV/0!) |
Empty |
Missing/blank cell reference |
Array(Vec<Value>) |
Array of values |
ErrorKind
| Variant | Excel error |
|---|---|
DivByZero |
#DIV/0! |
Value |
#VALUE! |
Ref |
#REF! |
Name |
#NAME? |
Num |
#NUM! |
NA |
#N/A |
Null |
#NULL! |
Available functions
Covers math, logical, text, financial, and statistical categories. For the full list with signatures and descriptions, query the live registry:
use Registry;
let registry = new;
for in registry.list_functions
License
MIT