SheetJS XLSX is a robust, battle-tested JavaScript library for parsing and writing spreadsheet data in various formats, including XLSX, XLS, CSV, ODS, and more. The current stable version is 0.18.5, with frequent updates addressing new features and bug fixes. It distinguishes itself with extensive format support, compatibility across Node.js and browsers, and first-class TypeScript definitions. The library focuses on data extraction and generation, offering a 'Community Edition' (this `xlsx` package) for core functionalities, while advanced features like styling, formula evaluation, and custom sheet generation are reserved for the commercial 'SheetJS Pro' offering. It's designed to handle complex spreadsheets and work with both legacy and modern software environments, making it a versatile tool for spreadsheet data manipulation.
npm install xlsxVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to read an existing Excel file, convert its data to JSON, and then create a new Excel file from JSON data using SheetJS in a Node.js environment. It highlights common parsing and writing patterns.
Review the SheetJS Pro documentation if your application requires advanced spreadsheet features beyond basic data manipulation. Features like formula evaluation (`eval_formulae`) require the Pro version.
For extremely large files, consider streaming parsers (if available for your format in Pro) or processing data in chunks if possible. For Node.js, increasing the Node.js memory limit (`--max-old-space-size`) might temporarily alleviate issues, but optimization of data handling is generally preferred.
When calling `sheet_to_json`, use options like `cellDates: true` to get Date objects directly or `raw: true` to get raw numbers and perform custom date conversions. Always verify the output format of dates during development.
For browser applications, use `XLSX.read(data, { type: 'array' })` with `FileReader` results or `XLSX.writeFile(workbook, filename)` with a helper like `FileSaver.js`. Ensure your build setup correctly handles conditional imports or shims for different environments.Ensure you are using `import * as XLSX from 'xlsx';` for ES Modules and `const XLSX = require('xlsx');` for CommonJS. Update your bundler configuration if necessary to correctly resolve the module structure.For browser environments, use `FileReader` to get file data as an ArrayBuffer for `XLSX.read`, and browser-compatible file saving utilities (e.g., `FileSaver.js`) for `XLSX.writeFile`. The `xlsx` core library itself is universal, but I/O needs environment-specific helpers.
Use `import * as XLSX from 'xlsx';` for ES Modules or `const XLSX = require('xlsx');` for CommonJS to ensure the `XLSX` variable correctly holds the module's exports.Pass `{ cellDates: true }` as an option to `XLSX.utils.sheet_to_json` (or similar utility) to instruct the library to attempt conversion of serial numbers into JavaScript `Date` objects.Increase Node.js's memory limit via `node --max-old-space-size=4096 script.js` (for 4GB). In browsers, consider optimizing the input file size, splitting processing, or looking into streaming solutions if offered by SheetJS Pro.
No dependency data recorded yet.