An Excel formula to Python code transpiler, written in Rust and compiled to WebAssembly for client-side browser execution. We have integrated this into our interactive webpage (WIP).
Note: This project is currently under active development. The API and feature set may change.
It is currently not in a working state, but is actively being developed. Subscribe to see updates
Expy parses Microsoft Excel formulas and transpiles them into equivalent Python code. It runs entirely in the browser via WebAssembly, and powers our web demo.
- LALR(1) parser for Excel formula syntax
- Runs client-side in the browser (no server required)
WIP
Download the latest release from the Releases page.
See the Development section below.
Include the generated WebAssembly module in your web application:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Expy Demo</title>
</head>
<body>
<script type="module">
import init, { transpile } from './pkg/expy.js';
async function run() {
await init();
const python = transpile("=SUM(A1:A10) + IF(B1 > 0, C1, D1)");
console.log(python);
}
run();
</script>
</body>
</html>Add Expy to your Cargo.toml:
[dependencies]
expy = { git = "https://github.com/nandium/expy" }use expy::transpile;
fn main() {
let excel_formula = "=SUM(A1:A10)";
let python_code = transpile(excel_formula).unwrap();
println!("{}", python_code);
}- Rust (stable toolchain)
- wasm-pack for WebAssembly builds
- Node.js (optional, for running WASM tests)
- Python 3 (optional, for local development server)
The required Rust components and targets are specified in rust-toolchain.toml and will be installed automatically when you run any Cargo command.
Clone the repository:
git clone https://github.com/nandium/expy.git
cd expyThe Rust toolchain will be installed automatically via rust-toolchain.toml when you run any cargo command.
Install wasm-pack=0.13.1 (if not already installed):
cargo install wasm-pack --version 0.13.1 --lockedBuild the WebAssembly package:
wasm-pack build --target web --releaseServe locally and open http://localhost:8080 in your browser:
python3 -m http.server 8080Run native Rust tests:
cargo testRun WebAssembly tests in a headless browser:
wasm-pack test --headless --firefoxOr using Node.js:
wasm-pack test --node| Target | Command | Output | Use Case |
|---|---|---|---|
web |
wasm-pack build --target web |
pkg/ |
Native ES modules |
bundler |
wasm-pack build --target bundler |
pkg/ |
Webpack, Rollup, Parcel |
nodejs |
wasm-pack build --target nodejs |
pkg/ |
Node.js (CommonJS) |
This project is licensed under the MIT License. See the LICENSE file for details.