All examples
advanced

Keep formulas from legacy .xls files

Cross-sheet references, named ranges and array formulas.

Excel 97-2003 files store formulas as binary tokens. TabularJS decodes them back to the text Excel shows, including references to other sheets and workbooks, named ranges and array constants. If a formula cannot be decoded exactly, the cell keeps the value Excel saved.

js
import tabularjs from 'tabularjs';

const result = await tabularjs('./budget-2003.xls');
const [summary] = result.worksheets;

// Formulas come back as text, exactly as Excel shows them
console.log(summary.data[1]);
// ['Total', "=SUM('Jan:Dec'!B2)", '=Rates!B1*B2', '=SUM(Expenses)']

// The same formula, without the "=", in the cell metadata
console.log(summary.cells.C2.formula); // 'Rates!B1*B2'

// Other formulas the decoder understands
// ='[Prices.xls]Sheet1'!A1    reference to another workbook
// =SUM(B2:B4*{1,2,3})        array constants
// =MYFUNCTION(A1)            add-in / user-defined functions

Live Preview

Sample output for a file with employee data.

stdout
{
  "worksheets": [
    {
      "name": "Sheet1",
      "data": [
        ["Name", "Department", "Salary", "Start Date"],
        ["Alice Johnson", "Engineering", 95000, "2021-03-15"],
        ["Bob Smith", "Marketing", 72000, "2022-01-10"],
        ["Carol Williams", "Engineering", 88000, "2020-07-22"],
        ["David Brown", "Design", 68000, "2023-02-08"],
        ["Eve Davis", "Engineering", 102000, "2019-11-30"]
      ]
    }
  ]
}