xsheetjs/demos/xspreadsheet
2022-05-20 04:56:18 -04:00
..
index.html x-spreadsheet demo [ci skip] fixes #2656 2022-04-15 19:06:45 -04:00
README.md estk test [ci skip] 2022-05-20 04:56:18 -04:00
shim.js x-spreadsheet demo 2020-03-22 21:57:53 -04:00
xlsx.full.min.js x-spreadsheet demo 2020-03-22 21:57:53 -04:00
xlsxspread.js x-spreadsheet demo avoid parseFloat [ci skip] 2022-05-18 07:42:59 +02:00

x-spreadsheet

The sheet_to_json utility function generates output arrays suitable for use with other JS libraries such as data grids for previewing data. With a familiar UI, x-spreadsheet is an excellent choice for developers looking for a modern editor.

This demo is available at https://oss.sheetjs.com/sheetjs/x-spreadsheet.html

Obtaining the Library

The x-data-spreadsheet NodeJS packages include a minified script that can be directly inserted as a script tag. The unpkg CDN also serves this script:

<script src="https://unpkg.com/x-data-spreadsheet/dist/xspreadsheet.js"></script>

Previewing Data

The HTML document needs a container element:

<div id="gridctr"></div>

Grid initialization is a one-liner:

/* note that the browser build exposes the variable `x` */
var grid = x_spreadsheet(document.getElementById("gridctr"));

The following function converts data from SheetJS to x-spreadsheet:

/* load data */
grid.loadData(stox(workbook_object));

stox is defined in xlsxspread.js

Editing

x-spreadsheet handles the entire edit cycle. No intervention is necessary.

Saving Data

grid.getData() returns an object that can be converted back to a worksheet:

/* build workbook from the grid data */
var new_wb = xtos(xspr.getData());

/* generate download */
XLSX.writeFile(new_wb, "SheetJS.xlsx");

stox is defined in xlsxspread.js

Additional Features

This demo barely scratches the surface. The underlying grid component includes many additional features that work with SheetJS Pro.

Analytics