From e2c377d20835f2545da8b380c1a73bdd6cae5642 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Mon, 25 Jul 2022 19:18:00 -0400 Subject: [PATCH] cmds --- docz/docs/02-installation/01-standalone.mdx | 10 ++++ docz/docs/02-installation/02-frameworks.md | 40 ++++++++++++++-- docz/docs/02-installation/04-nodejs.md | 46 ++++++++++++++++--- .../04-getting-started/03-demos/09-bundler.md | 36 +++++++-------- .../03-demos/10-database.md | 36 +++++++++++++++ .../docs/04-getting-started/03-demos/index.md | 3 +- docz/docs/08-api/07-write-options.md | 4 +- docz/docs/09-miscellany/05-contributing.md | 2 +- 8 files changed, 146 insertions(+), 31 deletions(-) diff --git a/docz/docs/02-installation/01-standalone.mdx b/docz/docs/02-installation/01-standalone.mdx index d0a7aff..1091172 100644 --- a/docz/docs/02-installation/01-standalone.mdx +++ b/docz/docs/02-installation/01-standalone.mdx @@ -24,6 +24,16 @@ The `latest` tag references the latest version and updates with each release: ``` +:::warning + +A number of CDNs host older versions of the SheetJS libraries. Due to syncing +issues, they are generally out of date. + +They are known CDN bugs. + + is the authoritative source for SheetJS modules. + +::: ## Browser Scripts diff --git a/docz/docs/02-installation/02-frameworks.md b/docz/docs/02-installation/02-frameworks.md index f97625e..720fc51 100644 --- a/docz/docs/02-installation/02-frameworks.md +++ b/docz/docs/02-installation/02-frameworks.md @@ -18,17 +18,17 @@ proper ECMAScript Module release which can be optimized with developer tools.
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
@@ -39,6 +39,40 @@ Once installed, the library can be imported under the name `xlsx`: import { read, writeFileXLSX } from "xlsx"; ``` +:::warning + +Older releases are technically available on the public npm registry as `xlsx`, +but the registry is out of date. The latest version on that registry is 0.18.5 + +This is a known registry bug + + is the authoritative source for SheetJS scripts. + +For existing projects, the easiest approach is to uninstall and reinstall: + + + +
{`\
+$ npm rm --save xlsx
+$ npm i --save file:vendor/xlsx-${current}.tgz`}
+
+
+ +
{`\
+$ pnpm rm xlsx
+$ pnpm install file:vendor/xlsx-${current}.tgz`}
+
+
+ +
{`\
+$ yarn remove xlsx
+$ yarn add file:vendor/xlsx-${current}.tgz`}
+
+
+
+ +::: + ## XLS Support If XLS support is required, `cpexcel.full.mjs` must be manually imported: diff --git a/docz/docs/02-installation/04-nodejs.md b/docz/docs/02-installation/04-nodejs.md index c4e659c..6c9cdd4 100644 --- a/docz/docs/02-installation/04-nodejs.md +++ b/docz/docs/02-installation/04-nodejs.md @@ -23,21 +23,55 @@ Tarballs can be directly installed using a package manager:
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
+:::warning + +Older releases are technically available on the public npm registry as `xlsx`, +but the registry is out of date. The latest version on that registry is 0.18.5 + +This is a known registry bug + + is the authoritative source for SheetJS scripts. + +For existing projects, the easiest approach is to uninstall and reinstall: + + + +
{`\
+$ npm rm --save xlsx
+$ npm i --save file:vendor/xlsx-${current}.tgz`}
+
+
+ +
{`\
+$ pnpm rm xlsx
+$ pnpm install file:vendor/xlsx-${current}.tgz`}
+
+
+ +
{`\
+$ yarn remove xlsx
+$ yarn add file:vendor/xlsx-${current}.tgz`}
+
+
+
+ +::: + ### Vendoring For general stability, "vendoring" modules is the recommended approach: @@ -53,17 +87,17 @@ For general stability, "vendoring" modules is the recommended approach:
{`\
-$ npm install --save file:vendor/xlsx-${current}.tgz`}
+$ npm i --save file:vendor/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save file:vendor/xlsx-${current}.tgz`}
+$ pnpm install file:vendor/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save file:vendor/xlsx-${current}.tgz`}
+$ yarn add  file:vendor/xlsx-${current}.tgz`}
 
diff --git a/docz/docs/04-getting-started/03-demos/09-bundler.md b/docz/docs/04-getting-started/03-demos/09-bundler.md index 10445a0..c2c0baf 100644 --- a/docz/docs/04-getting-started/03-demos/09-bundler.md +++ b/docz/docs/04-getting-started/03-demos/09-bundler.md @@ -46,17 +46,17 @@ Web Worker scripts can be bundled using the same approach.
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
@@ -98,17 +98,17 @@ local testing, a bundled script can save tens of milliseconds per run.
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
@@ -186,17 +186,17 @@ Both the `node` and `browser` platforms work out of the box.
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
@@ -264,17 +264,17 @@ npx http-server .
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
@@ -405,17 +405,17 @@ document.getElementById("xport").onclick = async() => {
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
@@ -442,17 +442,17 @@ Snowpack works with no caveats.
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ pnpm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ pnpm install https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
{`\
-$ yarn add --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ yarn add https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
diff --git a/docz/docs/04-getting-started/03-demos/10-database.md b/docz/docs/04-getting-started/03-demos/10-database.md index 3b1b6d1..1919cf3 100644 --- a/docz/docs/04-getting-started/03-demos/10-database.md +++ b/docz/docs/04-getting-started/03-demos/10-database.md @@ -224,6 +224,42 @@ function SheetJSQLWriter() { } ``` +### DSV Interchange + +Many databases offer utilities for reading and writing CSV, pipe-separated +documents, and other simple data files. They enable workflows where the library +generates CSV data for the database to process or where the library parses CSV +files created by the database. + +#### Worksheets to CSVs + +CSV data can be generated from worksheets using `XLSX.utils.sheet_to_csv`. + +```js +// starting from a worksheet object +const csv = XLSX.utils.sheet_to_json(ws); + +// whole workbook conversion +const csv_arr = wb.SheetNames.map(n => XLSX.utils.sheet_to_json(wb.Sheets[n])); +``` + +#### CSVs to Worksheets + +`XLSX.read` can read strings with CSV data. It will generate single-sheet +workbooks with worksheet name `Sheet1`. + +Where supported, `XLSX.readFile` can read files. + +```js +// starting from a CSV string +const ws_str = XLSX.read(csv_str, {type: "string"}).Sheets.Sheet1; + +// starting from a CSV binary string (e.g. `FileReader#readAsBinaryString`) +const ws_bstr = XLSX.read(csv_bstr, {type: "binary"}).Sheets.Sheet1; + +// starting from a CSV file in NodeJS or Bun or Deno +const ws_file = XLSX.readFile("test.csv").Sheets.Sheet1; +``` ## Databases diff --git a/docz/docs/04-getting-started/03-demos/index.md b/docz/docs/04-getting-started/03-demos/index.md index 146a4e6..3648d1b 100644 --- a/docz/docs/04-getting-started/03-demos/index.md +++ b/docz/docs/04-getting-started/03-demos/index.md @@ -48,7 +48,8 @@ The demo projects include small runnable examples and short explainers. - [`Other JavaScript Engines`](https://github.com/SheetJS/SheetJS/tree/master/demos/altjs/) - [`"serverless" functions`](https://github.com/SheetJS/SheetJS/tree/master/demos/function/) - [`sqlite3`](./database#sqlite) -- [`Databases and Key/Value Stores`](https://github.com/SheetJS/SheetJS/tree/master/demos/database/) +- [`Databases and Structured Data Stores`](./database) +- [`NoSQL, K/V, and Unstructured Data Stores`](./nosql) - [`Legacy Internet Explorer`](https://github.com/SheetJS/SheetJS/tree/master/demos/oldie/) ### Bundlers and Tooling diff --git a/docz/docs/08-api/07-write-options.md b/docz/docs/08-api/07-write-options.md index 5ff256f..3b91b7c 100644 --- a/docz/docs/08-api/07-write-options.md +++ b/docz/docs/08-api/07-write-options.md @@ -89,7 +89,7 @@ XLSX.writeFile(wb, "textport.numbers", {numbers: XLSX_ZAHL_PAYLOAD, compression: After installing the package:
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
The scripts will be available at `xlsx/dist/xlsx.zahl` (CommonJS) and @@ -113,7 +113,7 @@ XLSX.writeFile(wb, "textport.numbers", {numbers: XLSX_ZAHL_PAYLOAD, compression: After installing the package:
{`\
-$ npm install --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
+$ npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz`}
 
The scripts will be available at `xlsx/dist/xlsx.zahl` (CommonJS) and diff --git a/docz/docs/09-miscellany/05-contributing.md b/docz/docs/09-miscellany/05-contributing.md index 9ee4992..45cdac6 100644 --- a/docz/docs/09-miscellany/05-contributing.md +++ b/docz/docs/09-miscellany/05-contributing.md @@ -106,7 +106,7 @@ NodeJS installers can be found at npm install # Install global dependencies -sudo npm install -g mocha@2.5.3 voc @sheetjs/uglify-js +sudo npm i -g mocha@2.5.3 voc @sheetjs/uglify-js ``` 2) Initialize the test files: