xlsx-cli 1.1.3 [ci skip]

This commit is contained in:
SheetJS 2022-04-15 21:19:21 -04:00
parent 79e2773b58
commit af421e3161
9 changed files with 467 additions and 358 deletions

284
README.md

@ -34,6 +34,11 @@ port calculations to web apps; automate common spreadsheet tasks, and much more!
- [Getting Started](#getting-started)
* [Installation](#installation)
+ [Standalone Browser Scripts](#standalone-browser-scripts)
+ [ECMAScript Modules](#ecmascript-modules)
+ [Deno](#deno)
+ [NodeJS](#nodejs)
+ [Photoshop and InDesign](#photoshop-and-indesign)
* [Usage](#usage)
* [The Zen of SheetJS](#the-zen-of-sheetjs)
* [JS Ecosystem Demos](#js-ecosystem-demos)
@ -116,34 +121,26 @@ port calculations to web apps; automate common spreadsheet tasks, and much more!
### Installation
**Standalone Browser Scripts**
#### Standalone Browser Scripts
The complete browser standalone build is saved to `dist/xlsx.full.min.js` and
can be directly added to a page with a `<script>` tag:
Each standalone release script is available at <https://cdn.sheetjs.com/>.
The current version is `0.18.6` and can be referenced as follows:
```html
<script lang="javascript" src="dist/xlsx.full.min.js"></script>
<!-- use version 0.18.6 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.full.min.js"></script>
```
Each standalone release script is available at <https://cdn.sheetjs.com/>. The
latest version uses the `latest` tag:
The `latest` tag references the latest version and updates with each release:
```html
<!-- use the latest version -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
```
A specific release can be referenced by version:
```html
<!-- use version 0.18.5 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.5/package/dist/xlsx.full.min.js"></script>
```
For production use, scripts should be downloaded and added to a public folder
alongside other scripts.
</details>
**For production use, scripts should be downloaded and added to a public folder
alongside other scripts.**
<details>
<summary><b>Browser builds</b> (click to show)</summary>
@ -160,130 +157,20 @@ A slimmer build is generated at `dist/xlsx.mini.min.js`. Compared to full build:
These scripts are also available on the CDN:
```html
<!-- use xlsx.mini.min.js from the latest version -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.mini.min.js"></script>
<!-- use xlsx.mini.min.js from version 0.18.6 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.mini.min.js"></script>
```
</details>
With [bower](https://bower.io/search/?q=js-xlsx):
[Bower](https://bower.io/search/?q=js-xlsx) will pull the entire repo:
```bash
$ bower install js-xlsx
```
**ECMAScript Modules**
The ECMAScript Module build is saved to `xlsx.mjs` and can be directly added to
a page with a `script` tag using `type="module"`:
```html
<script type="module">
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>
```
The NodeJS package also exposes the module with the `module` parameter, which is
supported in Angular and other projects:
```ts
import { read, writeFileXLSX } from "xlsx";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);
```
**Deno**
`xlsx.mjs` can be imported in Deno:
```ts
// @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs';
/* load the codepage support library for extended support with older formats */
import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs';
XLSX.set_cptable(cptable);
```
**NodeJS**
Tarballs are available on <https://cdn.sheetjs.com>.
<https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz> is a link to the latest
version and will refresh on each release.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-<version>.tgz`) for the desired version.
2) Create a `vendor` subdirectory at the root of your project and move the
tarball to that folder. Add it to your project repository.
3) Install the tarball using a package manager:
```bash
# note : replace $VERSION with the actual version (e.g. latest or 0.18.6)
$ npm install --save file:vendor/xlsx-$VERSION.tgz # npm
$ pnpm install --save file:vendor/xlsx-$VERSION.tgz # pnpm
$ yarn add file:vendor/xlsx-$VERSION.tgz # yarn
```
The package will be installed and accessible as `xlsx`.
By default, the module supports `require`:
```js
var XLSX = require("xlsx");
```
The module also ships with `xlsx.mjs` for use with `import`:
```js
import * as XLSX from 'xlsx/xlsx.mjs';
/* load 'fs' for readFile and writeFile support */
import * as fs from 'fs';
XLSX.set_fs(fs);
/* load 'stream' for stream support */
import { Readable } from 'stream';
XLSX.stream.set_readable(Readable);
/* load the codepage support library for extended support with older formats */
import * as cpexcel from 'xlsx/dist/cpexcel.full.mjs';
XLSX.set_cptable(cpexcel);
```
**Photoshop and InDesign**
`dist/xlsx.extendscript.js` is an ExtendScript build for Photoshop and InDesign.
<https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.extendscript.js> is the
latest build. It can be directly referenced with a `#include` directive:
```extendscript
#include "xlsx.extendscript.js"
```
Bower will place the standalone scripts in `bower_components/js-xlsx/dist/`
<details>
<summary><b>Internet Explorer and ECMAScript 3 Compatibility</b> (click to show)</summary>
@ -301,12 +188,147 @@ To use the shim, add the shim before the script tag that loads `xlsx.js`:
<script type="text/javascript" src="xlsx.full.min.js"></script>
```
Due to SSL certificate compatibility issues, it is highly recommended to save
the Standalone and Shim scripts from <https://cdn.sheetjs.com/> and add to a
public directory in the site.
The script also includes `IE_LoadFile` and `IE_SaveFile` for loading and saving
files in Internet Explorer versions 6-9. The `xlsx.extendscript.js` script
bundles the shim in a format suitable for Photoshop and other Adobe products.
</details>
#### ECMAScript Modules
_Browser ESM_
The ECMAScript Module build is saved to `xlsx.mjs` and can be directly added to
a page with a `script` tag using `type="module"`:
```html
<script type="module">
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>
```
_Frameworks (Angular, VueJS, React) and Bundlers (webpack, etc)_
The NodeJS package is readily installed from the tarballs:
```bash
$ npm install --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # npm
$ pnpm install --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # pnpm
$ yarn add --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # yarn
```
Once installed, the library can be imported under the name `xlsx`:
```ts
import { read, writeFileXLSX } from "xlsx";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);
```
#### Deno
`xlsx.mjs` can be imported in Deno:
```ts
// @deno-types="https://cdn.sheetjs.com/xlsx-0.18.6/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs';
/* load the codepage support library for extended support with older formats */
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/cpexcel.full.mjs';
XLSX.set_cptable(cptable);
```
#### NodeJS
Tarballs are available on <https://cdn.sheetjs.com>.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
<https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz> is a link to the latest
version and will refresh on each release.
_Installation_
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-0.18.6.tgz`) for the desired version. The current
version is available at <https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz>
2) Create a `vendor` subdirectory at the root of your project and move the
tarball to that folder. Add it to your project repository.
3) Install the tarball using a package manager:
```bash
$ npm install --save file:vendor/xlsx-0.18.6.tgz # npm
$ pnpm install --save file:vendor/xlsx-0.18.6.tgz # pnpm
$ yarn add file:vendor/xlsx-0.18.6.tgz # yarn
```
The package will be installed and accessible as `xlsx`.
_Usage_
By default, the module supports `require` and it will automatically add support
for streams and filesystem access:
```js
var XLSX = require("xlsx");
```
The module also ships with `xlsx.mjs` for use with `import`. The `mjs` version
does not automatically load native node modules:
```js
import * as XLSX from 'xlsx/xlsx.mjs';
/* load 'fs' for readFile and writeFile support */
import * as fs from 'fs';
XLSX.set_fs(fs);
/* load 'stream' for stream support */
import { Readable } from 'stream';
XLSX.stream.set_readable(Readable);
/* load the codepage support library for extended support with older formats */
import * as cpexcel from 'xlsx/dist/cpexcel.full.mjs';
XLSX.set_cptable(cpexcel);
```
#### Photoshop and InDesign
`dist/xlsx.extendscript.js` is an ExtendScript build for Photoshop and InDesign.
<https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.extendscript.js> is the
current version. After downloading the script, it can be directly referenced
with a `#include` directive:
```extendscript
#include "xlsx.extendscript.js"
```
### Usage
Most scenarios involving spreadsheets and data can be broken into 5 parts:

@ -2,34 +2,26 @@
### Installation
**Standalone Browser Scripts**
#### Standalone Browser Scripts
The complete browser standalone build is saved to `dist/xlsx.full.min.js` and
can be directly added to a page with a `<script>` tag:
Each standalone release script is available at <https://cdn.sheetjs.com/>.
The current version is `0.18.6` and can be referenced as follows:
```html
<script lang="javascript" src="dist/xlsx.full.min.js"></script>
<!-- use version 0.18.6 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.full.min.js"></script>
```
Each standalone release script is available at <https://cdn.sheetjs.com/>. The
latest version uses the `latest` tag:
The `latest` tag references the latest version and updates with each release:
```html
<!-- use the latest version -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
```
A specific release can be referenced by version:
```html
<!-- use version 0.18.5 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.5/package/dist/xlsx.full.min.js"></script>
```
For production use, scripts should be downloaded and added to a public folder
alongside other scripts.
</details>
**For production use, scripts should be downloaded and added to a public folder
alongside other scripts.**
<details>
<summary><b>Browser builds</b> (click to show)</summary>
@ -46,130 +38,20 @@ A slimmer build is generated at `dist/xlsx.mini.min.js`. Compared to full build:
These scripts are also available on the CDN:
```html
<!-- use xlsx.mini.min.js from the latest version -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.mini.min.js"></script>
<!-- use xlsx.mini.min.js from version 0.18.6 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.mini.min.js"></script>
```
</details>
With [bower](https://bower.io/search/?q=js-xlsx):
[Bower](https://bower.io/search/?q=js-xlsx) will pull the entire repo:
```bash
$ bower install js-xlsx
```
**ECMAScript Modules**
The ECMAScript Module build is saved to `xlsx.mjs` and can be directly added to
a page with a `script` tag using `type="module"`:
```html
<script type="module">
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>
```
The NodeJS package also exposes the module with the `module` parameter, which is
supported in Angular and other projects:
```ts
import { read, writeFileXLSX } from "xlsx";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);
```
**Deno**
`xlsx.mjs` can be imported in Deno:
```ts
// @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs';
/* load the codepage support library for extended support with older formats */
import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs';
XLSX.set_cptable(cptable);
```
**NodeJS**
Tarballs are available on <https://cdn.sheetjs.com>.
<https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz> is a link to the latest
version and will refresh on each release.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-<version>.tgz`) for the desired version.
2) Create a `vendor` subdirectory at the root of your project and move the
tarball to that folder. Add it to your project repository.
3) Install the tarball using a package manager:
```bash
# note : replace $VERSION with the actual version (e.g. latest or 0.18.6)
$ npm install --save file:vendor/xlsx-$VERSION.tgz # npm
$ pnpm install --save file:vendor/xlsx-$VERSION.tgz # pnpm
$ yarn add file:vendor/xlsx-$VERSION.tgz # yarn
```
The package will be installed and accessible as `xlsx`.
By default, the module supports `require`:
```js
var XLSX = require("xlsx");
```
The module also ships with `xlsx.mjs` for use with `import`:
```js
import * as XLSX from 'xlsx/xlsx.mjs';
/* load 'fs' for readFile and writeFile support */
import * as fs from 'fs';
XLSX.set_fs(fs);
/* load 'stream' for stream support */
import { Readable } from 'stream';
XLSX.stream.set_readable(Readable);
/* load the codepage support library for extended support with older formats */
import * as cpexcel from 'xlsx/dist/cpexcel.full.mjs';
XLSX.set_cptable(cpexcel);
```
**Photoshop and InDesign**
`dist/xlsx.extendscript.js` is an ExtendScript build for Photoshop and InDesign.
<https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.extendscript.js> is the
latest build. It can be directly referenced with a `#include` directive:
```extendscript
#include "xlsx.extendscript.js"
```
Bower will place the standalone scripts in `bower_components/js-xlsx/dist/`
<details>
<summary><b>Internet Explorer and ECMAScript 3 Compatibility</b> (click to show)</summary>
@ -187,9 +69,144 @@ To use the shim, add the shim before the script tag that loads `xlsx.js`:
<script type="text/javascript" src="xlsx.full.min.js"></script>
```
Due to SSL certificate compatibility issues, it is highly recommended to save
the Standalone and Shim scripts from <https://cdn.sheetjs.com/> and add to a
public directory in the site.
The script also includes `IE_LoadFile` and `IE_SaveFile` for loading and saving
files in Internet Explorer versions 6-9. The `xlsx.extendscript.js` script
bundles the shim in a format suitable for Photoshop and other Adobe products.
</details>
#### ECMAScript Modules
_Browser ESM_
The ECMAScript Module build is saved to `xlsx.mjs` and can be directly added to
a page with a `script` tag using `type="module"`:
```html
<script type="module">
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>
```
_Frameworks (Angular, VueJS, React) and Bundlers (webpack, etc)_
The NodeJS package is readily installed from the tarballs:
```bash
$ npm install --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # npm
$ pnpm install --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # pnpm
$ yarn add --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # yarn
```
Once installed, the library can be imported under the name `xlsx`:
```ts
import { read, writeFileXLSX } from "xlsx";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);
```
#### Deno
`xlsx.mjs` can be imported in Deno:
```ts
// @deno-types="https://cdn.sheetjs.com/xlsx-0.18.6/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs';
/* load the codepage support library for extended support with older formats */
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/cpexcel.full.mjs';
XLSX.set_cptable(cptable);
```
#### NodeJS
Tarballs are available on <https://cdn.sheetjs.com>.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
<https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz> is a link to the latest
version and will refresh on each release.
_Installation_
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-0.18.6.tgz`) for the desired version. The current
version is available at <https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz>
2) Create a `vendor` subdirectory at the root of your project and move the
tarball to that folder. Add it to your project repository.
3) Install the tarball using a package manager:
```bash
$ npm install --save file:vendor/xlsx-0.18.6.tgz # npm
$ pnpm install --save file:vendor/xlsx-0.18.6.tgz # pnpm
$ yarn add file:vendor/xlsx-0.18.6.tgz # yarn
```
The package will be installed and accessible as `xlsx`.
_Usage_
By default, the module supports `require` and it will automatically add support
for streams and filesystem access:
```js
var XLSX = require("xlsx");
```
The module also ships with `xlsx.mjs` for use with `import`. The `mjs` version
does not automatically load native node modules:
```js
import * as XLSX from 'xlsx/xlsx.mjs';
/* load 'fs' for readFile and writeFile support */
import * as fs from 'fs';
XLSX.set_fs(fs);
/* load 'stream' for stream support */
import { Readable } from 'stream';
XLSX.stream.set_readable(Readable);
/* load the codepage support library for extended support with older formats */
import * as cpexcel from 'xlsx/dist/cpexcel.full.mjs';
XLSX.set_cptable(cpexcel);
```
#### Photoshop and InDesign
`dist/xlsx.extendscript.js` is an ExtendScript build for Photoshop and InDesign.
<https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.extendscript.js> is the
current version. After downloading the script, it can be directly referenced
with a `#include` directive:
```extendscript
#include "xlsx.extendscript.js"
```

@ -6,19 +6,25 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SheetJS Live Demo</title>
<style>
#drop{
border:2px dashed #bbb;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
padding:25px;
text-align:center;
font:20pt bold,"Vollkorn";color:#bbb
}
#b64data{
width:100%;
}
a { text-decoration: none }
#drop-zone{
background: white;
position: fixed;
top: 0px;
left: 0px;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
z-index: -1;
}
#drop-zone p, #drop-zone svg { pointer-events: none }
#drop-zone svg { margin-right: 5px }
</style>
</head>
<body>
@ -33,28 +39,32 @@ Output Format: <select name="format" onchange="setfmt()">
<option value="json"> JSON</option>
<option value="form"> FORMULAE</option>
<option value="html"> HTML</option>
<option value="xlsx"> XLSX</option>
</select><br />
<div id="drop">Drop a spreadsheet file here to see sheet data</div>
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
<input type="file" name="xlfile" id="xlf" />
<b> Drop a spreadsheet file anywhere in the page to see sheet data </b>
<textarea id="b64data">... or paste a base64-encoding here</textarea>
<input type="button" id="dotext" value="Click here to process the base64 text" onclick="b64it();"/><br />
<b>Advanced Demo Options:</b>
Use Web Workers: (when available) <input type="checkbox" name="useworker" checked>
Use Web Workers when available: <input type="checkbox" name="useworker" checked>
Always use UTF8 for CSV / text: <input type="checkbox" name="useutf8" checked>
</pre>
<pre id="out"></pre>
<div id="htmlout"></div>
<div id="drop-zone">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M17 13h-10v-1h10v1zm0-4h-10v1h10v-1zm0-3h-10v1h10v-1zm-15-1v-5h6v2h-4v3h-2zm8-5v2h4v-2h-4zm6 2h4v3h2v-5h-6v2zm6 5h-2v4h2v-4zm-20 10h2v-4h-2v4zm18-4v.543c0 4.107-6 2.457-6 2.457s1.518 6-2.638 6h-1.362v2h2.189c3.163 0 9.811-7.223 9.811-9.614v-1.386h-2zm-18-2h2v-4h-2v4zm2 11v-3h-2v5h6v-2h-4z"/></svg>
<p>Drop a spreadsheet file here to see sheet data</p>
</div>
<br />
<!-- uncomment the next line here and in xlsxworker.js for encoding support -->
<script src="dist/cpexcel.js"></script>
<script src="shim.js"></script>
<script src="xlsx.js"></script>
<script src="dist/shim.min.js"></script>
<script src="dist/xlsx.full.min.js"></script>
<script>
/*jshint browser:true */
/* eslint-env browser */
/*global Uint8Array */
/*global Uint8Array, Uint16Array, ArrayBuffer */
/*global XLSX */
/* exported b64it, setfmt */
/* eslint no-use-before-define:0 */
var global_wb;
@ -114,6 +124,12 @@ var process_wb = (function() {
return "";
};
var to_xlsx = function to_xlsx(workbook) {
HTMLOUT.innerHTML = "";
XLSX.writeFile(workbook, "SheetJSTest.xlsx");
return "";
};
return function process_wb(wb) {
global_wb = wb;
var output = "";
@ -121,6 +137,7 @@ var process_wb = (function() {
case "form": output = to_fmla(wb); break;
case "html": output = to_html(wb); break;
case "json": output = to_json(wb); break;
case "xlsx": output = to_xlsx(wb); break;
default: output = to_csv(wb);
}
if(OUT.innerText === undefined) OUT.textContent = output;
@ -145,6 +162,8 @@ var do_file = (function() {
var domwork = document.getElementsByName("useworker")[0];
if(!use_worker) domwork.disabled = !(domwork.checked = false);
var use_utf8 = false;
var xw = function xw(data, cb) {
var worker = new Worker('./xlsxworker.js');
worker.onmessage = function(e) {
@ -154,30 +173,30 @@ var do_file = (function() {
case 'xlsx': cb(JSON.parse(e.data.d)); break;
}
};
worker.postMessage({d:data,b:'array'});
worker.postMessage({d:data,b:'array',c:use_utf8 ? 65001 : void 0});
};
return function do_file(files) {
use_worker = domwork.checked;
use_utf8 = document.getElementsByName("useutf8")[0].checked;
var f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
if(typeof console !== 'undefined') console.log("onload", new Date(), use_worker);
var data = new Uint8Array(e.target.result);
if(use_worker) xw(data, process_wb);
else process_wb(XLSX.read(data, {type: 'array'}));
else process_wb(XLSX.read(data, {type: 'array', codepage: use_utf8 ? 65001 : void 0}));
};
reader.readAsArrayBuffer(f);
};
})();
(function() {
var drop = document.getElementById('drop');
if(!drop.addEventListener) return;
var dropZone = document.getElementById('drop-zone')
if(!dropZone.addEventListener && !window.addEventListener) return;
function handleDrop(e) {
e.stopPropagation();
e.preventDefault();
dropZoneDisplay(e, false);
do_file(e.dataTransfer.files);
}
@ -187,9 +206,26 @@ var do_file = (function() {
e.dataTransfer.dropEffect = 'copy';
}
drop.addEventListener('dragenter', handleDragover, false);
drop.addEventListener('dragover', handleDragover, false);
drop.addEventListener('drop', handleDrop, false);
function dropZoneDisplay(e, show){
e.stopPropagation();
e.preventDefault();
var opacity = show ? '1' : '0';
var zIndex = show ? '1' : '-1';
dropZone.style.opacity = opacity;
dropZone.style.zIndex = zIndex;
}
window.addEventListener('drop' , handleDrop)
window.addEventListener('dragover' , handleDragover)
window.addEventListener('dragenter' , function(e){
dropZoneDisplay(e, true);
})
dropZone.addEventListener('dragleave' , function(e){
dropZoneDisplay(e, false);
})
})();
(function() {

@ -32,6 +32,11 @@ port calculations to web apps; automate common spreadsheet tasks, and much more!
- [Getting Started](#getting-started)
* [Installation](#installation)
+ [Standalone Browser Scripts](#standalone-browser-scripts)
+ [ECMAScript Modules](#ecmascript-modules)
+ [Deno](#deno)
+ [NodeJS](#nodejs)
+ [Photoshop and InDesign](#photoshop-and-indesign)
* [Usage](#usage)
* [The Zen of SheetJS](#the-zen-of-sheetjs)
* [JS Ecosystem Demos](#js-ecosystem-demos)
@ -113,33 +118,26 @@ port calculations to web apps; automate common spreadsheet tasks, and much more!
### Installation
**Standalone Browser Scripts**
#### Standalone Browser Scripts
The complete browser standalone build is saved to `dist/xlsx.full.min.js` and
can be directly added to a page with a `<script>` tag:
Each standalone release script is available at <https://cdn.sheetjs.com/>.
The current version is `0.18.6` and can be referenced as follows:
```html
<script lang="javascript" src="dist/xlsx.full.min.js"></script>
<!-- use version 0.18.6 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.full.min.js"></script>
```
Each standalone release script is available at <https://cdn.sheetjs.com/>. The
latest version uses the `latest` tag:
The `latest` tag references the latest version and updates with each release:
```html
<!-- use the latest version -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js"></script>
```
A specific release can be referenced by version:
```html
<!-- use version 0.18.5 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.5/package/dist/xlsx.full.min.js"></script>
```
For production use, scripts should be downloaded and added to a public folder
alongside other scripts.
**For production use, scripts should be downloaded and added to a public folder
alongside other scripts.**
The complete single-file version is generated at `dist/xlsx.full.min.js`
@ -154,36 +152,73 @@ A slimmer build is generated at `dist/xlsx.mini.min.js`. Compared to full build:
These scripts are also available on the CDN:
```html
<!-- use xlsx.mini.min.js from the latest version -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.mini.min.js"></script>
<!-- use xlsx.mini.min.js from version 0.18.6 -->
<script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.mini.min.js"></script>
```
With [bower](https://bower.io/search/?q=js-xlsx):
[Bower](https://bower.io/search/?q=js-xlsx) will pull the entire repo:
```bash
$ bower install js-xlsx
```
**ECMAScript Modules**
Bower will place the standalone scripts in `bower_components/js-xlsx/dist/`
For broad compatibility with JavaScript engines, the library is written using
ECMAScript 3 language dialect as well as some ES5 features like `Array#forEach`.
Older browsers require shims to provide missing functions.
To use the shim, add the shim before the script tag that loads `xlsx.js`:
```html
<!-- 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>
```
Due to SSL certificate compatibility issues, it is highly recommended to save
the Standalone and Shim scripts from <https://cdn.sheetjs.com/> and add to a
public directory in the site.
The script also includes `IE_LoadFile` and `IE_SaveFile` for loading and saving
files in Internet Explorer versions 6-9. The `xlsx.extendscript.js` script
bundles the shim in a format suitable for Photoshop and other Adobe products.
#### ECMAScript Modules
_Browser ESM_
The ECMAScript Module build is saved to `xlsx.mjs` and can be directly added to
a page with a `script` tag using `type="module"`:
```html
<script type="module">
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs";
import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs";
/* load the codepage support library for extended support with older formats */
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs';
import { set_cptable } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs";
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/cpexcel.full.mjs';
set_cptable(cptable);
</script>
```
The NodeJS package also exposes the module with the `module` parameter, which is
supported in Angular and other projects:
_Frameworks (Angular, VueJS, React) and Bundlers (webpack, etc)_
The NodeJS package is readily installed from the tarballs:
```bash
$ npm install --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # npm
$ pnpm install --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # pnpm
$ yarn add --save https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # yarn
```
Once installed, the library can be imported under the name `xlsx`:
```ts
import { read, writeFileXLSX } from "xlsx";
@ -194,40 +229,43 @@ import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);
```
**Deno**
#### Deno
`xlsx.mjs` can be imported in Deno:
```ts
// @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs';
// @deno-types="https://cdn.sheetjs.com/xlsx-0.18.6/package/types/index.d.ts"
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs';
/* load the codepage support library for extended support with older formats */
import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs';
import * as cptable from 'https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/cpexcel.full.mjs';
XLSX.set_cptable(cptable);
```
**NodeJS**
#### NodeJS
Tarballs are available on <https://cdn.sheetjs.com>.
<https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz> is a link to the latest
version and will refresh on each release.
Each individual version can be referenced using a similar URL pattern.
<https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz> is the URL for `0.18.6`
<https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz> is a link to the latest
version and will refresh on each release.
_Installation_
Tarballs can be directly installed using a package manager:
```bash
$ npm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz # yarn
$ npm install https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # npm
$ pnpm install https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # pnpm
$ yarn add https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz # yarn
```
For general stability, "vendoring" modules is the recommended approach:
1) Download the tarball (`xlsx-<version>.tgz`) for the desired version.
1) Download the tarball (`xlsx-0.18.6.tgz`) for the desired version. The current
version is available at <https://cdn.sheetjs.com/xlsx-0.18.6/xlsx-0.18.6.tgz>
2) Create a `vendor` subdirectory at the root of your project and move the
tarball to that folder. Add it to your project repository.
@ -235,21 +273,24 @@ For general stability, "vendoring" modules is the recommended approach:
3) Install the tarball using a package manager:
```bash
# note : replace $VERSION with the actual version (e.g. latest or 0.18.6)
$ npm install --save file:vendor/xlsx-$VERSION.tgz # npm
$ pnpm install --save file:vendor/xlsx-$VERSION.tgz # pnpm
$ yarn add file:vendor/xlsx-$VERSION.tgz # yarn
$ npm install --save file:vendor/xlsx-0.18.6.tgz # npm
$ pnpm install --save file:vendor/xlsx-0.18.6.tgz # pnpm
$ yarn add file:vendor/xlsx-0.18.6.tgz # yarn
```
The package will be installed and accessible as `xlsx`.
By default, the module supports `require`:
_Usage_
By default, the module supports `require` and it will automatically add support
for streams and filesystem access:
```js
var XLSX = require("xlsx");
```
The module also ships with `xlsx.mjs` for use with `import`:
The module also ships with `xlsx.mjs` for use with `import`. The `mjs` version
does not automatically load native node modules:
```js
import * as XLSX from 'xlsx/xlsx.mjs';
@ -267,36 +308,18 @@ import * as cpexcel from 'xlsx/dist/cpexcel.full.mjs';
XLSX.set_cptable(cpexcel);
```
**Photoshop and InDesign**
#### Photoshop and InDesign
`dist/xlsx.extendscript.js` is an ExtendScript build for Photoshop and InDesign.
<https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.extendscript.js> is the
latest build. It can be directly referenced with a `#include` directive:
<https://cdn.sheetjs.com/xlsx-0.18.6/package/dist/xlsx.extendscript.js> is the
current version. After downloading the script, it can be directly referenced
with a `#include` directive:
```extendscript
#include "xlsx.extendscript.js"
```
For broad compatibility with JavaScript engines, the library is written using
ECMAScript 3 language dialect as well as some ES5 features like `Array#forEach`.
Older browsers require shims to provide missing functions.
To use the shim, add the shim before the script tag that loads `xlsx.js`:
```html
<!-- 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>
```
The script also includes `IE_LoadFile` and `IE_SaveFile` for loading and saving
files in Internet Explorer versions 6-9. The `xlsx.extendscript.js` script
bundles the shim in a format suitable for Photoshop and other Adobe products.
### Usage
Most scenarios involving spreadsheets and data can be broken into 5 parts:

@ -3,6 +3,11 @@
- [xlsx](README.md#sheetjs-js-xlsx)
- [Getting Started](README.md#getting-started)
* [Installation](README.md#installation)
+ [Standalone Browser Scripts](README.md#standalone-browser-scripts)
+ [ECMAScript Modules](README.md#ecmascript-modules)
+ [Deno](README.md#deno)
+ [NodeJS](README.md#nodejs)
+ [Photoshop and InDesign](README.md#photoshop-and-indesign)
* [Usage](README.md#usage)
* [The Zen of SheetJS](README.md#the-zen-of-sheetjs)
* [JS Ecosystem Demos](README.md#js-ecosystem-demos)

@ -32,6 +32,7 @@ function run() {
.option('-6, --xlml', 'emit SSML to <sheetname> or <file>.xls (2003 XML)')
.option('-T, --fods', 'emit FODS to <sheetname> or <file>.fods (Flat ODS)')
.option('--wk3', 'emit WK3 to <sheetname> or <file>.txt (Lotus WK3)')
.option('--numbers', 'emit NUMBERS to <sheetname> or <file>.numbers')
.option('-S, --formulae', 'emit list of values and formulae')
.option('-j, --json', 'emit formatted JSON (all fields text)')
@ -75,6 +76,7 @@ function run() {
['xls', 'xls', 'xls'],
['xla', 'xla', 'xla'],
['biff5', 'biff5', 'xls'],
['numbers', 'numbers', 'numbers'],
['ods', 'ods', 'ods'],
['fods', 'fods', 'fods'],
['wk3', 'wk3', 'wk3']
@ -178,6 +180,10 @@ function run() {
workbook_formats.forEach(function (m) {
if (program[m[0]] || isfmt(m[0])) {
wopts.bookType = m[1];
if (wopts.bookType == "numbers") try {
var XLSX_ZAHL = require("xlsx/dist/xlsx.zahl");
wopts.numbers = XLSX_ZAHL;
} catch(e) {}
if (wb) X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
process.exit(0);
}

@ -1,6 +1,6 @@
{
"name": "xlsx-cli",
"version": "1.1.2",
"version": "1.1.3",
"author": "sheetjs",
"description": "Command-line interface for SheetJS",
"keywords": [
@ -24,7 +24,7 @@
"dependencies": {
"commander": "~2.17.1",
"exit-on-epipe": "~1.0.1",
"xlsx": "latest"
"xlsx": "https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz"
},
"devDependencies": {
},

@ -10,7 +10,7 @@ importScripts('xlsx.js');
onmessage = function (evt) {
var v;
try {
v = XLSX.read(evt.data.d, {type: evt.data.b});
v = XLSX.read(evt.data.d, {type: evt.data.b, codepage: evt.data.c});
/*::self.*/postMessage({t:"xlsx", d:JSON.stringify(v)});
} catch(e) { /*::self.*/postMessage({t:"e",d:e.stack||e}); }
};

2
xlsxworker.js generated

@ -8,7 +8,7 @@ postMessage({t:"ready"});
onmessage = function (evt) {
var v;
try {
v = XLSX.read(evt.data.d, {type: evt.data.b});
v = XLSX.read(evt.data.d, {type: evt.data.b, codepage: evt.data.c});
postMessage({t:"xlsx", d:JSON.stringify(v)});
} catch(e) { postMessage({t:"e",d:e.stack||e}); }
};