Skip to content

Getting started with the Spreadsheet Engine

In this guide we’ll install GRID’s spreadsheet engine, load an Excel file, run a formula on the data it contains, and print the answer. This guide assumes you’re using Node.js and npm on a Unix-like system. We used Node.js v22.11.0 and npm v10.9.0 when writing this tutorial.

  1. Create a new directory and initialise an npm project inside it:

    Terminal window
    mkdir spreadsheet-engine-quickstart
    cd spreadsheet-engine-quickstart
    npm init --init-type module -y
  2. Add the spreadsheet engine as a dependency:

    Terminal window
    npm install @grid-is/spreadsheet-engine
  3. Grab a copy of our example spreadsheet. For this demo we’ll use a simple workbook that tracks monthly household expenses, categorises our spending, and lists a budget and actual spend per category. Save a local copy of budget.xlsx alongside the project you just created.

  4. Now to the meat of it. Create an index.js file in your project directory with this content:

    import { Model } from "@grid-is/spreadsheet-engine";
    await Model.preconditions;
    const model = await Model.fromXLSXFile("budget.xlsx");
    const totalSpent = model.runFormula("=SUM(D:D)");
    console.info({ totalSpent });
  5. The engine’s formula evaluator is shipped as a WebAssembly module, so Node needs the --experimental-wasm-modules flag to load it:

    Terminal window
    node --experimental-wasm-modules index.js

    You should see the licence banner followed by the total:

    { totalSpent: 6945 }

See our Tips page for more examples of loading workbooks in the browser, starting from a blank model, reading and writing cells, and exporting .xlsx files.

The API reference covers every class, method, and type the engine exposes. A few useful starting points:

  • Model: load workbooks, run formulas, read and write cells
  • Workbook: work with a single workbook within a model, including saving it back out as .xlsx
  • WorkSheet: interact with an individual sheet
  • Cell: the shape of a cell as returned by readCell and readCells