This section lists the functions defined in the library.
The "SheetJS Data Model" section covers spreadsheet features.
The API functions primarily focus on conversions between data representations.
Using the "Standalone" scripts,
XLSX is added to the
window or other
Using the "NodeJS" module, the
XLSX variable refers to the CommonJS export:
var XLSX = require("xlsx");
Using a framework, the
variable refers to the glob import:
import * as XLSX from "xlsx";
XLSX.read(data, read_opts) attempts to parse
XLSX.readFile(filename, read_opts) attempts to read
filename and parse.
Parse options are described in the Parsing Options section.
XLSX.write(wb, write_opts) attempts to write the workbook
XLSX.writeXLSX(wb, write_opts) attempts to write the workbook in XLSX format.
XLSX.writeFile(wb, filename, write_opts) attempts to write
In browser-based environments, it will attempt to force a client-side download.
XLSX.writeFileXLSX(wb, filename, write_opts) attempts to write an XLSX file.
XLSX.writeFileAsync(filename, wb, o, cb) attempts to write
o is omitted, the writer will use the third argument as the callback.
Write options are described in the Writing Options section.
Utilities are available in the
The methods are covered in dedicated pages:
Cell and cell address manipulation:
encode_row / decode_rowconverts between 0-indexed rows and 1-indexed rows.
encode_col / decode_colconverts between 0-indexed columns and column names.
encode_cell / decode_cellconverts cell addresses.
encode_range / decode_rangeconverts cell ranges.
aoa_to_sheetconverts an array of arrays of JS data to a worksheet.
json_to_sheetconverts an array of JS objects to a worksheet.
sheet_add_aoaadds an array of arrays of JS data to an existing worksheet.
sheet_add_jsonadds an array of JS objects to an existing worksheet.
sheet_to_jsonconverts a worksheet object to an array of JSON objects.
Reading from HTML:
table_to_sheetconverts a DOM TABLE element to a worksheet.
table_to_bookconverts a DOM TABLE element to a worksheet.
sheet_add_domadds data from a DOM TABLE element to an existing worksheet.
sheet_to_htmlgenerates HTML output.
Writing CSV and Text:
sheet_to_csvgenerates delimiter-separated-values output.
sheet_to_txtgenerates UTF-16 formatted text.
sheet_to_formulaegenerates a list of formulae or cell value assignments.
book_newcreates an empty workbook
book_append_sheetadds a worksheet to a workbook
format_cellgenerates the text value for a cell (using number formats).
sheet_set_array_formulaadds an array formula to a worksheet
NodeJS Streaming Write functions
XLSX.stream contains a set of streaming write functions for NodeJS streams:
to_csv(sheet, opts)streams CSV rows
to_html(sheet, opts)streams an HTML table incrementally
to_json(sheet, opts)streams JS objects (object-mode stream)
Streaming write functions are described in the Streaming Write demo.
Due to broad inconsistencies in ESM implementations, the
mjs build does not
import any dependencies. Instead, they must be manually passed to the library:
XLSX.set_cptable sets the internal
codepage instance. This provides support
for different languages in XLS or text parsing.
fs instance (using
provides NodeJS ESM support for
XLSX.utils.set_readable supplies a NodeJS
stream.Readable constructor. This
provides NodeJS ESM support for the streaming operations.
ESM helper functions are described in the "NodeJS" Installation section
XLSX.version is the version of the library.
The current version is
XLSX.SSF is an embedded version of the format library.
XLSX.CFB is an embedded version of the container library.