SheetJS CE
SheetJS Community Edition offers battle-tested open-source solutions for extracting useful data from almost any complex spreadsheet and generating new spreadsheets that will work with legacy and modern software alike.
SheetJS Pro offers solutions beyond data processing: Edit complex templates with ease; let out your inner Picasso with styling; make custom sheets with images/graphs/PivotTables; evaluate formula expressions and port calculations to web apps; automate common spreadsheet tasks, and much more!
Simple Examples
The code editors are live -- feel free to edit! Due to technical limitations, they showcase ReactJS patterns. Other parts of the documentation will cover more common use cases including plain JavaScript.
Export an HTML Table to Excel XLSX
How to add to your site (click to show)
1) Make sure your table has an ID:
<table id="TableToExport">
2) Include a reference to the SheetJS Library in your page:
<script src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
3) Add a button that users will click to generate an export
<button id="sheetjsexport"><b>Export as XLSX</b></button>
4) Add an event handler for the click
event to create a workbook and download:
document.getElementById("sheetjsexport").addEventListener('click', function() {
/* Create worksheet from HTML DOM TABLE */
var wb = XLSX.utils.table_to_book(document.getElementById("TableToExport"));
/* Export to file (start a download) */
XLSX.writeFile(wb, "SheetJSTable.xlsx");
});
Live Example (click to hide)
Download and Preview a Numbers workbook
How to add to your site (click to show)
1) Create a container DIV for the table:
<div id="TableContainer"></div>
2) Include a reference to the SheetJS Library in your page:
<script src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
3) Add a script block to download and update the page:
<script>
(async() => {
const f = await fetch(URL_TO_DOWNLOAD); // replace with the URL of the file
const ab = await f.arrayBuffer();
/* Parse file and get first worksheet */
const wb = XLSX.read(ab);
const ws = wb.Sheets[wb.SheetNames[0]];
/* Generate HTML */
var output = document.getElementById("TableContainer");
output.innerHTML = XLSX.utils.sheet_to_html(ws);
})();
</script>