Skip to content

nandium/expy

Repository files navigation

Expy

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).

License: MIT

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

Overview

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.

Features

  • LALR(1) parser for Excel formula syntax
  • Runs client-side in the browser (no server required)

Supported Excel Functions

WIP

Installation

Pre-built Binaries

Download the latest release from the Releases page.

From Source

See the Development section below.

Usage

Browser

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>

As a Rust Library

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);
}

Development

Requirements

  • 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.

Building

Clone the repository:

git clone https://github.com/nandium/expy.git
cd expy

The 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 --locked

Build the WebAssembly package:

wasm-pack build --target web --release

Serve locally and open http://localhost:8080 in your browser:

python3 -m http.server 8080

Testing

Run native Rust tests:

cargo test

Run WebAssembly tests in a headless browser:

wasm-pack test --headless --firefox

Or using Node.js:

wasm-pack test --node

Build Targets

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)

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published