Skip to main content

Standalone Browser Scripts

Each standalone release script is available at https://cdn.sheetjs.com/.

The current version is 0.20.3 and can be referenced as follows:

<!-- use version 0.20.3 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js"></script>

Watch the repo or subscribe to the RSS feed to be notified when new versions are released!

A number of services host older versions of the SheetJS libraries. Due to syncing issues, they are generally out of date.

The SheetJS CDN https://cdn.sheetjs.com/ is the authoritative source for SheetJS scripts

Browser Scripts

xlsx.full.min.js is the complete standalone script. It includes support for reading and writing many spreadsheet formats.

<!-- use xlsx.full.min.js from version 0.20.3 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js"></script>

xlsx.mini.min.js is a slimmer build that omits the following features:

  • CSV and SYLK encodings (directly affecting users outside of the United States)
  • XLSB / XLS / Lotus 1-2-3 / SpreadsheetML 2003 / Numbers file formats
  • Stream utility functions
How to integrate the mini build (click to show)

Replace references to xlsx.full.min.js with xlsx.mini.min.js. Starting from scratch, a single script tag should be added at the top of the HTML page:

<!-- use xlsx.mini.min.js from version 0.20.3 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.mini.min.js"></script>

Vendoring

For general stability, making a local copy of SheetJS scripts ("vendoring") is strongly recommended. Vendoring decouples websites from SheetJS infrastructure.

  1. Download the script (xlsx.full.min.js) for the desired version. The current version is available at https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js

  1. Move the script to a public folder with other scripts.

  2. Reference the local script from HTML pages:

<script src="/public/xlsx.full.min.js"></script>

This script assigns to window.XLSX. The global can be used in other scripts.

Internet Explorer and Older Browsers

For broad compatibility with JavaScript engines, the library is written using ECMAScript 3 language dialect. A "shim" script provides implementations of functions for older browsers and environments.

Due to SSL compatibility issues, older versions of IE will not be able to use the CDN scripts directly. They should be downloaded and saved to a public path:

A script reference to the shim must be added before the standalone script:

<!-- add the shim first -->
<script type="text/javascript" src="shim.min.js"></script>
<!-- after the shim is referenced, add the library -->
<script type="text/javascript" src="xlsx.full.min.js"></script>

Web Workers

The standalone scripts can be loaded using importScripts at the top of the worker scripts:

importScripts("https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/shim.min.js");
importScripts("https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js");

Type Checker

VSCode Telemetry and Data Exfiltration

The official Microsoft builds of Visual Studio Code ("VSCode") embed telemetry and send information to external servers.

VSCodium is a telemetry-free fork of VSCode.

When writing code that may process personally identifiable information (PII), the SheetJS team strongly encourages building VSCode from source or using IDEs that do not exfiltrate data.

The type checker integrated in VSCodium and VSCode do not currently provide type hints when using the standalone build. Using the JSDoc @type directive coupled with type imports, VSCodium will recognize the types:

VSCodium types

  1. Download the types (index.d.ts) for the desired version. The current version is available at https://cdn.sheetjs.com/xlsx-0.20.3/package/types/index.d.ts

  1. Rename the types file to xlsx.d.ts. It does not need to reside in the same folder as the standalone script.

  2. In the browser script referencing the global, prepend the following lines:

Prepend this fragment in each source file referencing the XLSX global
/** @type {import("./xlsx")} */
const XLSX = globalThis.XLSX;
  1. If the xlsx.d.ts file is in a different folder, change the argument to the import method to reflect the relative path. For example, given the structure:
Folder Structure
- /vendor
- /vendor/xlsx.ts
- /src
- /src/app.js

/src/app.js must refer to the types as ../vendor/xlsx:

Preamble for /src/app.js when types are at /vendor/xlsx.d.ts
/** @type {import("../vendor/xlsx")} */
const XLSX = globalThis.XLSX;

The .d.ts file extension must be omitted.

JSDoc types using the @import directive are not supported in <script> tags.

This is a known bug with VSCode!

ECMAScript Module Imports

This section refers to imports in HTML pages using <script type="module">.

The "Frameworks and Bundlers" section covers imports in projects using bundlers (ViteJS) or frameworks (Kaioken / ReactJS / Angular / VueJS / Svelte)

The ECMAScript Module build is saved to xlsx.mjs and can be directly added to a page with a script tag using type="module":

<script type="module">
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-0.20.3/package/xlsx.mjs";
</script>

If Encoding support is required, cpexcel.full.mjs must be manually imported:

<script type="module">
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-0.20.3/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>

Web Worker support is noted in the "Web Workers" demo

Dynamic Imports

Dynamic imports with import() will only download the SheetJS scripts when they are used. This example will download the library when data is exported:

<button id="xport">Export</button>
<script type="module">
xport.addEventListener("click", async() => {

/* dynamically import the script in the event listener */
const XLSX = await import("https://cdn.sheetjs.com/xlsx-0.20.3/package/xlsx.mjs");

const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet([["a","b","c"],[1,2,3]]);
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, "SheetJSESMTest.xlsx");
});
</script>

The callback functions must be marked as async and the script block must have the attribute type="module"

If Encoding support is required, cpexcel.full.mjs must be manually imported:

<button id="xport">Export</button>
<script type="module">
xport.addEventListener("click", async() => {

/* dynamically import the scripts in the event listener */
const XLSX = await import("https://cdn.sheetjs.com/xlsx-0.20.3/package/xlsx.mjs");
const cptable = await import("https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/cpexcel.full.mjs");
XLSX.set_cptable(cptable);

const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet([["a","b","c"],[1,2,3]]);
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, "SheetJSESMTest.xlsx");
});
</script>

Bower

Bower is deprecated and the maintainers recommend using other tools.

The Bower package manager supports tarballs from the SheetJS CDN:

npx bower install https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz

Bower will place the standalone scripts in bower_components/js-xlsx/dist/