Framework Guide
JavaScript
Use TabularJS in vanilla JavaScript — no bundler required. Works in any modern browser or Node.js environment with a single function call.
Installation
Install via npm:
bash
npm install tabularjsOr load directly from a CDN — no build step needed:
html
<script src="https://cdn.jsdelivr.net/npm/tabularjs/dist/index.js"></script>Basic Example
Listen for a file input change event and pass the selected file to tabularjs.
upload.jsjs
import tabularjs from 'tabularjs';
const input = document.getElementById('fileInput');
input.addEventListener('change', async (e) => {
const file = e.target.files[0];
if (!file) return;
const result = await tabularjs(file);
const [headers, ...rows] = result.worksheets[0].data;
console.log('Headers:', headers);
console.log('Rows:', rows);
});CDN Example
A self-contained HTML page — drop it into any project without a build tool.
index.htmlhtml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>TabularJS CDN</title>
</head>
<body>
<input type="file" id="fileInput" />
<pre id="output"></pre>
<script src="https://cdn.jsdelivr.net/npm/tabularjs/dist/index.js"></script>
<script>
document.getElementById('fileInput')
.addEventListener('change', async (e) => {
const file = e.target.files[0];
if (!file) return;
const result = await tabularjs(file);
document.getElementById('output').textContent =
JSON.stringify(result, null, 2);
});
</script>
</body>
</html>Node.js
Read a file from disk with fs and parse it server-side.
parse.mjsjs
import { readFile } from 'fs/promises';
import tabularjs from 'tabularjs';
const buffer = await readFile('./data.xlsx');
const result = await tabularjs(new Blob([buffer]));
const [headers, ...rows] = result.worksheets[0].data;
console.log('Headers:', headers);
console.log('Rows:', rows);
