Skip to main content

Crate truecalc_core

Crate truecalc_core 

Source
Expand description

Spreadsheet formula parser and evaluator for Google Sheets and Excel conformance.

§Quick start

use std::collections::HashMap;
use truecalc_core::{Engine, Value};

let engine = Engine::sheets();

let mut vars = HashMap::new();
vars.insert("A1".to_string(), Value::Number(10.0));
vars.insert("A2".to_string(), Value::Number(20.0));
vars.insert("A3".to_string(), Value::Number(30.0));

let result = engine.evaluate("=SUM(A1,A2,A3)", &vars);
assert_eq!(result, Value::Number(60.0));

§Engine flavors

The engine flavor is required and immutable: create one engine per evaluation context and reuse it.

ConstructorTarget conformance
Engine::sheets()Google Sheets
Engine::excel()Excel (parse/validate only; evaluation pending)

§Evaluation modes

§Migration from 0.6.x

The free evaluate() function and Engine::google_sheets() constructor were deprecated in 0.7.0. Update call sites as follows:

// Before (0.6.x):
// use truecalc_core::evaluate;
// let result = evaluate("=SUM(A1,A2)", &vars);

// After (0.7+):
use std::collections::HashMap;
use truecalc_core::{Engine, Value};
let vars: HashMap<String, Value> = HashMap::new();
let result = Engine::sheets().evaluate("=SUM(A1,A2)", &vars);

See MIGRATION.md for the full migration guide.

  • truecalc-workbook: full workbook layer — engine-locked workbook, worksheet, cell mutation, and recalc.

Re-exports§

pub use display::display_number;
pub use engine::Engine;
pub use engine::EngineFlavor;
pub use parser::parse;Deprecated
pub use parser::validate;Deprecated
pub use parser::Expr;
pub use parser::CellAddr;
pub use parser::Ref;
pub use types::ErrorKind;
pub use types::ParseError;
pub use types::Value;
pub use eval::functions::FunctionMeta;
pub use eval::functions::Registry;
pub use eval::extract_refs;
pub use eval::Resolver;

Modules§

display
engine
eval
parser
types

Functions§

evaluateDeprecated
Evaluate a formula string with named variables, targeting Google Sheets conformance.