Formualizer Docs
SheetPort

SheetPort Quickstart

End-to-end example of using SheetPort in Rust, Python, and JS/WASM.

This quickstart shows how to use SheetPort to turn a simple loan calculator spreadsheet into a typed function using Rust, Python, and JavaScript/WASM.

1. The Manifest

We'll start with a manifest (manifest.fio.yaml) that defines two scalar inputs (principal and interest rate) and one scalar output (monthly payment).

spec: fio
spec_version: "0.3.0"
manifest:
  id: loan-calculator
  name: Loan Calculator
ports:
  - id: principal
    dir: in
    shape: scalar
    location: { a1: "Calculator!B1" }
    schema: { type: number }
  - id: rate
    dir: in
    shape: scalar
    location: { a1: "Calculator!B2" }
    schema: { type: number }
  - id: monthly_payment
    dir: out
    shape: scalar
    location: { a1: "Calculator!B4" }
    schema: { type: number }

2. Implementation

SheetPort: write inputs → evaluate → read outputs
use formualizer::Workbook;use formualizer::sheetport::{SheetPortSession, EvalOptions, InputUpdate};use formualizer::sheetport_spec::Manifest;use formualizer::common::LiteralValue;fn main() -> Result<(), Box<dyn std::error::Error>> {  let yaml = std::fs::read_to_string("manifest.fio.yaml")?;  let manifest = Manifest::from_yaml_str(&yaml)?;  manifest.validate()?;  let wb = Workbook::from_path("model.xlsx")?;  let mut session = SheetPortSession::new(wb, manifest)?;  // Write inputs  let mut update = InputUpdate::default();  update.set_scalar("principal", LiteralValue::Number(250000.0));  update.set_scalar("rate", LiteralValue::Number(0.065));  session.write_inputs(update)?;  // Evaluate and read outputs  let outputs = session.evaluate_once(EvalOptions::default())?;  println!("Monthly payment: {:?}", outputs.get("monthly_payment"));  Ok(())}

The JS/WASM tab requires a workbook file, so it isn't runnable in-browser here. For self-contained runnable examples, see the JS/WASM Quickstart.

On this page