From 7d749963f4e342786d48a30a4366dca5727d8461 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Sat, 22 Jun 2024 04:16:02 -0400 Subject: [PATCH] HTTP Downloads demo refresh --- docz/data/engines.js | 1 + docz/data/engines.xls | 8 +- docz/docs/03-demos/01-math/01-summary.md | 2 +- .../docs/03-demos/03-net/01-network/index.mdx | 143 +++++++++++++++--- docz/docs/03-demos/42-engines/02-v8.md | 10 ++ docz/docs/03-demos/42-engines/26-jurassic.md | 1 + 6 files changed, 135 insertions(+), 30 deletions(-) diff --git a/docz/data/engines.js b/docz/data/engines.js index 6640ceb..7290e52 100644 --- a/docz/data/engines.js +++ b/docz/data/engines.js @@ -16,6 +16,7 @@ const EngineData = () => {

The following bindings have been tested:

+

Asterisks (✱) in the Windows columns mark tests that were run in Windows Subsystem for Linux (WSL)

); }; export default EngineData; \ No newline at end of file diff --git a/docz/data/engines.xls b/docz/data/engines.xls index 3a03736..248cb36 100644 --- a/docz/data/engines.xls +++ b/docz/data/engines.xls @@ -182,8 +182,8 @@ C - - + + @@ -212,7 +212,7 @@ C# - + @@ -322,7 +322,7 @@ Java - + diff --git a/docz/docs/03-demos/01-math/01-summary.md b/docz/docs/03-demos/01-math/01-summary.md index c4240f0..423f8e4 100644 --- a/docz/docs/03-demos/01-math/01-summary.md +++ b/docz/docs/03-demos/01-math/01-summary.md @@ -40,7 +40,7 @@ This browser demo was tested in the following environments: | Browser | Date | |:------------|:-----------| -| Chrome 119 | 2024-01-06 | +| Chrome 126 | 2024-06-21 | | Safari 17.4 | 2024-06-20 | ::: diff --git a/docz/docs/03-demos/03-net/01-network/index.mdx b/docz/docs/03-demos/03-net/01-network/index.mdx index c987d63..e1f7838 100644 --- a/docz/docs/03-demos/03-net/01-network/index.mdx +++ b/docz/docs/03-demos/03-net/01-network/index.mdx @@ -11,10 +11,19 @@ pagination_next: demos/net/upload/index import current from '/version.js'; import CodeBlock from '@theme/CodeBlock'; -`XMLHttpRequest` and `fetch` browser APIs enable binary data transfer between -web browser clients and web servers. Since this library works in web browsers, -server conversion work can be offloaded to the client! This demo shows a few -common scenarios involving browser APIs and popular wrapper libraries. +[SheetJS](https://sheetjs.com) is a JavaScript library for reading and writing +data from spreadsheets. + +A number of JavaScript APIs, including `XMLHttpRequest` and `fetch`, allow +scripts to download spreadsheets for further processing. + +This demo uses various APIs and wrapper libraries to download workbooks and pass +raw binary data to SheetJS libraries. + +- ["Browser Demos"](#browser-demos) run entirely within the web browser. A test + workbook will be downloaded and parsed in the web browser. + +- ["NodeJS Demos"](#nodejs-demos) run in NodeJS and other server-side platforms. :::info pass @@ -36,7 +45,7 @@ functions functions can send files to clients. ::: -## Downloading Binary Data +## Binary Data Most interesting spreadsheet files are binary data that contain byte sequences that represent invalid UTF-8 characters. @@ -374,7 +383,7 @@ The `https` module provides a low-level `get` method for HTTPS GET requests: ```js title="SheetJSHTTPSGet.js" var https = require("https"), XLSX = require("xlsx"); -https.get('https://docs.sheetjs.com/pres.numbers', function(res) { +https.get('https://docs.sheetjs.com/pres.xlsx', function(res) { var bufs = []; res.on('data', function(chunk) { bufs.push(chunk); }); res.on('end', function() { @@ -387,15 +396,36 @@ https.get('https://docs.sheetjs.com/pres.numbers', function(res) { }); ``` -
- Complete Example (click to show) +:::note Tested Deployments -:::note Tested Environments +This demo was tested in the following environments: -This demo was last tested on 2024 January 15 against NodeJS `20.11.0` +| NodeJS | Date | Workarounds | +|:-----------|:-----------|:-------------------------------| +| `0.10.48` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `0.12.18` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `4.9.1` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `6.17.1` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `8.17.0` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `10.24.1` | 2024-06-21 | | +| `12.22.12` | 2024-06-21 | | +| `14.21.3` | 2024-06-21 | | +| `16.20.2` | 2024-06-21 | | +| `18.20.3` | 2024-06-21 | | +| `20.15.0` | 2024-06-21 | | +| `22.3.0` | 2024-06-21 | | + +The `NODE_TLS_REJECT_UNAUTHORIZED` workaround sets the value to `'0'`: + +```js title="Legacy NodeJS Certificate has Expired Bypass (prepend to script)" +process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; +``` ::: +
+ Complete Example (click to show) + 1) Install the [NodeJS module](/docs/getting-started/installation/nodejs) {`\ @@ -412,11 +442,24 @@ node SheetJSHTTPSGet.js If successful, the script will print CSV contents of the test file. +:::caution pass + +For older versions of NodeJS, the script will fail due to a certificate error. +The error can be suppressed by prepending the following line to the script: + +```js title="SheetJSHTTPSGet.js (add to top)" +process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; +``` + +**It is strongly encouraged to upgrade to a newer NodeJS version!** + +::: +
### fetch -:::caution pass +:::info pass Experimental support for `fetch` was introduced in NodeJS `16.15.0`. It will be considered stable in NodeJS LTS version `22`. @@ -435,15 +478,21 @@ async function parse_from_url(url) { } ``` -
- Complete Example (click to show) +:::note Tested Deployments -:::note Tested Environments +This demo was tested in the following environments: -This demo was last tested on 2024 January 15 against NodeJS `20.11.0` +| NodeJS | Date | +|:-----------|:-----------| +| `18.20.3` | 2024-06-21 | +| `20.15.0` | 2024-06-21 | +| `22.3.0` | 2024-06-21 | ::: +
+ Complete Example (click to show) + 1) Install the [NodeJS module](/docs/getting-started/installation/nodejs) {`\ @@ -498,7 +547,7 @@ Setting the option `encoding: null` passes raw buffers: ```js title="SheetJSRequest.js" var XLSX = require('xlsx'), request = require('request'); -var url = 'https://docs.sheetjs.com/pres.numbers'; +var url = 'https://docs.sheetjs.com/pres.xlsx'; /* call `request` with the option `encoding: null` */ // highlight-next-line @@ -515,15 +564,36 @@ request(url, {encoding: null}, function(err, res, data) { }); ``` -
- Complete Example (click to show) +:::note Tested Deployments -:::note Tested Environments +This demo was tested in the following environments: -This demo was last tested on 2024 January 15 against request `2.88.2` +| NodeJS | Date | Workarounds | +|:-----------|:-----------|:-------------------------------| +| `0.10.48` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `0.12.18` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `4.9.1` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `6.17.1` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `8.17.0` | 2024-06-21 | `NODE_TLS_REJECT_UNAUTHORIZED` | +| `10.24.1` | 2024-06-21 | | +| `12.22.12` | 2024-06-21 | | +| `14.21.3` | 2024-06-21 | | +| `16.20.2` | 2024-06-21 | | +| `18.20.3` | 2024-06-21 | | +| `20.15.0` | 2024-06-21 | | +| `22.3.0` | 2024-06-21 | | + +The `NODE_TLS_REJECT_UNAUTHORIZED` workaround sets the value to `'0'`: + +```js title="Legacy NodeJS Certificate has Expired Bypass (prepend to script)" +process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; +``` ::: +
+ Complete Example (click to show) + 1) Install the [NodeJS module](/docs/getting-started/installation/nodejs) {`\ @@ -540,6 +610,19 @@ node SheetJSRequest.js If successful, the script will print CSV contents of the test file. +:::caution pass + +For older versions of NodeJS, the script will fail due to a certificate error. +The error can be suppressed by prepending the following line to the script: + +```js title="SheetJSRequest.js (add to top)" +process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; +``` + +**It is strongly encouraged to upgrade to a newer NodeJS version!** + +::: +
#### axios @@ -558,19 +641,29 @@ async function workbook_dl_axios(url) { } ``` -
- Complete Example (click to show) +:::note Tested Deployments -:::note Tested Environments +This demo was tested in the following environments: -This demo was last tested on 2024 January 15 against Axios `1.6.5` +| NodeJS | Axios | Date | +|:-----------|:-------|:-----------| +| `10.24.1` | 0.28.1 | 2024-06-21 | +| `12.22.12` | 1.7.2 | 2024-06-21 | +| `14.21.3` | 1.7.2 | 2024-06-21 | +| `16.20.2` | 1.7.2 | 2024-06-21 | +| `18.20.3` | 1.7.2 | 2024-06-21 | +| `20.15.0` | 1.7.2 | 2024-06-21 | +| `22.3.0` | 1.7.2 | 2024-06-21 | ::: +
+ Complete Example (click to show) + 1) Install the [NodeJS module](/docs/getting-started/installation/nodejs) {`\ -npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz axios@1.6.5`} +npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz axios@1.7.2`} 2) Save the following to `SheetJSAxios.js`: diff --git a/docz/docs/03-demos/42-engines/02-v8.md b/docz/docs/03-demos/42-engines/02-v8.md index 3cdb4b3..83095d7 100644 --- a/docz/docs/03-demos/42-engines/02-v8.md +++ b/docz/docs/03-demos/42-engines/02-v8.md @@ -992,6 +992,7 @@ This demo was last tested in the following deployments: |:-------------|:--------------|:--------|:----------|:-----------| | `darwin-x64` | `12.6.228.13` | `3.1.3` | `22` | 2024-06-19 | | `darwin-arm` | `12.6.228.13` | `3.1.3` | `11.0.23` | 2024-06-19 | +| `win10-x64` | `12.6.228.13` | `3.1.3` | `11.0.16` | 2024-06-21 | | `linux-x64` | `12.6.228.13` | `3.1.3` | `17.0.7` | 2024-06-20 | | `linux-arm` | `12.6.228.13` | `3.1.3` | `17.0.11` | 2024-06-20 | @@ -1043,6 +1044,10 @@ curl -LO https://repo1.maven.org/maven2/com/caoccao/javet/javet-linux-arm64/3.1. +```bash +curl -LO https://repo1.maven.org/maven2/com/caoccao/javet/javet/3.1.3/javet-3.1.3.jar +``` + @@ -1108,6 +1113,11 @@ java -cp ".:javet-linux-arm64-3.1.3.jar" SheetJSJavet pres.xlsx +```bash +javac -cp ".;javet-3.1.3.jar" SheetJSJavet.java +java -cp ".;javet-3.1.3.jar" SheetJSJavet pres.xlsx +``` + diff --git a/docz/docs/03-demos/42-engines/26-jurassic.md b/docz/docs/03-demos/42-engines/26-jurassic.md index 53d8c92..92a7c7f 100644 --- a/docz/docs/03-demos/42-engines/26-jurassic.md +++ b/docz/docs/03-demos/42-engines/26-jurassic.md @@ -178,6 +178,7 @@ This demo was tested in the following deployments: |:-------------|:---------|:-----------| | `darwin-x64` | `3.2.7` | 2024-06-15 | | `darwin-arm` | `3.2.7` | 2024-06-15 | +| `win10-x64` | `3.2.7` | 2024-06-21 | | `linux-x64` | `3.2.7` | 2024-06-20 | | `linux-arm` | `3.2.7` | 2024-06-20 |