All formats

XLSX to JSONExcel 2007+ (XLSX)

The modern Excel workbook format.

OOXML-based spreadsheet format introduced with Microsoft Office 2007. TabularJS parses XLSX files with its own parser in the browser and Node.js: no SheetJS, no xlsx dependency.

An .xlsx file is a ZIP archive of XML parts: one part per worksheet, a shared string table, a style sheet and the workbook definition. TabularJS opens the archive, reads those parts and returns one plain JavaScript object with every worksheet in it, ready to save as JSON, send to an API or load into a grid.

The same function runs in Node.js and in the browser. In Node.js, pass a file path or a Buffer. In the browser, pass the File from an <input type="file"> or a drop event, or a Blob from fetch(). The output keeps the sheet layout: data[row][col] mirrors the grid, so data[0][0] is cell A1.

Feature support

Data values
Formulas
Styles
Merged cells
Comments
Column metadata

What TabularJS extracts from XLSX files

Convert XLSX to JSON in Node.js

js
import tabularjs from 'tabularjs';

const result = await tabularjs('orders.xlsx');

for (const sheet of result.worksheets) {
  console.log(sheet.worksheetName, sheet.data.length, 'rows');
}

const orders = result.worksheets[0];
console.log(orders.data[1]);                 // [ 'Apple', 3, 0.5, '=B2*C2', 46296 ]
console.log(orders.mergeCells);              // { A6: [ 2, 1 ] }
console.log(result.style[orders.style.A1]);  // 'font-weight: bold; background-color: #FFFF00'

Read XLSX files in the browser

js
import tabularjs from 'tabularjs';

const input = document.querySelector('input[type=file]');

input.addEventListener('change', async () => {
  const result = await tabularjs(input.files[0]);
  const sheet = result.worksheets[0];

  // First row as keys, the other rows as objects
  const [header, ...rows] = sheet.data;
  const records = rows.map((row) => Object.fromEntries(header.map((key, i) => [key, row[i]])));
  console.log(JSON.stringify(records, null, 2));
});

JSON output

json
{
  "worksheets": [
    {
      "worksheetName": "Orders",
      "data": [
        ["Product", "Qty", "Price", "Total", "Shipped"],
        ["Apple", 3, 0.5, "=B2*C2", 46296],
        ["Pear", 2, 0.75, "=B3*C3", ""],
        ["Total", "", "", "=SUM(D2:D3)", ""]
      ],
      "columns": [{ "width": 100, "title": "A", "type": "text" }],
      "rows": { "0": { "height": 21 } },
      "cells": { "E2": { "format": "yyyy-mm-dd" } },
      "style": { "A1": 0, "E2": 1 },
      "mergeCells": { "A6": [2, 1] },
      "comments": { "A2": "Fresh stock" }
    },
    { "worksheetName": "Notes", "data": [["hello"]] }
  ],
  "style": ["font-weight: bold; background-color: #FFFF00", "font-family: Calibri; font-size: 11pt"],
  "definedNames": { "Prices": "Orders!$C$2:$C$3" }
}

Output for a small two-sheet workbook, trimmed: only the first column definition and row height are shown and the second sheet is cut. The property names and values are the real ones.

Limitations

Frequently asked questions

Do I need SheetJS or the xlsx package to read .xlsx files?

No. TabularJS has its own XLSX parser. Its runtime dependencies are JSZip, which opens the ZIP archive, and a small markup parser (@lemonadejs/html-to-json) for the XML parts.

How do I convert the rows to an array of JSON objects?

TabularJS returns rows as arrays so the grid layout is kept. Use the first row as keys: const [header, ...rows] = sheet.data; then rows.map(r => Object.fromEntries(header.map((h, i) => [h, r[i]]))).

Can I get the calculated result of a formula?

Not from the parser. TabularJS returns the formula text, such as =SUM(D2:D3), and never evaluates it. If you need the values, load the result into a spreadsheet component that calculates formulas, such as Jspreadsheet.

How do I read one specific sheet?

There is no sheet option: every sheet is returned. Pick the one you need by name with result.worksheets.find(w => w.worksheetName === 'Orders'). Hidden sheets are in the list too, marked with worksheetState.

Does it read .xlsm files?

Yes, the cell data. A .xlsm file has the same structure as .xlsx, and because the extension is not on the list TabularJS detects the format from the content. You can also pass { extension: 'xlsx' }. VBA macros are not read.

Why TabularJS for Excel 2007+ (XLSX)?