# SheetJS — Read and Write Spreadsheets from JavaScript > A comprehensive JavaScript library for parsing and writing Excel, CSV, and other spreadsheet formats in the browser and Node.js. ## Install Save as a script file and run: # SheetJS — Read and Write Spreadsheets from JavaScript ## Quick Use ```bash npm install xlsx ``` ```js const XLSX = require('xlsx'); const workbook = XLSX.readFile('data.xlsx'); const sheet = workbook.Sheets[workbook.SheetNames[0]]; const json = XLSX.utils.sheet_to_json(sheet); console.log(json); ``` ## Introduction SheetJS (also published as the `xlsx` npm package) provides a pure-JavaScript engine for reading, editing, and writing spreadsheet data. It handles dozens of file formats—XLS, XLSX, CSV, ODS, and more—without native dependencies, making it suitable for both server-side Node.js scripts and in-browser applications. ## What SheetJS Does - Parses Excel files (XLS, XLSX, XLSB) into a uniform workbook object model - Writes workbooks back to XLSX, CSV, HTML, JSON, and other output formats - Runs in the browser with no server round-trips, enabling client-side export - Converts between row-major arrays, JSON arrays, and HTML tables - Handles multi-sheet workbooks, merged cells, number formats, and date parsing ## Architecture Overview SheetJS exposes a workbook/sheet data model. File bytes are fed to a format-specific parser that produces a workbook object containing named sheets. Each sheet is a sparse two-dimensional map of cell objects keyed by A1-style references. Utility functions convert between this internal representation and developer-friendly structures like arrays of objects. Writers serialize the workbook back into the target binary or text format. ## Setup & Configuration - Install from npm: `npm install xlsx` or load via CDN for browser use - Import with `require('xlsx')` (CJS) or `import * as XLSX from 'xlsx'` (ESM) - No native add-ons or external binaries required - Use the streaming API (`XLSX.stream`) for large files that exceed memory limits - Configure date handling with `cellDates: true` in the parsing options ## Key Features - Supports 20+ spreadsheet formats including legacy XLS and modern XLSB - Zero native dependencies—runs identically in Node.js, Deno, and browsers - Streaming reader and writer for processing large files efficiently - Rich cell metadata including types, styles, formulas, and comments - Active maintenance with frequent releases since 2012 ## Comparison with Similar Tools - **ExcelJS** — provides deeper style and image support but only handles XLSX; SheetJS covers far more formats - **Papa Parse** — CSV-only parser; SheetJS handles CSV plus binary Excel and ODS - **openpyxl (Python)** — Python equivalent for XLSX; SheetJS brings the same capability to JavaScript - **Tabulator** — focuses on UI table rendering; SheetJS focuses on file I/O ## FAQ **Q: Can SheetJS run in the browser without a server?** A: Yes. It parses files entirely in the browser using the File API or drag-and-drop input. **Q: Does SheetJS support writing styled XLSX files?** A: The community edition handles data and basic number formats. The Pro edition adds full styling, images, and pivot tables. **Q: How does SheetJS handle large files?** A: Use the streaming API to process rows incrementally rather than loading the entire workbook into memory. **Q: Is SheetJS free and open source?** A: The core library is released under the Apache-2.0 license. An optional Pro tier adds advanced features. ## Sources - https://github.com/SheetJS/sheetjs - https://docs.sheetjs.com/ --- Source: https://tokrepo.com/en/workflows/asset-2c6f3366 Author: Script Depot