Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omid/formula
A parser and evaluator of spreadsheet-like formulas
https://github.com/omid/formula
excel formula formulas google-sheets googlesheets libreoffice libreoffice-calc microsoft-excel ms-excel office365 rust sheets spreadsheet
Last synced: 4 months ago
JSON representation
A parser and evaluator of spreadsheet-like formulas
- Host: GitHub
- URL: https://github.com/omid/formula
- Owner: omid
- License: mit
- Created: 2022-08-22T11:41:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-11T11:27:18.000Z (about 2 years ago)
- Last Synced: 2024-04-23T17:51:54.303Z (9 months ago)
- Topics: excel, formula, formulas, google-sheets, googlesheets, libreoffice, libreoffice-calc, microsoft-excel, ms-excel, office365, rust, sheets, spreadsheet
- Language: Rust
- Homepage:
- Size: 62.5 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Crates.io](https://img.shields.io/crates/v/formula.svg?style=flat)](https://crates.io/crates/formula)
[![npm](https://img.shields.io/npm/v/formula-wasm.svg?style=flat)](https://npmjs.com/package/formula-wasm)
[![Workflow Status](https://github.com/omid/formula/workflows/ci/badge.svg)](https://github.com/omid/formula/actions?query=workflow%3A%22ci%22)Formula
A parser and evaluator of spreadsheet-like formulasFormula is in its early stages and is not ready for production use.
So far we have the following features:
- 18 date time functions
- 26 text functions
- 26 math functions
- 7 logical functions
- 2 web functions
- plus all arithmetic and comparison operators#### Installation and usage
##### Rust
Add this library to your project with `cargo add formula` or add `formula = "*"` to your `Cargo.toml` file.
Use it similar to the following code:
```rust
use formula::{Formula, Expr, Result};fn main() -> Result<()> {
let formula = Formula::new("=UPPER(TRIM(' Hello '))")?;
let value = formula.parse()?;
assert_eq!(value, Expr::String("HELLO".to_string()));
Ok(())
}
```##### JavaScript
Add this library to your project with `npm install formula-wasm` or add `formula-wasm` to your `package.json` file.
Use it similar to the following code:
```js
import { parse } from 'formula-wasm';const value = parse('=UPPER(TRIM(" Hello "))');
console.assert(value, "HELLO");
```#### What we do not support, yet:
- We don't support all existing functions in the world, but we would like to add more of them, like Excel functions, Google Sheets functions, and so on
- At the moment, we don't support table data. It means you need to extract table data and pass theirs values to this library
- We do not support simple formulas like `1+1` or as argument like `AND(1>3, 1<3)` or `SUM(2-1, 2)`. Instead, you can use our `F.` functions like `AND(F.GT(1, 3), F.LT(1, 3))` or `SUM(F.SUB(2, 1), 2)`
- We still do not support parentheses to change the order of operations, but you can use our `F.` functions. So for example instead of `2*(1+1)`, you should use `F.MUL(2, F.ADD(1, 1))`#### Contributing
We would love to have your contribution! Please read our [contributing guidelines](CONTRIBUTING.md) to get started.
#### Inspired by
- [formulajs](https://github.com/formulajs/formulajs)
- [hyperformula](https://github.com/handsontable/hyperformula)#### License
This project is licensed under the MIT license. See the [LICENSE](LICENSE.md) file for more info.