Apache POI

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.

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>

Install vis NPM

  $ npm install xlsx  

Install via Bower

 $ bower install js-xlsx  

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.

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.