This commit is contained in:
SheetJS 2022-11-07 05:41:00 -05:00
parent f2b446f631
commit b01bf3873c
11 changed files with 38 additions and 115 deletions

@ -79,7 +79,7 @@ npx browserify xlsxworker.js > worker.js
npx http-server
```
5) Access the site <http://localhost:8080/> and use the file input element to
5) Access the site http://localhost:8080/ and use the file input element to
select a spreadsheet.
</details>

@ -220,8 +220,7 @@ const { webkit } = require('playwright'); // import desired browser
## PhantomJS
PhantomJS is a headless web browser powered by WebKit. Standalone binaries are
available at <https://phantomjs.org/download.html>
PhantomJS is a headless web browser powered by WebKit.
:::warning

@ -14,7 +14,7 @@ const XLSX = require("xlsx");
(async() => {
/* Download Data */
const f = await fetch("https://sheetjs.com/pres.xlsx");
const f = await fetch("https://docs.sheetjs.com/pres.xlsx");
const data = await f.arrayBuffer();
/* Parse workbook */
@ -62,69 +62,7 @@ cannot access private repositories.
Any publicly available spreadsheet can be a valid data source. The process will
fetch the data on specified intervals or events.
This demo endpoint <https://livesheet.deno.dev/> generates XLSX files.
<details><summary><b>Server Details</b> (click to show)</summary>
This demo is hosted on Deno Deploy.
```ts
// @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts"
import { utils, writeXLSX } from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs';
import * as Drash from "https://deno.land/x/drash@v2.5.4/mod.ts";
const rand = (x:number, n = 10): number => ((x + n * (Math.random() - 0.5) + 10)|0)%10;
class HomeResource extends Drash.Resource {
public paths = ["/"];
// see https://github.com/drashland/drash/issues/194
public OPTIONS(request: Drash.Request, response: Drash.Response) {
const allHttpMethods: string[] = [ "GET", "POST", "PUT", "DELETE" ];
response.headers.set("Allow", allHttpMethods.join()); // Use this
response.headers.set("Access-Control-Allow-Methods", allHttpMethods.join()); // or this
response.headers.set("access-control-allow-origin", "*");
response.status_code = 204;
return response;
}
public GET(request: Drash.Request, response: Drash.Response): void {
// create a workbook with some random data
let data: any[][] = [ "ABCDEFG".split("") ];
for(let i = 0; i < 10; ++i) data = data.concat([
[5,4,3,3,7,9,5].map(v => rand(v)),
[5,4,3,3,7,9,5].map(v => rand(v, 8)),
[5,4,3,3,7,9,5].map(v => rand(v, 6)),
[5,4,3,3,7,9,5].map(v => rand(v, 4)),
[5,4,3,3,7,9,5].map(v => rand(v, 2)),
[5,4,3,3,7,9,5].map(v => rand(v, 0))
]);
const ws = utils.aoa_to_sheet(data);
const wb = utils.book_new(); utils.book_append_sheet(wb, ws, "data");
// write the workbook to XLSX as a Uint8Array
const file = writeXLSX(wb, { type: "buffer"});
// set headers
response.headers.set("Content-Disposition", 'attachment; filename="LiveSheet.xlsx"');
// send data
return response.send("application/vnd.ms-excel", file);
}
}
// Create and run your server
const server = new Drash.Server({
hostname: "",
port: 3000,
protocol: "http",
resources: [ HomeResource ],
});
server.run();
console.log(`Server running at ${server.address}.`);
```
</details>
For this demo, <https://docs.sheetjs.com/pres.xlsx> will be used.
### Action
@ -135,7 +73,7 @@ The `githubocto/flat` action can be added as a step in a workflow:
- name: Fetch data
uses: githubocto/flat@v3
with:
http_url: https://livesheet.deno.dev/
http_url: https://docs.sheetjs.com/pres.xlsx
downloaded_filename: data.xlsx
postprocess: ./postprocess.ts
```
@ -144,7 +82,7 @@ The `http_url` will be fetched and saved to `downloaded_filename` in the repo.
This can be approximated with the following command:
```bash
curl -L -o data.xlsx https://livesheet.deno.dev/
curl -L -o data.xlsx https://docs.sheetjs.com/pres.xlsx
```
After saving, the `postprocess` script will be run. When a `.ts` file is the
@ -175,8 +113,7 @@ releases, the examples import from the SheetJS CDN:
import * as XLSX from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs';
```
The official registry endpoint <https://deno.land/x/sheetjs> is out of date.
This is a known registry bug.
The official Deno registry is out of date. This is a known registry bug.
:::
@ -293,7 +230,7 @@ jobs:
- name: Fetch data
uses: githubocto/flat@v3
with:
http_url: https://livesheet.deno.dev/
http_url: https://docs.sheetjs.com/pres.xlsx
downloaded_filename: data.xlsx
postprocess: ./postprocess.ts
```

@ -393,7 +393,7 @@ evt.respondWith(new Response(buf, {
<details><summary><b>Complete Example</b> (click to show)</summary>
Save the following script to `deno.ts` and run with `deno run -A deno.ts`. Open
a web browser and access <http://localhost:7262> to download the workbook.
a web browser and access `http://localhost:7262/` to download the workbook.
```ts title="deno.ts"
// @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts"
@ -447,7 +447,7 @@ return new Response(buf, {
Download [`xlsx.mjs`](https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs).
Save the following script to `bun.js` and run with `bun bun.js`. Open a web
browser and access <http://localhost:7262> to download the exported workbook.
browser and access `http://localhost:7262/` to download the exported workbook.
```js title="bun.js"
import * as XLSX from "./xlsx.mjs";
@ -841,5 +841,3 @@ Readable Stream.
- `XLSX.stream.to_json` is the streaming version of `XLSX.utils.sheet_to_json`.
Examples are included in ["Large Datasets"](/docs/demos/stream#streaming-write)
<https://sheetaki.now.sh/> pipes write streams to nodejs response.

@ -258,6 +258,6 @@ worksheet. The supported codes are a subset of the Word RTF support.
#### Ethercalc Record Format (ETH)
[Ethercalc](https://ethercalc.net/) is an open source web spreadsheet powered by
a record format reminiscent of SYLK wrapped in a MIME multi-part message.
Ethercalc was an open source web spreadsheet powered by a record format
reminiscent of SYLK wrapped in a MIME multi-part message.

@ -179,14 +179,13 @@ contexts, freeing up the renderer to update.
#### Strange exported file names in the web browser
JS and the DOM API do not have a standard approach for creating files. There was
a [`saveAs` proposal](https://www.w3.org/TR/2014/NOTE-file-writer-api-20140424/)
but it was abandoned in 2014.
a `saveAs` proposal as part of "File API: Writer" but it was abandoned in 2014.
The library integrates a number of platform-specific techniques for different
environments. In modern web browsers, the library uses the `download` attribute.
Third party libraries like [FileSaver](https://github.com/eligrey/FileSaver.js/)
provide an implementation of `saveAs` and may help in some cases.
Third party libraries like `FileSaver.js` provide an implementation of `saveAs`
that include more browser-specific workarounds.
<details><summary><b>FileSaver.js integration</b> (click to show)</summary>

@ -6,14 +6,4 @@ hide_table_of_contents: true
The official source code repository is <https://git.sheetjs.com/sheetjs/sheetjs>
:::note Mirrors
Older snapshots of the source code repository are available at various hosts:
- [GitHub](https://github.com/sheetjs/sheetjs)
- [GitLab](https://gitlab.com/sheetjs/sheetjs)
- [BitBucket](https://bitbucket.org/sheetjs/sheetjs)
<https://git.sheetjs.com/sheetjs/sheetjs> is the authoritative repository.
:::
Issues should be raised at <https://git.sheetjs.com/sheetjs/sheetjs/issues>

@ -75,15 +75,24 @@ ExtendScript Toolkit 3.5 is available as a standalone download for Windows.
<details>
<summary>(click to show)</summary>
- NodeJS `0.8`, `0.10`, `0.12`, `4.x`, `5.x`, `6.x`, `7.x`, `8.x`
**Browsers**
- IE 6/7/8/9/10/11 (IE 6-9 require shims)
- Chrome 24+ (including Android 4.0+)
- Safari 6+ (iOS and Desktop)
- Edge 13+, FF 18+, and Opera 12+
- Chrome 26+ (including Android 6.0+)
- Safari 8+ (Desktop) and Safari 10+ (iOS)
- Edge 13-18 and 79+
- FF Latest
Tests utilize the mocha testing framework.
The automated browser tests seek to test the latest patch version of each major
release of Chromium ending in `0` (starting from Chrome 30).
- <https://saucelabs.com/u/sheetjs> for XLS\* modules using Sauce Labs
Edge originally was an independent browser, becoming a Chromium fork in version
79. Since the new releases should be nearly identical to the Chrome counterpart,
the Edge tests are run on major releases ending in `5` (starting from Edge 85).
**Server Runtimes**
- NodeJS `0.8`, `0.10`, `0.12`, and every major version starting from `4`
- io.js 1/2/3
- Deno latest
The test suite also includes tests for various time zones. To change
the timezone locally, set the `TZ` environment variable:
@ -99,13 +108,5 @@ $ env TZ="Asia/Kolkata" WTF=1 make test_misc
Test files are housed in [another repo](https://github.com/SheetJS/test_files).
Running `make init` will refresh the `test_files` submodule and get the files.
Note that this requires `svn`, `git`, `hg` and other commands that may not be
available. If `make init` fails, please download the latest version of the test
files snapshot from [the repo](https://github.com/SheetJS/test_files/releases)
#### Latest Snapshot
<https://github.com/SheetJS/test_files/releases/download/20170409/test_files.zip>
(download and unzip to the `test_files` subfolder)
[The "OS-Specific Setup"](/docs/miscellany/contributing#os-specific-setup)
includes notes for installing the required dependencies.

@ -62,8 +62,7 @@ sudo npm i -g n
sudo n 16
```
3) Follow <https://github.com/paul-nelson-baker/git-openssl-shellscript> to
build and install a version of Git with proper SSL support:
3) Build and install a version of Git with proper SSL support:
```bash
# Git does not support OpenSSL out of the box, must do this
@ -88,13 +87,13 @@ On Linux:
sudo apt-get install mercurial subversion
```
On MacOS, install using [`brew`](https://brew.sh/):
On MacOS, install using Homebrew:
```bash
brew install mercurial subversion
```
NodeJS installers can be found at <https://nodejs.org/en/download/>
NodeJS installers can be found at the project homepage.
1) Install NodeJS modules for building the scripts

@ -80,7 +80,7 @@ const config = {
position: 'right',
},
{
href: 'https://docs.sheetjs.com/docs/miscellany/source/',
href: 'https://git.sheetjs.com/sheetjs/sheetjs',
label: 'Source',
position: 'right',
},
@ -132,7 +132,7 @@ const config = {
},
{
label: 'Source',
href: 'https://docs.sheetjs.com/docs/miscellany/source/',
href: 'https://git.sheetjs.com/sheetjs/sheetjs',
},
],
},

BIN
docz/static/pres.xlsx Normal file

Binary file not shown.