Cellular is a JavaScript spreadsheet engine. It includes a formula parser.
const sheet = new Sheet();
sheet.getCell('A1').text = 1;
sheet.getCell('A2').text = 2;
sheet.getCell('A3').text = 3;
sheet.getCell('B1').text = '=A1 + A2 * A3';
sheet.calculate();
sheet.getCell('B1').value;
// 7
Try it now on RunKit
A REPL is included. It creates a sheet when you run it.
yarn repl
Run sheet.calculate()
after entering values. The ouput from the current line as well as the current sheet is printed.
sheet.getCell('A1').text = 1;
sheet.getCell('A2').text = 2;
sheet.getCell('A3').text = 3;
sheet.getCell('B1').text = '=A1 + A2 * A3';
sheet.calculate();
Find the UMD package at ./dist/cellular.js
. This is included with the NPM package.
You can import this where you need it.
npm install cellularjs
var cellular = require('./dist/cellular');
var sheet = new cellular.Sheet();
sheet.getCell('A1').text = 11;
sheet.getCell('A2').text = 22;
sheet.getCell('A3').text = '=A1 + A2';
// Be sure to run calculate() after setting cell values
sheet.calculate();
// Then, print the output
sheet.toString();
// A1: 11 => 11
// A2: 22 => 22
// A3: =A1 + A2 => 33