From d55b7a306392bb4131ca5a41cc2fbea54c3e5a77 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Sun, 31 Jul 2022 19:48:02 -0400 Subject: [PATCH] numbers OperationStorage iwa warning --- bits/40_harb.js | 6 ++ bits/83_numbers.js | 2 + demos/README.md | 25 +++-- demos/deno/.gitignore | 1 - demos/deno/Makefile | 24 ----- demos/deno/README.md | 89 ++-------------- demos/deno/doit.ts | 43 -------- demos/deno/mjs.ts | 6 -- demos/deno/node.ts | 6 -- demos/deno/sheet2csv.ts | 21 ---- demos/deno/stream.ts | 32 ------ demos/deno/x.ts | 5 - demos/knockout/README.md | 67 +----------- demos/knockout/index.html | 109 -------------------- demos/knockout/shim.js | 1 - demos/knockout/xlsx.full.min.js | 1 - demos/requirejs/.gitignore | 4 - demos/requirejs/Makefile | 10 -- demos/requirejs/README.md | 64 +----------- demos/requirejs/app.js | 147 --------------------------- demos/requirejs/browser.html | 68 ------------- demos/requirejs/build.js | 9 -- demos/requirejs/optimizer.html | 58 ----------- demos/rollup/Makefile | 23 ----- demos/rollup/README.md | 43 +------- demos/rollup/app.js | 146 -------------------------- demos/rollup/main.js | 3 - demos/rollup/rollup.config.js | 16 --- demos/rollup/rollup.config.node.js | 16 --- demos/rollup/rollup.config.worker.js | 16 --- demos/rollup/rollup.html | 50 --------- demos/rollup/xlsxworker.js | 11 -- modules/83_numbers.js | 2 + modules/83_numbers.ts | 1 + 34 files changed, 39 insertions(+), 1086 deletions(-) delete mode 100644 demos/deno/.gitignore delete mode 100644 demos/deno/Makefile delete mode 100644 demos/deno/doit.ts delete mode 100644 demos/deno/mjs.ts delete mode 100644 demos/deno/node.ts delete mode 100644 demos/deno/sheet2csv.ts delete mode 100644 demos/deno/stream.ts delete mode 100644 demos/deno/x.ts delete mode 100644 demos/knockout/index.html delete mode 120000 demos/knockout/shim.js delete mode 120000 demos/knockout/xlsx.full.min.js delete mode 100644 demos/requirejs/.gitignore delete mode 100644 demos/requirejs/Makefile delete mode 100644 demos/requirejs/app.js delete mode 100644 demos/requirejs/browser.html delete mode 100644 demos/requirejs/build.js delete mode 100644 demos/requirejs/optimizer.html delete mode 100644 demos/rollup/Makefile delete mode 100644 demos/rollup/app.js delete mode 100644 demos/rollup/main.js delete mode 100644 demos/rollup/rollup.config.js delete mode 100644 demos/rollup/rollup.config.node.js delete mode 100644 demos/rollup/rollup.config.worker.js delete mode 100644 demos/rollup/rollup.html delete mode 100644 demos/rollup/xlsxworker.js diff --git a/bits/40_harb.js b/bits/40_harb.js index c3cffd7..6b85b7e 100644 --- a/bits/40_harb.js +++ b/bits/40_harb.js @@ -443,6 +443,8 @@ var SYLK = /*#__PURE__*/(function() { } wb.Workbook.Names.push(nn); } break; + // case 'NE': // ?? + // case 'NU': // ?? case 'C': /* cell */ var C_seen_K = false, C_seen_X = false, C_seen_S = false, C_seen_E = false, _R = -1, _C = -1, formula = "", cell_t = "z"; for(rj=1; rj 0) { rowinfo[R].hpt = Mval; rowinfo[R].hpx = pt2px(Mval); } else if(Mval === 0) rowinfo[R].hidden = true; break; + // case 'K': // ?? + // case 'E': // ?? default: if(opts && opts.WTF) throw new Error("SYLK bad record " + rstr); } if(F_seen < 1) next_cell_format = null; break; diff --git a/bits/83_numbers.js b/bits/83_numbers.js index 06a0b9d..bdafa36 100644 --- a/bits/83_numbers.js +++ b/bits/83_numbers.js @@ -827,6 +827,8 @@ function parse_numbers_iwa(cfb, opts) { cfb.FileIndex.forEach(function(s) { if (!s.name.match(/\.iwa$/)) return; + if (s.content[0] == 98) + return; var o; try { o = decompress_iwa_file(s.content); diff --git a/demos/README.md b/demos/README.md index 0882765..d2786b5 100644 --- a/demos/README.md +++ b/demos/README.md @@ -26,12 +26,12 @@ can be installed with Bash on Windows or with `cygwin`. - [`IndexedDB`](https://docs.sheetjs.com/docs/getting-started/demos/database#indexeddb) **Frameworks** -- [`angularjs`](angular/) -- [`angular and ionic`](angular2/) -- [`knockout`](knockout/) -- [`meteor`](meteor/) -- [`react, react-native, next`](react/) -- [`vue 2.x, weex, nuxt`](vue/) +- [`Angular.JS`](angular/) +- [`Angular 2+ and Ionic`](angular2/) +- [`Knockout`](https://docs.sheetjs.com/docs/getting-started/demos/legacy#knockoutjs) +- [`Meteor`](meteor/) +- [`React, React Native and NextJS`](react/) +- [`VueJS, WeeX and NuxtJS`](vue/) **Front-End UI Components** - [`canvas-datagrid`](datagrid/) @@ -42,16 +42,16 @@ can be installed with Bash on Windows or with `cygwin`. **Platforms and Integrations** - [`NodeJS Server-Side Processing`](server/) - [`Deno`](deno/) -- [`electron application`](electron/) +- [`Electron`](electron/) - [`NW.js`](nwjs/) -- [`Chrome / Chromium extensions`](chrome/) +- [`Chrome / Chromium Extension`](chrome/) - [`Google Sheets API`](https://docs.sheetjs.com/docs/getting-started/demos/gsheet) - [`ExtendScript for Adobe Apps`](https://docs.sheetjs.com/docs/getting-started/demos/extendscript) - [`NetSuite SuiteScript`](https://docs.sheetjs.com/docs/getting-started/demos/netsuite) - [`SalesForce Lightning Web Components`](https://docs.sheetjs.com/docs/getting-started/demos/salesforce) - [`Excel JavaScript API`](https://docs.sheetjs.com/docs/getting-started/demos/excel) - [`Headless Automation`](https://docs.sheetjs.com/docs/getting-started/demos/headless) -- [`Swift JSC and other engines`](altjs/) +- [`Swift JSC and Other JavaScript Engines`](altjs/) - [`"serverless" functions`](function/) - [`databases and key/value stores`](database/) - [`Databases and Structured Data Stores`](https://docs.sheetjs.com/docs/getting-started/demos/database) @@ -63,12 +63,15 @@ can be installed with Bash on Windows or with `cygwin`. - [`bun`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#bun) - [`esbuild`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#esbuild) - [`parcel`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#parcel) -- [`requirejs`](requirejs/) -- [`rollup`](rollup/) +- [`requirejs`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#requirejs) +- [`rollup`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#rollup) - [`snowpack`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#snowpack) +- [`swc`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#swc) - [`systemjs`](systemjs/) - [`typescript`](typescript/) +- [`vite`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#vite) - [`webpack 2.x`](webpack/) +- [`wmr`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#wmr) Other examples are included in the [showcase](demos/showcase/). diff --git a/demos/deno/.gitignore b/demos/deno/.gitignore deleted file mode 100644 index 8d4c030..0000000 --- a/demos/deno/.gitignore +++ /dev/null @@ -1 +0,0 @@ -sheet2csv diff --git a/demos/deno/Makefile b/demos/deno/Makefile deleted file mode 100644 index 66a2fc9..0000000 --- a/demos/deno/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TESTS= x mjs -UNSTABLE= node -TEST_FILES=number_format_greek.xls - -.PHONY: test -test: $(UNSTABLE) $(TESTS) - -.PHONY: sheet2csv -sheet2csv: sheet2csv.ts - deno compile -r --allow-read $< - -$(TESTS): %: %.ts doit.ts $(TEST_FILES) - deno run --allow-read --allow-write $< - -# --unstable is required, see https://github.com/denoland/deno_std/issues/1900 -$(UNSTABLE): %: %.ts doit.ts $(TEST_FILES) - deno run --allow-read --allow-write --unstable --allow-env $< - -.PHONY: stream -stream: stream.ts - deno run $< - -number_format_greek.xls: - cp ../../test_files/biff5/number_format_greek.xls . diff --git a/demos/deno/README.md b/demos/deno/README.md index ec77da1..5b5fa44 100644 --- a/demos/deno/README.md +++ b/demos/deno/README.md @@ -1,88 +1,13 @@ # Deno -Deno is a runtime capable of running JS code including this library. There are -a few different builds and recommended use cases as covered in this demo. - -Due to ongoing stability and sync issues with the Deno registry, scripts should -use [the CDN build](https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs): - -```js -// @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); -``` - - -## Reading and Writing Files - -In general, the command-line flag `--allow-read` must be passed to enable file -reading. The flag `--allow-write` must be passed to enable file writing. - -_Reading a File_ - -```ts -const workbook = XLSX.readFile("test.xlsx"); -``` - -_Writing a File_ - -Older versions of the library did not properly detect features from Deno, so the -`buffer` export would return an array of bytes. Since `Deno.writeFileSync` does -not handle byte arrays, user code must generate a `Uint8Array` first: - -```ts -XLSX.writeFile(workbook, "test.xlsb"); -``` - -## Demos - -**Complete Examples** - -`sheet2csv.ts` is a complete command-line tool for generating CSV text from -workbooks. Building the application is incredibly straightforward: - -```bash -$ deno compile -r --allow-read sheet2csv.ts # build the sheet2csv binary -$ ./sheet2csv test.xlsx # print the first worksheet as CSV -$ ./sheet2csv test.xlsx s5s # print worksheet "s5s" as CSV -``` - -The [`server` demo](../server) includes a sample Deno server for parsing uploads -and generating HTML TABLE previews. - - -**Module Import Scenarios** - -All demos attempt to read a file and write a new file. [`doit.ts`](./doit.ts) -accepts the `XLSX` module as an argument. - -- `x` imports the ESM build without the codepage library: - -```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'; -``` - -- `mjs` imports the ESM build and the associated codepage library: - -```ts -import * as XLSX from '../../xlsx.mjs'; -/* recommended for reading XLS files */ -import * as cptable from '../../dist/cptable.full.mjs'; -XLSX.set_cptable(cptable); -``` - -- `node` uses the node compatibility layer: - -```ts -import { createRequire } from 'https://deno.land/std/node/module.ts'; -const require = createRequire(import.meta.url); -const XLSX = require('../../'); -``` +Deno is a runtime capable of running JS code including this library. +Demos have been integrated in the [documentation](https://docs.sheetjs.com) : +- installation +- writing JS data to a spreadsheet +- input strategies +- output strategies +- `deno compile` [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/deno/doit.ts b/demos/deno/doit.ts deleted file mode 100644 index d22a580..0000000 --- a/demos/deno/doit.ts +++ /dev/null @@ -1,43 +0,0 @@ -const bts = [ - "xlsx", - "xlsb", - "xls", - "csv", - "fods", - "xlml", - "slk" -]; -export default function doit(XLSX: any, tag: string) { - const path = "number_format_greek.xls"; - let workbook: any; - - /* read file */ - try { - workbook = XLSX.readFile(path); - } catch(e) { - console.log(e); - console.error("Cannot use readFile, falling back to read"); - const rawdata = Deno.readFileSync(path); - workbook = XLSX.read(rawdata, {type: "buffer"}); - } - - /* write file */ - try { - bts.forEach(bt => { - console.log(bt); - XLSX.writeFile(workbook, `${tag}.${bt}`); - }); - } catch(e) { - console.log(e); - console.error("Cannot use writeFile, falling back to write"); - bts.forEach(bt => { - console.log(bt); - const buf = XLSX.write(workbook, {type: "buffer", bookType: bt}); - if(typeof buf == "string") { - const nbuf = new Uint8Array(buf.length); - for(let i = 0; i < buf.length; ++i) nbuf[i] = buf.charCodeAt(i); - Deno.writeFileSync(`${tag}.${bt}`, nbuf); - } else Deno.writeFileSync(`${tag}.${bt}`, new Uint8Array(buf)); - }); - } -} diff --git a/demos/deno/mjs.ts b/demos/deno/mjs.ts deleted file mode 100644 index b36323c..0000000 --- a/demos/deno/mjs.ts +++ /dev/null @@ -1,6 +0,0 @@ -import * as XLSX from '../../xlsx.mjs'; -import * as cpexcel from '../../dist/cpexcel.full.mjs'; -XLSX.set_cptable(cpexcel); - -import doit from './doit.ts'; -doit(XLSX, "mjs"); diff --git a/demos/deno/node.ts b/demos/deno/node.ts deleted file mode 100644 index 7bd2c9d..0000000 --- a/demos/deno/node.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createRequire } from 'https://deno.land/std/node/module.ts'; -const require = createRequire(import.meta.url); -const XLSX = require('../../'); - -import doit from './doit.ts'; -doit(XLSX, "node"); diff --git a/demos/deno/sheet2csv.ts b/demos/deno/sheet2csv.ts deleted file mode 100644 index fb4543e..0000000 --- a/demos/deno/sheet2csv.ts +++ /dev/null @@ -1,21 +0,0 @@ -/*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */ -// @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'; -import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs'; -XLSX.set_cptable(cptable); - -const filename = Deno.args[0]; -if(!filename) { - console.error("usage: sheet2csv [sheetname]"); - Deno.exit(1); -} - -const workbook = XLSX.readFile(filename); -const sheetname = Deno.args[1] || workbook.SheetNames[0]; - -if(!workbook.Sheets[sheetname]) { - console.error(`error: workbook missing sheet ${sheetname}`); - Deno.exit(1); -} - -console.log(XLSX.utils.sheet_to_csv(workbook.Sheets[sheetname])); diff --git a/demos/deno/stream.ts b/demos/deno/stream.ts deleted file mode 100644 index 246b9f9..0000000 --- a/demos/deno/stream.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {utils, stream, set_cptable} from '../../xlsx.mjs'; -import * as cpexcel from '../../dist/cpexcel.full.mjs'; -set_cptable(cpexcel); - -function NodeReadableCB(cb:(d:any)=>void) { - var rd = { - __done: false, - _read: function() {}, - push: function(d: any) { if(!this.__done) cb(d); if(d == null) this.__done = true; }, - resume: function pump() {for(var i = 0; i < 10000 && !this.__done; ++i) rd._read(); if(!rd.__done) setTimeout(pump, 0); } - }; - return rd; -} - -function NodeReadable(rd: any) { return function() { return rd; }; } - -const L = 1_000_000; -const W = 30; - -console.time("prep"); -const ws = utils.aoa_to_sheet([Array.from({length: W}, (_, C) => utils.encode_col(C))], {dense: true}); -for(let l = 1; l < L; ++l) utils.sheet_add_aoa(ws, [Array.from({length: W}, (_,j) => j == 0 ? String(l) : l+j)], {origin: -1}); -console.timeEnd("prep"); - -console.time("stream"); -var cnt = 0; -const rt = NodeReadableCB((d: any) => { - ++cnt; if((cnt%10000) == 0) console.log(cnt); if(d == null) console.timeEnd("stream"); -}); -stream.set_readable(NodeReadable(rt)); -const rd = stream.to_csv(ws); -rd.resume(); diff --git a/demos/deno/x.ts b/demos/deno/x.ts deleted file mode 100644 index f2bb5f5..0000000 --- a/demos/deno/x.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @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'; - -import doit from './doit.ts'; -doit(XLSX, "x"); diff --git a/demos/knockout/README.md b/demos/knockout/README.md index e272536..31d76c6 100644 --- a/demos/knockout/README.md +++ b/demos/knockout/README.md @@ -1,68 +1,7 @@ -# Knockout +# Knockout -The `xlsx.core.min.js` and `xlsx.full.min.js` scripts are designed to be dropped -into web pages with script tags: - -```html - -``` - -Strictly speaking, there should be no need for a Knockout demo! You can proceed -as you would with any other browser-friendly library. - - -## Array of Arrays - -A common data table is often stored as an array of arrays: - -```js -var aoa = [ [1,2], [3,4] ]; -``` - -This neatly maps to a table with `data-bind="foreach: ..."`: - -```html - - - - -
-``` - -The `sheet_to_json` utility function can generate array of arrays for model use: - -```js -/* starting from a `wb` workbook object, pull first worksheet */ -var ws = wb.Sheets[wb.SheetNames[0]]; -/* convert the worksheet to an array of arrays */ -var aoa = XLSX.utils.sheet_to_json(ws, {header:1}); -/* update model */ -model.aoa(aoa); -``` - - -## Demo - -The easiest observable representation is an `observableArray`: - -```js -var ViewModel = function() { this.aoa = ko.observableArray([[1,2],[3,4]]); }; -var model = new ViewModel(); -ko.applyBindings(model); -``` - -Unfortunately the nested `"foreach: $data"` binding is read-only. A two-way -binding is possible using the `$parent` and `$index` binding context properties: - -```html - - - - -
-``` - -The demo shows reading worksheets into a view model and writing models to XLSX. +[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/legacy#knockoutjs) +includes a live example and improved explanations. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/knockout/index.html b/demos/knockout/index.html deleted file mode 100644 index ad72b6d..0000000 --- a/demos/knockout/index.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - SheetJS + KnockoutJS - - - - - - - - -
-SheetJS + KnockoutJS demo
-
-The core library can be used as-is in KnockoutJS applications.
-The Community Edition README details some common use cases.
-We also have some more public demos
-
-This demo shows:
-- view model backed by an array of arrays
-- file import that refreshes the model
-- table of editable `input` elements that are bound to the model
-- file export based on the model
-
-Sample Spreadsheet
-
- - - - - - -
- - - - - - - - - diff --git a/demos/knockout/shim.js b/demos/knockout/shim.js deleted file mode 120000 index 7ec5819..0000000 --- a/demos/knockout/shim.js +++ /dev/null @@ -1 +0,0 @@ -../../shim.js \ No newline at end of file diff --git a/demos/knockout/xlsx.full.min.js b/demos/knockout/xlsx.full.min.js deleted file mode 120000 index dbca48d..0000000 --- a/demos/knockout/xlsx.full.min.js +++ /dev/null @@ -1 +0,0 @@ -../../dist/xlsx.full.min.js \ No newline at end of file diff --git a/demos/requirejs/.gitignore b/demos/requirejs/.gitignore deleted file mode 100644 index 510d56f..0000000 --- a/demos/requirejs/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -xlsx.full* -r.js -require.js -app-built.js diff --git a/demos/requirejs/Makefile b/demos/requirejs/Makefile deleted file mode 100644 index 584e26f..0000000 --- a/demos/requirejs/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -TOOL=requirejs -.PHONY: all -all: $(TOOL).js - -.PHONY: $(TOOL).js -$(TOOL).js: - if [ ! -e require.js ]; then curl -LO http://requirejs.org/docs/release/2.3.3/comments/require.js; fi - if [ ! -e r.js ]; then curl -LO http://requirejs.org/docs/release/2.3.3/r.js; fi - rm -f xlsx.full.min.js; ln -s ../../dist/xlsx.full.min.js - node r.js -o build.js paths.requireLib=./require include=requireLib diff --git a/demos/requirejs/README.md b/demos/requirejs/README.md index 415aa54..5f456aa 100644 --- a/demos/requirejs/README.md +++ b/demos/requirejs/README.md @@ -1,67 +1,7 @@ # RequireJS -The module complies with the AMD `define` semantics, enabling use in RequireJS -out of the box. +[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/bundler#requirejs) +includes a live example and improved explanations. -The require config should set `xlsx` path to the appropriate dist file: - -```js - paths: { - xlsx: "xlsx.full.min" - }, -``` - -Once that is set, app code can freely require `"xlsx"`: - -```js -require(["xlsx"], function(XLSX) { - /* use XLSX here */ -}); -``` - -## Deployments - -`browser.html` demonstrates a dynamic deployment, using the in-browser config: - -```html - - - -``` - -`optimizer.html` demonstrates an optimized deployment using `build.js` config: - -```js -/* build config */ -({ - baseUrl: ".", - name: "app", - paths: { - xlsx: "xlsx.full.min" - }, - out: "app-built.js" -}) -``` - -The optimizer is invoked with: - -```bash -node r.js -o build.js paths.requireLib=./require include=requireLib -``` - -That step creates a file `app-built.js` that can be included in a page: - -```html - - -``` [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/requirejs/app.js b/demos/requirejs/app.js deleted file mode 100644 index 264a094..0000000 --- a/demos/requirejs/app.js +++ /dev/null @@ -1,147 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -require(["xlsx"], function(XLSX2) { - -var global_wb; - -var process_wb = (function() { - var OUT = document.getElementById('out'); - var HTMLOUT = document.getElementById('htmlout'); - - var get_format = (function() { - var radios = document.getElementsByName( "format" ); - return function() { - for(var i = 0; i < radios.length; ++i) if(radios[i].checked || radios.length === 1) return radios[i].value; - }; - })(); - - var to_json = function to_json(workbook) { - var result = {}; - workbook.SheetNames.forEach(function(sheetName) { - var roa = XLSX2.utils.sheet_to_json(workbook.Sheets[sheetName]); - if(roa.length) result[sheetName] = roa; - }); - return JSON.stringify(result, 2, 2); - }; - - var to_csv = function to_csv(workbook) { - var result = []; - workbook.SheetNames.forEach(function(sheetName) { - var csv = XLSX2.utils.sheet_to_csv(workbook.Sheets[sheetName]); - if(csv.length){ - result.push("SHEET: " + sheetName); - result.push(""); - result.push(csv); - } - }); - return result.join("\n"); - }; - - var to_fmla = function to_fmla(workbook) { - var result = []; - workbook.SheetNames.forEach(function(sheetName) { - var formulae = XLSX2.utils.get_formulae(workbook.Sheets[sheetName]); - if(formulae.length){ - result.push("SHEET: " + sheetName); - result.push(""); - result.push(formulae.join("\n")); - } - }); - return result.join("\n"); - }; - - var to_html = function to_html(workbook) { - HTMLOUT.innerHTML = ""; - workbook.SheetNames.forEach(function(sheetName) { - var htmlstr = XLSX2.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); - HTMLOUT.innerHTML += htmlstr; - }); - return ""; - }; - - return function process_wb(wb) { - global_wb = wb; - var output = ""; - switch(get_format()) { - case "form": output = to_fmla(wb); break; - case "html": output = to_html(wb); break; - case "json": output = to_json(wb); break; - default: output = to_csv(wb); - } - if(OUT.innerText === undefined) OUT.textContent = output; - else OUT.innerText = output; - if(typeof console !== 'undefined') console.log("output", new Date()); - }; -})(); - -var setfmt = window.setfmt = function setfmt() { if(global_wb) process_wb(global_wb); }; - -var b64it = window.b64it = (function() { - var tarea = document.getElementById('b64data'); - return function b64it() { - if(typeof console !== 'undefined') console.log("onload", new Date()); - var wb = XLSX2.read(tarea.value, {type:'base64', WTF:false}); - process_wb(wb); - }; -})(); - -var do_file = (function() { - var use_worker = false && typeof Worker !== 'undefined'; - var domwork = document.getElementsByName("useworker")[0]; - if(!use_worker) domwork.disabled = !(domwork.checked = false); - - var xw = function xw(data, cb) { - var worker = new Worker(XW.worker); - worker.onmessage = function(e) { - switch(e.data.t) { - case 'ready': break; - case 'e': console.error(e.data.d); break; - case XW.msg: cb(JSON.parse(e.data.d)); break; - } - }; - worker.postMessage({d:data,b:'array'}); - }; - - return function do_file(files) { - use_worker = domwork.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 = e.target.result; - data = new Uint8Array(data); - if(use_worker) xw(data, process_wb); - else process_wb(XLSX2.read(data, {type: 'array'})); - }; - reader.readAsArrayBuffer(f); - }; -})(); - -(function() { - var drop = document.getElementById('drop'); - if(!drop.addEventListener) return; - - function handleDrop(e) { - e.stopPropagation(); - e.preventDefault(); - do_file(e.dataTransfer.files); - } - - function handleDragover(e) { - e.stopPropagation(); - e.preventDefault(); - e.dataTransfer.dropEffect = 'copy'; - } - - drop.addEventListener('dragenter', handleDragover, false); - drop.addEventListener('dragover', handleDragover, false); - drop.addEventListener('drop', handleDrop, false); -})(); - -(function() { - var xlf = document.getElementById('xlf'); - if(!xlf.addEventListener) return; - function handleFile(e) { do_file(e.target.files); } - xlf.addEventListener('change', handleFile, false); -})(); - -}); diff --git a/demos/requirejs/browser.html b/demos/requirejs/browser.html deleted file mode 100644 index 690b18a..0000000 --- a/demos/requirejs/browser.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - -SheetJS Live Demo - - - -
-SheetJS Data Preview Live Demo
-(Base64 text works back to IE6; drag and drop works back to IE10)
-
-Source Code Repo
-Issues?  Something look weird?  Click here and report an issue
-Output Format: 
-
Drop a spreadsheet file here to see sheet data
- ... or click here to select a file - - -
-Advanced Demo Options: -Use Web Workers: (when available) -
-

-
-
- - - - - - diff --git a/demos/requirejs/build.js b/demos/requirejs/build.js deleted file mode 100644 index 15608fe..0000000 --- a/demos/requirejs/build.js +++ /dev/null @@ -1,9 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -({ - baseUrl: ".", - name: "app", - paths: { - xlsx: "xlsx.full.min" - }, - out: "app-built.js" -}) diff --git a/demos/requirejs/optimizer.html b/demos/requirejs/optimizer.html deleted file mode 100644 index a65d469..0000000 --- a/demos/requirejs/optimizer.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - -SheetJS Live Demo - - - -
-SheetJS Data Preview Live Demo
-(Base64 text works back to IE6; drag and drop works back to IE10)
-
-Source Code Repo
-Issues?  Something look weird?  Click here and report an issue
-Output Format: 
-
Drop a spreadsheet file here to see sheet data
- ... or click here to select a file - - -
-Advanced Demo Options: -Use Web Workers: (when available) -
-

-
-
- - - - diff --git a/demos/rollup/Makefile b/demos/rollup/Makefile deleted file mode 100644 index 9b7a745..0000000 --- a/demos/rollup/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TOOL=rollup -.PHONY: all -all: $(TOOL).min.js worker.min.js - -$(TOOL).min.js: $(TOOL).js - uglifyjs $< > $@ - -.PHONY: $(TOOL).js -$(TOOL).js: - # node - rollup -c rollup.config.node.js - node -e 'require("./rollup.node")' - # browser - rollup -c - rollup -c rollup.config.worker.js - -worker.min.js: worker.js - uglifyjs $< > $@ - -.PHONY: init -init: - #@npm install @rollup/plugin-node-resolve @rollup/plugin-commonjs - @mkdir -p node_modules; cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd - diff --git a/demos/rollup/README.md b/demos/rollup/README.md index d1961cd..d4a52fb 100644 --- a/demos/rollup/README.md +++ b/demos/rollup/README.md @@ -1,46 +1,7 @@ # Rollup -This library has a proper ESM build that is enabled by default: +[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/bundler#rollup) +includes a simple example and improved explanations. -```js -import { read, utils } from 'xlsx'; -``` - -This sample demonstrates a bundle for browser as well as for node. - -This demo uses the `import` form to expose the whole library, enabling client -code to access the library with `import XLSX from 'xlsx'`. The JS code from -the root demo was moved to a separate `app.js` script. - -## Required Plugins - -The `rollup-plugin-node-resolve` plugin is used: - -```js -import resolve from 'rollup-plugin-node-resolve'; -export default { - /* ... */ - plugins: [ - resolve({ - module: false, // <-- this library is not an ES6 module - browser: true, // <-- suppress node-specific features - }) - ], - /* ... */ -}; -``` - -For the browser deployments, the output format is `'iife'`. For node, the -output format is `'cjs'`. - -### Worker Scripts - -Rollup can also bundle worker scripts! Instead of using `importScripts`, the -worker script should import the module: - -```diff --importScripts('dist/xlsx.full.min.js'); -+import * as XLSX from 'xlsx'; // or do named imports -``` [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/rollup/app.js b/demos/rollup/app.js deleted file mode 100644 index be204ec..0000000 --- a/demos/rollup/app.js +++ /dev/null @@ -1,146 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -/*jshint browser:true */ -import { read, write, utils } from 'xlsx'; - -var global_wb; - -var process_wb = (function() { - var OUT = document.getElementById('out'); - var HTMLOUT = document.getElementById('htmlout'); - - var get_format = (function() { - var radios = document.getElementsByName( "format" ); - return function() { - for(var i = 0; i < radios.length; ++i) if(radios[i].checked || radios.length === 1) return radios[i].value; - }; - })(); - - var to_json = function to_json(workbook) { - var result = {}; - workbook.SheetNames.forEach(function(sheetName) { - var roa = utils.sheet_to_json(workbook.Sheets[sheetName]); - if(roa.length) result[sheetName] = roa; - }); - return JSON.stringify(result, 2, 2); - }; - - var to_csv = function to_csv(workbook) { - var result = []; - workbook.SheetNames.forEach(function(sheetName) { - var csv = utils.sheet_to_csv(workbook.Sheets[sheetName]); - if(csv.length){ - result.push("SHEET: " + sheetName); - result.push(""); - result.push(csv); - } - }); - return result.join("\n"); - }; - - var to_fmla = function to_fmla(workbook) { - var result = []; - workbook.SheetNames.forEach(function(sheetName) { - var formulae = utils.get_formulae(workbook.Sheets[sheetName]); - if(formulae.length){ - result.push("SHEET: " + sheetName); - result.push(""); - result.push(formulae.join("\n")); - } - }); - return result.join("\n"); - }; - - var to_html = function to_html(workbook) { - HTMLOUT.innerHTML = ""; - workbook.SheetNames.forEach(function(sheetName) { - var htmlstr = write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); - HTMLOUT.innerHTML += htmlstr; - }); - return ""; - }; - - return function process_wb(wb) { - global_wb = wb; - var output = ""; - switch(get_format()) { - case "form": output = to_fmla(wb); break; - case "html": output = to_html(wb); break; - case "json": output = to_json(wb); break; - default: output = to_csv(wb); - } - if(OUT.innerText === undefined) OUT.textContent = output; - else OUT.innerText = output; - if(typeof console !== 'undefined') console.log("output", new Date()); - }; -})(); - -var setfmt = window.setfmt = function setfmt() { if(global_wb) process_wb(global_wb); }; - -var b64it = window.b64it = (function() { - var tarea = document.getElementById('b64data'); - return function b64it() { - if(typeof console !== 'undefined') console.log("onload", new Date()); - var wb = read(tarea.value, {type:'base64', WTF:false}); - process_wb(wb); - }; -})(); - -var do_file = (function() { - var use_worker = typeof Worker !== 'undefined'; - var domwork = document.getElementsByName("useworker")[0]; - if(!use_worker) domwork.disabled = !(domwork.checked = false); - - var xw = function xw(data, cb) { - var worker = new Worker('./worker.js'); - worker.onmessage = function(e) { - switch(e.data.t) { - case 'ready': break; - case 'e': console.error(e.data.d); break; - case 'xlsx': cb(JSON.parse(e.data.d)); break; - } - }; - worker.postMessage({d:data,b:'array'}); - }; - - return function do_file(files) { - use_worker = domwork.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 = e.target.result; - data = new Uint8Array(data); - if(use_worker) xw(data, process_wb); - else process_wb(read(data, {type: 'array'})); - }; - reader.readAsArrayBuffer(f); - }; -})(); - -(function() { - var drop = document.getElementById('drop'); - if(!drop.addEventListener) return; - - function handleDrop(e) { - e.stopPropagation(); - e.preventDefault(); - do_file(e.dataTransfer.files); - } - - function handleDragover(e) { - e.stopPropagation(); - e.preventDefault(); - e.dataTransfer.dropEffect = 'copy'; - } - - drop.addEventListener('dragenter', handleDragover, false); - drop.addEventListener('dragover', handleDragover, false); - drop.addEventListener('drop', handleDrop, false); -})(); - -(function() { - var xlf = document.getElementById('xlf'); - if(!xlf.addEventListener) return; - function handleFile(e) { do_file(e.target.files); } - xlf.addEventListener('change', handleFile, false); -})(); diff --git a/demos/rollup/main.js b/demos/rollup/main.js deleted file mode 100644 index 7f34293..0000000 --- a/demos/rollup/main.js +++ /dev/null @@ -1,3 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import * as XLSX from 'xlsx'; -export default XLSX; diff --git a/demos/rollup/rollup.config.js b/demos/rollup/rollup.config.js deleted file mode 100644 index 0553263..0000000 --- a/demos/rollup/rollup.config.js +++ /dev/null @@ -1,16 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import resolve from '@rollup/plugin-node-resolve'; -export default { - input: 'app.js', - output: { - file: 'rollup.js', - format: 'iife' - }, - //dest: 'rollup.js', - plugins: [ - resolve({ - module: false, - browser: true, - }), - ], -}; diff --git a/demos/rollup/rollup.config.node.js b/demos/rollup/rollup.config.node.js deleted file mode 100644 index f3b48fd..0000000 --- a/demos/rollup/rollup.config.node.js +++ /dev/null @@ -1,16 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import resolve from '@rollup/plugin-node-resolve'; -export default { - input: 'main.js', - output: { - file: 'rollup.node.js', - format: 'cjs' - }, - //dest: 'rollup.node.js', - plugins: [ - resolve({ - module: false, - browser: true, - }) - ], -}; diff --git a/demos/rollup/rollup.config.worker.js b/demos/rollup/rollup.config.worker.js deleted file mode 100644 index f3d0a27..0000000 --- a/demos/rollup/rollup.config.worker.js +++ /dev/null @@ -1,16 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import resolve from '@rollup/plugin-node-resolve'; -export default { - input: 'xlsxworker.js', - output: { - file: 'worker.js', - format: 'iife' - }, - //dest: 'worker.js', - plugins: [ - resolve({ - module: false, - browser: true, - }), - ], -}; diff --git a/demos/rollup/rollup.html b/demos/rollup/rollup.html deleted file mode 100644 index f597307..0000000 --- a/demos/rollup/rollup.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - -SheetJS Live Demo - - - -
-SheetJS Data Preview Live Demo
-(Base64 text works back to IE6; drag and drop works back to IE10)
-
-Source Code Repo
-Issues?  Something look weird?  Click here and report an issue
-Output Format: 
-
Drop a spreadsheet file here to see sheet data
- ... or click here to select a file - - -
-Advanced Demo Options: -Use Web Workers: (when available) -
-

-
-
- - - diff --git a/demos/rollup/xlsxworker.js b/demos/rollup/xlsxworker.js deleted file mode 100644 index a9f88a0..0000000 --- a/demos/rollup/xlsxworker.js +++ /dev/null @@ -1,11 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import { read } from 'xlsx'; -postMessage({t:"ready"}); - -onmessage = function (evt) { - var v; - try { - v = read(evt.data.d, {type: evt.data.b}); -postMessage({t:"xlsx", d:JSON.stringify(v)}); - } catch(e) { postMessage({t:"e",d:e.stack||e}); } -}; diff --git a/modules/83_numbers.js b/modules/83_numbers.js index 06a0b9d..bdafa36 100644 --- a/modules/83_numbers.js +++ b/modules/83_numbers.js @@ -827,6 +827,8 @@ function parse_numbers_iwa(cfb, opts) { cfb.FileIndex.forEach(function(s) { if (!s.name.match(/\.iwa$/)) return; + if (s.content[0] == 98) + return; var o; try { o = decompress_iwa_file(s.content); diff --git a/modules/83_numbers.ts b/modules/83_numbers.ts index f3b00ed..5dcfc34 100644 --- a/modules/83_numbers.ts +++ b/modules/83_numbers.ts @@ -717,6 +717,7 @@ function parse_numbers_iwa(cfb: CFB$Container, opts?: ParsingOptions ): WorkBook /* collect entire message space */ cfb.FileIndex.forEach(s => { if(!s.name.match(/\.iwa$/)) return; + if(s.content[0] == 98) return; // TODO: OperationStorage.iwa var o: Uint8Array; try { o = decompress_iwa_file(s.content as Uint8Array); } catch(e) { return console.log("?? " + s.content.length + " " + (e.message || e)); } var packets: IWAArchiveInfo[];