1. Products
  2.   Spreadsheet
  3.   JavaScript
  4.   SheetJS JS-XLSX  



JavaScript Library for Excel Spreadsheets

Open Source JavaScript API to Create, Parse, Lock & Unlock Excel Workbook.

SheetJS JS-XLSX facilitates the JavaScript developers in reading and writing Excel spreadsheets of various file formats. 

It provides the developers with the ability to create a workbook from scratch, parse complex sheets, convert HTML tables, read a specific cell, add a new worksheet and more.

Previous Next

Getting Started with SheetJS

Just add the following script tag in the browser in order to get started with SheetJS

SheetJS Integration

<script lang="javascript" src="/dist/xlsx.full.min.js"></script>

JavaScript API to Create & Modify Spreadsheet Files

SheetJS JS-XLSX allows creating a new workbook from scratch. Once created developers can easily update the workbook properties such as title, subject, author, etc. Developers can also create a worksheet and add it to the empty workbook as well as assign a name to the new sheet and add cell data using several options. 

Create XLSX - JavaScript

var fs = require('fs');
var XLSX = require('xlsx');
var wb = XLSX.utils.book_new();
wb.Props = {
    Title: "FileFomat",
    Subject: "Developer Guide"

wb.SheetNames.push("Test Sheet");
var ws_data = [['hello' , 'world']];
var ws = XLSX.utils.aoa_to_sheet(ws_data);
wb.Sheets["Test Sheet"] = ws;
var wbout = XLSX.write(wb, {bookType:'xlsx', type: 'binary'});

Parse Workbook Data using JavaScript

SheetJS JS-XLSX can parse workbook data from web-based applications. It supports converting multiple tables on a web page to individual worksheets, extracts HTML code from a page, and more.

Parse Workbook & Fetch Data using JavaScript API

 * Get the car data reduced to just the variables we are interested
 * and cleaned of missing data.
async function getData() {
  /* fetch file */
  const carsDataResponse = await fetch('https://sheetjs.com/data/cd.xls');
  /* get file data (ArrayBuffer) */
  const carsDataAB = await carsDataResponse.arrayBuffer();
  /* parse */
  const carsDataWB = XLSX.read(carsDataAB);
  /* get first worksheet */
  const carsDataWS = carsDataWB.Sheets[carsDataWB.SheetNames[0]];
  /* generate array of JS objects */
  const carsData = XLSX.utils.sheet_to_json(carsDataWS);
  const cleaned = carsData.map(car => ({
    mpg: car.Miles_per_Gallon,
    horsepower: car.Horsepower,
  .filter(car => (car.mpg != null && car.horsepower != null));

  return cleaned;

Lock and Unlock Workbook Cells in JavaScript Apps

Sometimes, it is required to lock up a certain set of cells in a spreadsheet to protect spreadsheets from unintended changes. SheetJS JS-XLSX gives the developer the ability to lock and unlock Workbook cells. It is useful to protect certain cells, as you can let the users make changes to most of the spreadsheet when required.