ExtendScript Demo fixed links

This commit is contained in:
SheetJS 2024-08-12 01:40:33 -04:00
parent 0699eabbba
commit 6836b4b450
13 changed files with 387 additions and 74 deletions

@ -110,7 +110,7 @@
<Cell ss:StyleID="s16"><Data ss:Type="String">✔</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">✔</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">✘</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String"> </Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String"></Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String">✘</Data></Cell>
<Cell ss:StyleID="s16"><Data ss:Type="String"> </Data></Cell>
</Row>

@ -119,12 +119,12 @@ builder requires a proper `package.json` that includes the SheetJS dependency.
This demo was last tested in the following deployments:
| Architecture | BunJS | Date |
|:-------------|:--------|:-----------|
| `darwin-x64` | `1.1.4` | 2024-04-19 |
| `win10-x64` | `1.1.4` | 2024-04-19 |
| `win11-x64` | `1.1.8` | 2024-05-17 |
| `linux-x64` | `1.1.4` | 2024-04-25 |
| Architecture | BunJS | Date |
|:-------------|:---------|:-----------|
| `darwin-x64` | `1.1.4` | 2024-04-19 |
| `win10-x64` | `1.1.4` | 2024-04-19 |
| `win11-x64` | `1.1.22` | 2024-08-11 |
| `linux-x64` | `1.1.4` | 2024-04-25 |
:::
@ -138,8 +138,34 @@ echo "{}" > package.json
:::caution pass
In PowerShell, the redirect will add the UTF16LE BOM. Bun does not currently
support the encoding. The file must be resaved in UTF8 (without BOM) or ASCII.
The PowerShell file redirect will use the `UTF-16 LE` encoding. Bun does not
support the encoding and will fail to install the package:
```
bun add v1.1.22-canary.96 (df33f2b2)
1 | <20><>{}
^
error: Unexpected <20><>
```
The file must be resaved in UTF8 (without BOM) or ASCII.
0) Open `package.json` in VSCodium.
The current encoding is displayed in the lower-right corner:
![VSCodium status bar](pathname:///files/encodium.png)
1) Click the displayed encoding.
2) In the "Select Action" popup, select "Save with Encoding"
3) In the new list, select `UTF-8 utf8`:
![VSCodium encoding](pathname:///files/vscutf8.png)
VSCodium will automatically re-save the file.
:::

@ -35,9 +35,9 @@ This demo was tested in the following configurations:
| Date | Platform |
|:-----------|:--------------------------------------------------------------|
| 2024-08-09 | NVIDIA RTX 4090 (24 GB VRAM) + i9-10910 (128 GB RAM) |
| 2024-08-09 | NVIDIA RTX 4080 SUPER (16 GB VRAM) + i9-10910 (128 GB RAM) |
| 2024-07-15 | Apple M2 Max 12-Core CPU + 30-Core GPU (32 GB unified memory) |
| 2024-07-14 | NVIDIA RTX 4090 (24 GB VRAM) + i9-10910 (128 GB RAM) |
| 2024-07-14 | NVIDIA RTX 4080 SUPER (16 GB VRAM) + i9-10910 (128 GB RAM) |
SheetJS users have verified this demo in other configurations:
@ -50,6 +50,7 @@ SheetJS users have verified this demo in other configurations:
| LangChainJS | NVIDIA RTX 4060 (8 GB VRAM) + Ryzen 7 5700g (32 GB RAM) |
| LangChainJS | NVIDIA RTX 3090 (24 GB VRAM) + Ryzen 9 3900XT (128 GB RAM) |
| LangChainJS | NVIDIA RTX 3080 (12 GB VRAM) + Ryzen 7 5800X (32 GB RAM) |
| LangChainJS | NVIDIA RTX 3070 (8 GB VRAM) + Ryzen Z1 Extreme (16 GB RAM) |
| LangChainJS | NVIDIA RTX 3060 (12 GB VRAM) + i5-11400 (32 GB RAM) |
| LangChainJS | NVIDIA RTX 2080 (12 GB VRAM) + i7-9700K (16 GB RAM) |
| LangChainJS | NVIDIA RTX 2060 (6 GB VRAM) + Ryzen 5 3600 (32 GB RAM) |
@ -60,13 +61,13 @@ SheetJS users have verified this demo in other configurations:
Special thanks to:
- [`@Rasmus`](https://tengstedt.dev/)
- [Rasmus Tengstedt](https://tengstedt.dev/)
- [Triston Armstrong](https://tristonarmstrong.com/)
- [Ben Halverson](https://benhalverson.dev/)
- [Navid Nami](https://github.com/CaseoJKL)
- [`@Smor`](https://smor.dev/)
- [`@timbr`](https://timbr.dev/)
- [`n3bs`](https://github.com/0xn3bs)
- [`@n3bs`](https://github.com/0xn3bs)
:::
@ -159,14 +160,51 @@ flowchart LR
linkStyle 0,1,2 color:blue,stroke:blue;
```
The SheetJS `readFile` method[^2] can read general workbooks. The method returns
a workbook object that conforms to the SheetJS data model[^3].
**Parsing files from the filesystem**
The SheetJS `readFile` method[^2] can read workbook files. The method accepts a
path and returns a workbook object that conforms to the SheetJS data model[^3].
```js
/* Load SheetJS Libraries */
import { readFile, set_fs } from 'xlsx';
/* Load 'fs' for readFile support */
import * as fs from 'fs';
set_fs(fs);
/* Parse `pres.xlsx` */
// highlight-next-line
const wb = readFile("pres.xlsx");
```
**Inspecting SheetJS workbook and worksheet objects**
Workbook objects represent multi-sheet workbook files. They store individual
worksheet objects and other metadata.
Relevant to this discussion, the workbook object uses the following keys[^7]:
- `SheetNames` is an array of worksheet names
- `Sheets` is an object whose keys are sheet names and whose values are sheet objects.
`SheetNames[0]` is the first worksheet name, so the following snippet will pull
the first worksheet from the workbook:
```js
const first_ws = wb.Sheets[wb.SheetNames[0]];
```
**Exporting SheetJS worksheets to CSV**
Each worksheet in the workbook can be written to CSV text using the SheetJS
`sheet_to_csv`[^4] method.
`sheet_to_csv`[^4] method. The method accepts a SheetJS worksheet object and
returns a string.
```js
const csv = utils.sheet_to_csv(first_ws);
```
**Complete Script**
For example, the following NodeJS script reads `pres.xlsx` and displays CSV rows
from the first worksheet:
@ -197,8 +235,8 @@ and [Maple](/docs/demos/extensions/maple/) support XLSX data import. The SheetJS
integrations generate clean XLSX workbooks from user-supplied spreadsheets.
- [TensorFlow.js](/docs/demos/math/tensorflow), [Pandas](/docs/demos/math/pandas)
and [Mathematica](/docs/demos/extensions/mathematica) support CSV. The SheetJS
integrations generate clean CSVs and use built-in CSV processors.
and [Mathematica](/docs/demos/extensions/mathematica) support CSV data import.
The SheetJS integrations generate clean CSVs and use built-in CSV processors.
- The ["Command-Line Tools"](/docs/demos/cli/) demo covers techniques for making
standalone command-line tools for file conversion.
@ -417,8 +455,11 @@ This issue affects many JavaScript tools. Various demos cover workarounds:
- [ViteJS plugins](/docs/demos/static/vitejs#plugins) receive the relative path
to the workbook file and can read the file directly.
- [Webpack Plugins](/docs/demos/static/webpack#sheetjs-loader) have a special
option to instruct the library to pass raw binary data rather than text.
- [Webpack plugins](/docs/demos/static/webpack#sheetjs-loader) support a special
`raw` option that instructs the bundler to pass raw binary data.
- [NuxtJS parsers and transformers](/docs/demos/static/nuxtjs) can deduce the
path to the workbook file from internal identifiers.
:::
@ -682,7 +723,7 @@ SheetJS users have also tested this demo within Windows Subsystem for Linux.
:::caution pass
This demo was tested using the ChatQA-1.5 model[^9] in Ollama[^10].
This demo was tested using the ChatQA-1.5 model[^9] in Ollama.
The tested model used up to 9.2GB VRAM. It is strongly recommended to run the
demo on a newer Apple Silicon Mac or a PC with an Nvidia GPU with at least 12GB
@ -690,7 +731,21 @@ VRAM. SheetJS users have tested the demo on systems with as little as 6GB VRAM.
:::
0) Create a new project:
0) Install pre-requisites:
- [NodeJS LTS (version 20+)](https://nodejs.org/)
- [Ollama](https://ollama.com/download)
:::note pass
Ollama should be installed on the same platform as NodeJS. If NodeJS is run
within WSL, Ollama should also be installed within WSL.
:::
After installing dependencies, start a new terminal session.
1) Create a new project:
```bash
mkdir sheetjs-loader
@ -698,7 +753,7 @@ cd sheetjs-loader
npm init -y
```
1) Download the demo scripts:
2) Download the demo scripts:
- [`loadofsheet.mjs`](pathname:///loadofsheet/loadofsheet.mjs)
- [`query.mjs`](pathname:///loadofsheet/query.mjs)
@ -725,13 +780,13 @@ curl.exe -LO https://docs.sheetjs.com/loadofsheet/loadofsheet.mjs
:::
2) Install the SheetJS NodeJS module:
3) Install the SheetJS NodeJS module:
<CodeBlock language="bash">{`\
npm i --save https://sheet.lol/balls/xlsx-${current}.tgz`}
</CodeBlock>
3) Install dependencies:
4) Install dependencies:
```bash
npm i --save @langchain/community@0.2.18 @langchain/core@0.2.15 langchain@0.2.9 peggy@4.0.3 --force
@ -744,7 +799,7 @@ and peer dependency versions. The `--force` flag was required.
:::
4) Download the [cars dataset](pathname:///cd.xls):
5) Download the [cars dataset](pathname:///cd.xls):
```bash
curl -LO https://docs.sheetjs.com/cd.xls
@ -766,20 +821,13 @@ curl.exe -LO https://docs.sheetjs.com/cd.xls
:::
5) Install the `llama3-chatqa:8b-v1.5-q8_0` model using Ollama:
6) Install the `llama3-chatqa:8b-v1.5-q8_0` model using Ollama:
```bash
ollama pull llama3-chatqa:8b-v1.5-q8_0
```
:::note pass
If the command cannot be found, install Ollama[^10] and run the command in a new
terminal window.
:::
6) Run the demo script
7) Run the demo script
```bash
node query.mjs
@ -838,4 +886,3 @@ charts, tables, and other features.
[^7]: See ["Workbook Object"](/docs/csf/book)
[^8]: See [`sheet_to_json` in "Utilities"](/docs/api/utilities/array#array-output)
[^9]: See [the official ChatQA website](https://chatqa-project.github.io/) for the ChatQA paper and other model details.
[^10]: See [the official Ollama website](https://ollama.com/download) for installation instructions.

@ -48,11 +48,27 @@ app.post('/import', async(c) => {
// highlight-next-line
const file = body["upload"];
/* `file` is a `File` objects */
/* `file` is a `File` object */
// ...
});
```
:::caution pass
By default, the HonoJS body parser will use the last value when the form body
specifies multiple values for a given field. To force the body parser to process
all files, the field name must end with `[]`:
```js
/* parse body */
const body = await c.req.parseBody();
/* get all files uploaded in the `upload` field */
// highlight-next-line
const files = body["upload[]"];
```
:::
HonoJS exposes each file as a `Blob` object. The `Blob#arrayBuffer` method
returns a Promise that resolves to an `ArrayBuffer`. That `ArrayBuffer` can be
parsed with the SheetJS `read` method[^2].

@ -14,6 +14,9 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
export const r = {style: {color:"red"}};
export const g = {style: {color:"green"}};
Dart[^1] + Flutter[^2] is a popular cross-platform app framework. JavaScript
code can be run through [embedded engines](/docs/demos/engines).
@ -56,6 +59,7 @@ This demo was tested in the following environments:
|:-----------|:------------------|:--------|:---------|:-------------|:-----------|
| Android 34 | Pixel 3a | `3.4.3` | `3.22.2` | `darwin-x64` | 2024-06-09 |
| iOS 17.5 | iPhone 15 Pro Max | `3.4.3` | `3.22.2` | `darwin-x64` | 2024-06-09 |
| Android 35 | Pixel 3a | `3.5.0` | `3.24.0` | `win11-x64` | 2024-08-10 |
:::
@ -224,24 +228,24 @@ Run `flutter doctor` and confirm the following items are checked:
<Tabs groupId="os">
<TabItem value="linux" label="Linux">
```
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
```
<pre>
<span {...g}>[✓]</span> Android toolchain - develop for Android devices (Android SDK version 34.0.0)
</pre>
</TabItem>
<TabItem value="macos" label="macOS" default>
```
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
```
<pre>
<span {...g}>[✓]</span> Android toolchain - develop for Android devices (Android SDK version 34.0.0)
<span {...g}>[✓]</span> Xcode - develop for iOS and macOS (Xcode 15.4)
</pre>
</TabItem>
<TabItem value="win" label="Windows">
```
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
```
<pre>
<span {...g}>[✓]</span> Android toolchain - develop for Android devices (Android SDK version 35.0.0)
</pre>
</TabItem>
</Tabs>
@ -290,6 +294,11 @@ In local testing, there were issues with the Android toolchain:
error: Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
```
Android Studio does not install `Android SDK Command-Line Tools` by default. It
must be installed manually.
Assuming the command-line tools are installed
This was fixed by switching to Java 20, installing `Android SDK 33`, and rolling
back to `Android SDK Command-Line Tools (revision: 10.0)`
@ -307,13 +316,12 @@ If Google Chrome is not installed, `flutter doctor` will show an issue:
If Chromium is installed, the environment variable should be manually assigned:
```bash
export CHROME_EXECUTABLE=/Applications/Chromium.app/Contents/MacOS/Chromium
```
<Tabs groupId="os">
<TabItem value="linux" label="Linux">
The `CHROME_EXECUTABLE` environment variable should be set to the path to the
`chrome` binary. This path differs between distributions and package managers.
</TabItem>
<TabItem value="macos" label="macOS">
@ -324,6 +332,18 @@ export CHROME_EXECUTABLE=/Applications/Chromium.app/Contents/MacOS/Chromium
</TabItem>
<TabItem value="win" label="Windows">
Type `env` in the search bar and select "Edit the system environment variables".
In the new window, click the "Environment Variables..." button.
In the new window, look for the "System variables" section and click "New..."
Set the "Variable name" to `CHROME_EXECUTABLE` and the value to the path to the
program. When this demo was last tested, Chromium was installed for the local
user at `C:\Users\USERNAME\AppData\Local\Chromium\Application\chrome.exe` .
Click "OK" in each window (3 windows) and restart your computer.
</TabItem>
</Tabs>
@ -331,7 +351,20 @@ export CHROME_EXECUTABLE=/Applications/Chromium.app/Contents/MacOS/Chromium
</details>
Run `flutter emulators` and check for both `ios` and `android` emulators:
Run `flutter emulators` and look for `android` and (on macOS only) `ios`
emulators.
<Tabs groupId="os">
<TabItem value="linux" label="Linux">
```
Id • Name • Manufacturer • Platform
Pixel_3a_API_35 • Pixel 3a API 35 • Google • android
```
</TabItem>
<TabItem value="macos" label="macOS">
```
Id • Name • Manufacturer • Platform
@ -340,6 +373,18 @@ apple_ios_simulator • iOS Simulator • Apple • ios
Pixel_3a_API_34 • Pixel 3a API 34 • Google • android
```
</TabItem>
<TabItem value="win" label="Windows">
```
Id • Name • Manufacturer • Platform
Pixel_3a_API_35 • Pixel 3a API 35 • Google • android
```
</TabItem>
</Tabs>
1) Disable telemetry. The following commands were confirmed to work:
```bash
@ -449,6 +494,32 @@ Once the app loads, stop the terminal process and close the simulator.
flutter pub add http csv flutter_js
```
:::info pass
The command may fail in Windows with the followimg message:
<pre {...r}>
Building with plugins requires symlink support.
Please enable Developer Mode in your system settings. Run
{` `}start ms-settings:developers
to open settings.
</pre>
As stated, "Developer Mode" must be enabled:
1) Run `start ms-settings:developers`
2) In the panel, enable "Developer Mode" and click "Yes" in the popup.
3) Reinstall dependencies:
```bash
flutter pub add http csv flutter_js
```
:::
6) Open `pubspec.yaml` with a text editor. Search for the line that starts with
`flutter:` (no whitespace) and add the highlighted lines:
@ -472,12 +543,50 @@ curl -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/shim.min.js
cd ..`}
</CodeBlock>
:::caution pass
PowerShell `curl` is incompatible with the official `curl` program. The command
may fail with a parameter error:
```
Invoke-WebRequest : A parameter cannot be found that matches parameter name 'LO'.
```
`curl.exe` must be used instead:
<CodeBlock language="bash">{`\
mkdir -p scripts
cd scripts
curl.exe -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/xlsx.full.min.js
curl.exe -LO https://cdn.sheetjs.com/xlsx-${current}/package/dist/shim.min.js
cd ..`}
</CodeBlock>
:::
8) Download [`main.dart`](pathname:///flutter/main.dart) to `lib/main.dart`:
```bash
curl -L -o lib/main.dart https://docs.sheetjs.com/flutter/main.dart
```
:::caution pass
PowerShell `curl` is incompatible with the official `curl` program. The command
may fail with a parameter error:
```
Invoke-WebRequest : A parameter cannot be found that matches parameter name 'L'.
```
`curl.exe` must be used instead:
```bash
curl.exe -L -o lib/main.dart https://docs.sheetjs.com/flutter/main.dart
```
:::
### Android
9) Start the Android emulator using the same instructions as Step 3.
@ -491,6 +600,40 @@ flutter run
The app fetches https://docs.sheetjs.com/pres.numbers, parses, converts data to
an array of arrays, and presents the data in a Flutter `Table` widget.
<details>
<summary><b>If emulator is not detected</b> (click to show)</summary>
In some test runs, `flutter run` did not automatically detect the emulator.
Run `flutter -v -d sheetjs run` and the command will fail. Inspect the output:
```text title="Command output"
// highlight-next-line
[ +6 ms] No supported devices found with name or id matching 'sheetjs'.
[ ] The following devices were found:
...
// highlight-next-line
[ +26 ms] sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator)
[ ] macOS (desktop) • macos • darwin-arm64 • macOS 13.5.1 22G90 darwin-arm64
...
```
Search the output for `sheetjs`. After that line, search for the emulator list.
One of the lines will correspond to the running emulator:
```
[ +26 ms] sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator)
^^^^^^^^^^^^^--- the second column is the name
```
The second column is the device name. Assuming the name is `emulator-5554`, run:
```bash
flutter -v -d emulator-5554 run
```
</details>
:::info pass
In some demo runs, the build failed with an Android SDK error:

@ -23,6 +23,10 @@ This demo uses SheetJS in Creative Suite extensions to import data from
spreadsheet files and export data to spreadsheets. We'll explore how to use
SheetJS scripts in extensions and programmatically interact with documents.
The InDesign demos translate between InDesign tables and workbooks.
![InDesign Table to Spreadsheet](pathname:///extendscript/indexport.png)
This demo explores three different JavaScript platforms supported in various
versions of Photoshop and InDesign:
@ -42,7 +46,7 @@ This demo was verified in the following deployments:
| App | Platform | Date |
|:----------|:-------------|:-----------|
| Photoshop | ExtendScript | 2024-03-12 |
| InDesign | ExtendScript | 2024-04-04 |
| InDesign | ExtendScript | 2024-08-12 |
| InDesign | CEP | 2024-03-12 |
| InDesign | UXP | 2024-03-11 |
@ -57,6 +61,16 @@ be included from a script in the same directory:
#include "xlsx.extendscript.js"
```
:::caution pass
ExtendScript is not performant. Even modest files may cause Adobe apps to crash.
On the [SheetJS chat](https://sheetjs.com/chat), a user presented a workaround
that uses [a precompiled command-line tool](/docs/demos/cli/) to process data
and pass JSON data back to ExtendScript.
:::
### Reading Files
The SheetJS `readFile`[^2] method can directly accept an absolute URI:
@ -403,7 +417,7 @@ const wb = XLSX.read(ab);
1) Download the following scripts:
<ul>
<li><a href="pathname:///extendscript/parse.idjs"><code>parse.idjs</code></a></li>
<li><a href="/extendscript/parse.idjs"><code>parse.idjs</code></a></li>
<li><a href={`https://cdn.sheetjs.com/xlsx-${current}/package/dist/xlsx.full.min.js`}><code>xlsx.full.min.js</code></a></li>
</ul>
@ -462,7 +476,7 @@ await file.write(buf, { data: storage.formats.binary });
1) Download the following scripts:
<ul>
<li><a href="pathname:///extendscript/write.idjs"><code>write.idjs</code></a></li>
<li><a href="/extendscript/write.idjs"><code>write.idjs</code></a></li>
<li><a href={`https://cdn.sheetjs.com/xlsx-${current}/package/dist/xlsx.full.min.js`}><code>xlsx.full.min.js</code></a></li>
</ul>

@ -3,7 +3,7 @@ title: Excel JavaScript API
pagination_prev: demos/cloud/index
pagination_next: demos/bigdata/index
sidebar_custom_props:
summary: Enhance data import functionality from Excel
summary: Add new data import functionality to Excel by integrating SheetJS in custom JavaScript user-defined functions and extensions.
---
import current from '/version.js';
@ -11,8 +11,10 @@ import CodeBlock from '@theme/CodeBlock';
:::info pass
This demo focuses on the JavaScript API included with Excel. For reading and
writing Excel files, [other demos](/docs/demos/) cover a wide variety of use cases
This demo focuses on the Excel JavaScript API.
For reading and writing Excel spreadsheets, [other demos](/docs/demos/) cover a
wide variety of use cases and deployments.
:::
@ -33,7 +35,7 @@ data into the worksheet.
:::note Tested Deployments
This demo was last tested on 2024 March 04 against Excel 365 (version 2402).
This demo was last tested on 2024 August 11 against Excel 365 (version 2407).
:::
@ -68,12 +70,31 @@ imported from scripts in an Excel Custom Functions project.
The [`sheet_to_json`](/docs/api/utilities/array#array-output) helper function
can generate arrays of arrays of values based on the worksheet data. Excel
custom functions transparently treat these as Dynamic Arrays.
custom functions transparently treat arrays of arrays as Dynamic Arrays.
This example fetches a file, parses the data, and extracts the first worksheet:
This example fetches a file using the `fetch` API, parses the binary data using
the SheetJS `read`[^1] method and returns data from the first worksheet.
```mermaid
flowchart LR
url[(Remote\nFile)]
ab[(File\nBytes)]
subgraph SheetJS Structures
wb(((SheetJS\nWorkbook)))
ws((SheetJS\nWorksheet))
end
aoo[[Array of\nObjects]]
xl>Excel\nWorksheet]
url --> |fetch\narrayBuffer| ab
ab --> |read\n\n| wb
wb --> |wb.Sheets\nselect sheet| ws
ws --> |sheet_to_json\n\n| aoo
aoo --> |return\nExcel| xl
linkStyle 1,2,3 color:blue,stroke:blue;
```
```js title="src\functions\functions.js"
var XLSX = require("xlsx");
const XLSX = require("xlsx");
/**
* Download file and write data
@ -90,11 +111,13 @@ export async function extern(url) {
const ab = await res.arrayBuffer();
/* Parse Data */
var wb = XLSX.read(ab);
const wb = XLSX.read(ab);
/* get and return data */
var ws = wb.Sheets[wb.SheetNames[0]]; // get first worksheet
var aoa = XLSX.utils.sheet_to_json(ws, { header: 1 }); // array of arrays
/* Translate Data */
const ws = wb.Sheets[wb.SheetNames[0]]; // get first worksheet
const aoa = XLSX.utils.sheet_to_json(ws, { header: 1 }); // array of arrays
/* Return Data */
return aoa;
} catch(e) { return [[e.message || e]]; } // pass error back to Excel
}
@ -160,8 +183,8 @@ npm run build
npm start
```
If prompted to `Allow localhost loopback for Microsoft Edge WebView`, type "N"
and press Enter.
If prompted to `Allow localhost loopback for Microsoft Edge WebView`, type
<kbd>N</kbd> and press Enter.
If prompted to install "Developer CA for Microsoft Office Add-ins" certificate,
select "Yes"
@ -235,7 +258,7 @@ npm start
```
14) In the new Excel window, enter the formula `=SHEETJS.VERSION()` in cell
`D1`. You should see something similar to the following screenshot:
`E1`. You should see something similar to the following screenshot:
![`SHEETJS.VERSION` output](pathname:///xlapi/xlvers.png)
@ -243,7 +266,7 @@ This indicates that the SheetJS library has been loaded.
### Fetching Files from the Internet
15) Add the following code snippet to `src\functions\functions.js`:
15) Add the following code snippet to `src\functions\functions.js` and save:
```js title="src\functions\functions.js (add to end)"
/**
@ -271,10 +294,15 @@ export async function extern(url) {
}
```
16) After making the change, save the files. Close the terminal window and the
Excel window (do not save the Excel file). Re-run `npm start`.
16) Close the terminal window and the Excel window (do not save the Excel file).
17) Enter the text `https://docs.sheetjs.com/pres.numbers` in cell `D1`. Enter
17) In the PowerShell window, start the development process again:
```bash
npm start
```
18) Enter the text `https://docs.sheetjs.com/pres.numbers` in cell `D1`. Enter
the formula `=SHEETJS.EXTERN(D1)` in cell `D2` and press Enter.
Excel should pull in the data and generate a dynamic array. The worksheet should
@ -283,6 +311,8 @@ match the screenshot at the top of this page.
:::tip pass
[SheetJS Pro](https://sheetjs.com/pro) offers additional features that can be
used in Excel Custom Functions and Add-ins
used in Excel Custom Functions and Add-ins.
:::
[^1]: See [`read` in "Reading Files"](/docs/api/parse-options)

@ -0,0 +1,35 @@
---
title: NodeJS CLI Tool
hide_table_of_contents: true
---
The SheetJS `xlsx-cli` NodeJS command-line tool converts data between common
formats. By default it displays data in CSV rows. The tool can read from and
write to any [supported file format](/docs/miscellany/formats).
The package is hosted on the [SheetJS CDN](https://cdn.sheetjs.com/xlsx-cli/).
## Usage
The package can be invoked with any standard package script runner.
### NodeJS
The package runner for `npm` is `npx`. The help command can be displayed with:
```bash
npx -p xlsx@https://cdn.sheetjs.com/xlsx-cli/xlsx-cli-1.1.4.tgz xlsx --help
```
### BunJS
Bun ships with the `bunx` test runner. The help message can be displayed with:
```bash
bunx -p xlsx@https://cdn.sheetjs.com/xlsx-cli/xlsx-cli-1.1.4.tgz --help
```
## Source Code
Source code and project documentation are hosted on the SheetJS git server at
https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/packages/xlsx-cli

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 76 KiB

@ -1,3 +1,5 @@
//const version = "0.20.2";
import { version } from "xlsx";
export default version;
export const xlsx_cli = "1.1.4";