1. Products
  2.   Spreadsheet
  3.   JavaScript
  4.   x-spreadsheet
 
  

JavaScript Library to Create Excel & Google Sheets

Open Source JavaScript API allows generating of an Excel & Google Sheets style spreadsheet for the web. It supports inserting new sheets, undo & redo commands, select font family or font size & more.

x-spreadsheet is a very useful web-based JavaScript library for working with spreadsheet documents. It is a pure JavaScript library used to generate an Excel & Google Sheets style spreadsheet for the web with lesser effort and cost. The library is open source and is freely available under the MIT license. The library has included support for importing spreadsheet modules or loading JavaScript files from CDN.

The x-spreadsheet library makes it easy for software developers to load their data in a spreadsheet at runtime or save or validate the data after the change. There are several important features supported by the library related to Excel creation and manipulation such as inserting new sheets, undoing & redo commands, selecting font family or font size, applying or clear formatting (bold, italic, underline, strike), text color or fill color, select borders, merge cells, apply alignment, text wrapping, freeze cell, resize row-height, col-width, copy or cut and Paste, auto-fill, Insert row or column, delete row, column, multiple sheets, printing support, data validations and much more.

Previous Next

Getting Started with x-spreadsheet

The recommended way to install x-spreadsheet is using npm, please use the following script for a smooth installation.

Install x-spreadsheet via npm

$ npm install better-xlsx 

You can download the compiled shared library from GitHub repository and install it.

Excel XLSX Spreadsheet Creation via JavaScript

The open source JavaScript library Better-xlsx helps software developers to generate Microsoft Excel XLSX compatible spreadsheets using JavaScript code. The library supports features likes creating a new workbook from scratch, adding sheets to a worksheet, inserting contents to the sheet, applying formatting to it, inserting new rows or columns, adding text or images, and many more.

Manage Rows and Columns in XLSX Worksheet

The Better-xlsx library has provided useful functionality for managing rows and columns in a worksheet using JavaScript code. The library supports several important functions for handling rows and columns such as adding new rows and columns, set the height of the row, get content in a row or column, applying styles to a column, fill row or column of sheet, set column width, and so on.

Cell Formatting & Management in Excel Workbook

The open source JavaScript library Better-xlsx gives software developers the power to handle cell formatting and its management inside their own JavaScript apps. The library supports applying multiple styles to Excel cells with just a couple of lines of code. It also included several features related to cells such as create new cells, merge cells, hide cells, get the cell style, vertical merging with other cells, get the cell value, set cell formula, set cell values with Number type,s and many more.

How to Appends a Cell Comment via JavaScript API?

var cell = ws["A1"];

/* create comment array if it does not exist */
if(!cell.c) ws.A1.c = [];

/* create a comment part */
var comment_part = {
  a:"SheetJS",
  t:"I'm a little comment, short and stout!"
};

/* Add comment part to the comment array */
cell.c.push(comment_part);

//Modify a single cell value in a Worksheet
XLSX.utils.sheet_add_aoa(worksheet, [[new_value]], { origin: address });

//Modify multiple cell values in a Worksheet
XLSX.utils.sheet_add_aoa(worksheet, aoa, opts);

//Merge a group of cells

if(!worksheet["!merges"]) worksheet["!merges"] = [];
worksheet["!merges"].push(XLSX.utils.decode_range("A1:E1"));

 English