XLFormula Engine is a Rust crate for parsing and evaluating Excel formulas. It currently works with f32 types.
It supports:
Add the corresponding entry to your Cargo.toml dependency list:
rust
[dependencies]
xlformula_engine = "0.1.0"
and add this to your crate root:
rust
extern crate xlformula_engine;
Here is a simple example of parsing an Excel formula string and evaluating to a result: ```rust extern crate xlformulaengine; use xlformulaengine::calculate; use xlformulaengine::parseformula;
fn main() { let formula = parseformula::parsestringtoformula(&"=1+2"); let result = calculate::calculateformula(formula, None); println!("Result is {}", calculate::resultto_string(result)); } ```
Another example with a formula with references: ```rust extern crate xlformulaengine; use xlformulaengine::calculate; use xlformulaengine::parseformula; use xlformula_engine::types;
fn main() { let datafunction = |s: String| match s.asstr() { "A" => types::Value::Text("=1+B".tostring()), "B" => types::Value::Number(3.0), _ => types::Value::Error(types::Error::Value), }; let formula = parseformula::parsestringtoformula(&"=A+B"); let result = calculate::calculateformula(formula, Some(datafunction)); println!("Result is {}", calculate::resultto_string(result)); } ```
Licensed under MIT License (see the LICENSE file for the full text).
Please feel free to contact us at jirada.herbst@data2impact.com.