From 917a69e394c417ac3770ee85694f67d45d2bab8f Mon Sep 17 00:00:00 2001 From: SheetJS Date: Mon, 15 Aug 2022 01:20:14 -0400 Subject: [PATCH] XLSX custprops strip ns [ci skip] --- bits/35_custprops.js | 2 +- demos/README.md | 79 ++++++------- demos/altjs/README.md | 2 +- demos/angular/README.md | 4 +- demos/angular2/Makefile | 11 -- demos/angular2/README.md | 47 +------- demos/angular2/nscript.sh | 10 -- demos/angular2/nscript.ts | 82 -------------- demos/array/README.md | 2 +- demos/browserify/README.md | 2 +- demos/chrome/README.md | 2 +- demos/database/README.md | 4 +- demos/datagrid/README.md | 2 +- demos/deno/README.md | 2 +- demos/electron/README.md | 2 +- demos/extendscript/README.md | 2 +- demos/function/Makefile | 4 - demos/function/README.md | 26 ----- demos/function/mcstream.js | 22 ---- demos/google-sheet/README.md | 2 +- demos/headless/README.md | 2 +- demos/knockout/README.md | 2 +- demos/nwjs/README.md | 2 +- demos/oldie/README.md | 154 +------------------------ demos/oldie/base64.min.js | 1 - demos/oldie/download.png | Bin 2500 -> 0 bytes demos/oldie/downloadify.min.js | 3 - demos/oldie/downloadify.swf | Bin 2625 -> 0 bytes demos/oldie/index.html | 152 ------------------------- demos/oldie/shim.min.js | 1 - demos/oldie/swfobject.js | 4 - demos/oldie/xlsx.full.min.js | 1 - demos/parcel/README.md | 2 +- demos/react/README.md | 29 +---- demos/react/native.sh | 27 ----- demos/react/react-native.js | 179 ------------------------------ demos/react/screen.png | Bin 70135 -> 0 bytes demos/requirejs/README.md | 2 +- demos/rollup/README.md | 2 +- demos/systemjs/.gitignore | 2 - demos/systemjs/README.md | 2 +- demos/vue/.gitignore | 2 - demos/vue/Makefile | 15 +-- demos/vue/README.md | 55 +-------- demos/vue/content/sheetjs.numbers | Bin 98993 -> 0 bytes demos/vue/index3.html | 2 +- demos/vue/native.vue | 66 ----------- demos/vue/nuxt.config.js | 20 ---- demos/vue/package.json | 7 -- demos/vue/pages/index.vue | 24 ---- demos/vue/screen.png | Bin 99002 -> 0 bytes demos/vue/static/shim.js | 1 - demos/vue/static/xlsx.full.min.js | 1 - demos/vue/weex.sh | 16 --- demos/webpack/README.md | 2 +- demos/xhr/README.md | 2 +- 56 files changed, 81 insertions(+), 1008 deletions(-) delete mode 100755 demos/angular2/nscript.sh delete mode 100644 demos/angular2/nscript.ts delete mode 100644 demos/function/mcstream.js delete mode 100644 demos/oldie/base64.min.js delete mode 100755 demos/oldie/download.png delete mode 100755 demos/oldie/downloadify.min.js delete mode 100755 demos/oldie/downloadify.swf delete mode 100644 demos/oldie/index.html delete mode 120000 demos/oldie/shim.min.js delete mode 100755 demos/oldie/swfobject.js delete mode 120000 demos/oldie/xlsx.full.min.js delete mode 100755 demos/react/native.sh delete mode 100644 demos/react/react-native.js delete mode 100644 demos/react/screen.png delete mode 100644 demos/systemjs/.gitignore delete mode 100644 demos/vue/.gitignore delete mode 100755 demos/vue/content/sheetjs.numbers delete mode 100644 demos/vue/native.vue delete mode 100644 demos/vue/nuxt.config.js delete mode 100644 demos/vue/package.json delete mode 100644 demos/vue/pages/index.vue delete mode 100644 demos/vue/screen.png delete mode 120000 demos/vue/static/shim.js delete mode 120000 demos/vue/static/xlsx.full.min.js delete mode 100644 demos/vue/weex.sh diff --git a/bits/35_custprops.js b/bits/35_custprops.js index 1bd5bf6..3b22fc2 100644 --- a/bits/35_custprops.js +++ b/bits/35_custprops.js @@ -5,7 +5,7 @@ function parse_cust_props(data/*:string*/, opts) { var m = data.match(custregex); if(m) for(var i = 0; i != m.length; ++i) { var x = m[i], y = parsexmltag(x); - switch(y[0]) { + switch(strip_ns(y[0])) { case ' +[The new demo](https://docs.sheetjs.com/docs/demos/mobile#nativescript) +is updated for NativeScript 8 and uses more idiomatic data patterns. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/angular2/nscript.sh b/demos/angular2/nscript.sh deleted file mode 100755 index 851199c..0000000 --- a/demos/angular2/nscript.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -if [ ! -e SheetJSNS ]; then - ns create SheetJSNS --ng - cd SheetJSNS - npm install --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz - cd .. -fi - -<../../dist/xlsx.full.min.js sed 's/require("fs")/null/g' > SheetJSNS/src/app/xlsx.full.min.js -cp nscript.ts SheetJSNS/src/app/app.component.ts diff --git a/demos/angular2/nscript.ts b/demos/angular2/nscript.ts deleted file mode 100644 index 75e1956..0000000 --- a/demos/angular2/nscript.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -/* vim: set ts=2: */ - -import { Component } from '@angular/core'; -import { encoding } from '@nativescript/core/text'; -import { File, Folder, knownFolders, path } from '@nativescript/core/file-system'; -import { Dialogs } from '@nativescript/core'; -import { Page, GridLayout, WebView, DockLayout, Button } from '@nativescript/core'; - -import * as XLSX from './xlsx.full.min'; - -@Component({ - selector: 'ns-app', - template: ` - - - - - - - - - - - - - ` -}) - -export class AppComponent { - html: string = ""; - constructor() { - const ws = XLSX.utils.aoa_to_sheet([[1,2],[3,4]]); - this.html = XLSX.utils.sheet_to_html(ws); - }; - - /* Import button */ - async import() { - const filename: string = "SheetJSNS.csv"; - - /* find appropriate path */ - const target: Folder = knownFolders.documents() || knownFolders.ios.sharedPublic(); - const url: string = path.normalize(target.path + "///" + filename); - const file: File = File.fromPath(url); - - try { - /* get binary string */ - const bstr: string = await file.readText(encoding.ISO_8859_1); - - /* read workbook */ - const wb = XLSX.read(bstr, { type: "binary" }); - - /* grab first sheet */ - const wsname: string = wb.SheetNames[0]; - const ws = wb.Sheets[wsname]; - - /* update table */ - this.html = XLSX.utils.sheet_to_html(ws); - Dialogs.alert(`Attempting to read to ${filename} in ${url}`); - } catch(e) { - Dialogs.alert(e.message); - } - }; - - /* Export button */ - async export() { - const wb = XLSX.read(this.html, { type: "string" }); - const filename: string = "SheetJSNS.csv"; - - /* generate binary string */ - const wbout: string = XLSX.write(wb, { bookType: 'csv', type: 'binary' }); - - /* find appropriate path */ - const target: Folder = knownFolders.documents() || knownFolders.ios.sharedPublic(); - const url: string = path.normalize(target.path + "///" + filename); - const file: File = File.fromPath(url); - - /* attempt to save binary string to file */ - await file.writeText(wbout, encoding.ISO_8859_1); - Dialogs.alert(`Wrote to ${filename} in ${url}`); - }; -} diff --git a/demos/array/README.md b/demos/array/README.md index dcf14b3..1176d9b 100644 --- a/demos/array/README.md +++ b/demos/array/README.md @@ -1,6 +1,6 @@ # Typed Arrays and Math -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/ml) includes +[The new demo](https://docs.sheetjs.com/docs/demos/ml) includes interactive examples as well as strategies for CSV and JS Array interchange. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/browserify/README.md b/demos/browserify/README.md index c27653b..7541c7a 100644 --- a/demos/browserify/README.md +++ b/demos/browserify/README.md @@ -1,6 +1,6 @@ # Browserify -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/bundler#browserify) +[The new demo](https://docs.sheetjs.com/docs/demos/bundler#browserify) includes a more concise example. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/chrome/README.md b/demos/chrome/README.md index 799ad17..e2a8843 100644 --- a/demos/chrome/README.md +++ b/demos/chrome/README.md @@ -1,6 +1,6 @@ # Chrome and Chromium -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/chromium) +[The new demo](https://docs.sheetjs.com/docs/demos/chromium) includes more up-to-date details. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/database/README.md b/demos/database/README.md index 9117f85..e9b465b 100644 --- a/demos/database/README.md +++ b/demos/database/README.md @@ -2,10 +2,10 @@ This demo has been split up for clarity: -- covers SQL and +- covers SQL and structured data (including CRUD operations) -- https://docs.sheetjs.com/docs/getting-started/demos/nosql covers unstructured +- https://docs.sheetjs.com/docs/demos/nosql covers unstructured data including "NoSQL" data stores. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/datagrid/README.md b/demos/datagrid/README.md index cac7ca3..88401f9 100644 --- a/demos/datagrid/README.md +++ b/demos/datagrid/README.md @@ -1,6 +1,6 @@ # canvas-datagrid -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/grid#canvas-datagrid) +[The new demo](https://docs.sheetjs.com/docs/demos/grid#canvas-datagrid) includes a live example and improved explanations. diff --git a/demos/deno/README.md b/demos/deno/README.md index 5b5fa44..8706219 100644 --- a/demos/deno/README.md +++ b/demos/deno/README.md @@ -8,6 +8,6 @@ Demos have been integrated in the [documentation](https://docs.sheetjs.com) : - writing JS data to a spreadsheet - input strategies - output strategies -- `deno compile` +- `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/electron/README.md b/demos/electron/README.md index 95ad5dc..c8aab57 100644 --- a/demos/electron/README.md +++ b/demos/electron/README.md @@ -1,6 +1,6 @@ # Electron -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/desktop#electron) +[The new demo](https://docs.sheetjs.com/docs/demos/desktop#electron) includes an improved example and detailed explanations. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/extendscript/README.md b/demos/extendscript/README.md index 8e61928..449b655 100644 --- a/demos/extendscript/README.md +++ b/demos/extendscript/README.md @@ -1,6 +1,6 @@ # Adobe ExtendScript -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/extendscript) +[The new demo](https://docs.sheetjs.com/docs/demos/extendscript) has a more focused Photoshop example as well as notes about other extensibility frameworks shipping with newer versions of Creative Cloud apps. diff --git a/demos/function/Makefile b/demos/function/Makefile index 67ef827..1588319 100644 --- a/demos/function/Makefile +++ b/demos/function/Makefile @@ -1,7 +1,3 @@ -.PHONY: microcule -microcule: mcstream.js - microcule $< - .PHONY: aws aws: lambda-proxy diff --git a/demos/function/README.md b/demos/function/README.md index 39e187c..c5cd76a 100644 --- a/demos/function/README.md +++ b/demos/function/README.md @@ -43,32 +43,6 @@ var workbook = XLSX.readFile("path/to/file.xlsb"); XLSX.writeFile(workbook, "output/path/file.csv"); ``` -The `mcstream.js` demo uses the `microcule` framework to show a simple body -converter. It accepts raw data from a POST connection, parses as a workbook, -and streams back the first worksheet as CSV: - -
- Code Sketch (click to show) - -```js -const XLSX = require('xlsx'); - -module.exports = (hook) => { - /* process_RS from the main README under "Streaming Read" section */ - process_RS(hook.req, (wb) => { - hook.res.writeHead(200, { 'Content-Type': 'text/csv' }); - /* get first worksheet */ - const ws = wb.Sheets[wb.SheetNames[0]]; - /* generate CSV stream and pipe to response */ - const stream = XLSX.stream.to_csv(ws); - stream.pipe(hook.res); - }); -}; -``` - -
- - #### Report Generation For an existing platform that already generates JSON or CSV or HTML output, the diff --git a/demos/function/mcstream.js b/demos/function/mcstream.js deleted file mode 100644 index 09d8cff..0000000 --- a/demos/function/mcstream.js +++ /dev/null @@ -1,22 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -/* eslint-env node */ -// cat file.xlsx | curl --header 'content-type: application/octet-stream' --data-binary @- "http://localhost:3000/" -const XLSX = require('xlsx'); - -const process_RS = (stream, cb) => { - var buffers = []; - stream.on('data', function(data) { buffers.push(data); }); - stream.on('end', function() { - var buffer = Buffer.concat(buffers); - var workbook = XLSX.read(buffer, {type:"buffer"}); - cb(workbook); - }); -}; - -module.exports = (hook) => { - process_RS(hook.req, (wb) => { - hook.res.writeHead(200, { 'Content-Type': 'text/csv' }); - const stream = XLSX.stream.to_csv(wb.Sheets[wb.SheetNames[0]]); - stream.pipe(hook.res); - }); -}; diff --git a/demos/google-sheet/README.md b/demos/google-sheet/README.md index 02a19c6..01e8d25 100644 --- a/demos/google-sheet/README.md +++ b/demos/google-sheet/README.md @@ -3,7 +3,7 @@ The old demo used a deprecated version of the Google Sheets API to export data from Google Sheets Documents. -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/gsheet) uses +[The new demo](https://docs.sheetjs.com/docs/demos/gsheet) uses the new Google Sheets API to read and write data. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/headless/README.md b/demos/headless/README.md index 43fb249..7367db9 100644 --- a/demos/headless/README.md +++ b/demos/headless/README.md @@ -1,6 +1,6 @@ # Headless Browsers -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/headless) +[The new demo](https://docs.sheetjs.com/docs/demos/headless) has a more focused table export example as well as a demo script for Chromium automation with Puppeteer and multi-browser automation with Playwright. diff --git a/demos/knockout/README.md b/demos/knockout/README.md index 31d76c6..d1448b1 100644 --- a/demos/knockout/README.md +++ b/demos/knockout/README.md @@ -1,6 +1,6 @@ # Knockout -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/legacy#knockoutjs) +[The new demo](https://docs.sheetjs.com/docs/demos/legacy#knockoutjs) includes a live example and improved explanations. diff --git a/demos/nwjs/README.md b/demos/nwjs/README.md index 14c1361..8ef6e37 100644 --- a/demos/nwjs/README.md +++ b/demos/nwjs/README.md @@ -1,6 +1,6 @@ # NW.js -[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/desktop#nwjs) +[The new demo](https://docs.sheetjs.com/docs/demos/desktop#nwjs) includes an improved example and detailed explanations. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/oldie/README.md b/demos/oldie/README.md index 472f17f..f4eeccb 100644 --- a/demos/oldie/README.md +++ b/demos/oldie/README.md @@ -1,156 +1,6 @@ # Internet Explorer -The modern upload and download strategies are not available in older versions of -IE, but there are approaches using older technologies like ActiveX and Flash. - -
- Live Demos (click to show) - - uses XMLHttpRequest to download test -files and convert to CSV. - - demonstrates reading files with `FileReader`. - -Older versions of IE do not support HTML5 File API but do support Base64. - -On OSX you can get the Base64 encoding with: - -```bash -$ certutil -encode target_file target_file.b64 -``` - -(note: You have to open the file and remove the header and footer lines) - -
- -## Upload Strategies - -#### IE10 and IE11 FileReader - -IE10 and IE11 support the standard HTML5 FileReader API: - -```js -function handle_fr(e) { - var files = e.target.files, f = files[0]; - var reader = new FileReader(); - reader.onload = function(e) { - var data = new Uint8Array(e.target.result); - var wb = XLSX.read(data, {type: 'array'}); - process_wb(wb); - }; - reader.readAsArrayBuffer(f); -} -input_dom_element.addEventListener('change', handle_fr, false); -``` - -#### ActiveX-based Upload - -Through the `Scripting.FileSystemObject` object model, a script in the VBScript -scripting language can read from an arbitrary path on the filesystem. The shim -includes a special `IE_LoadFile` function to read binary strings from file. This -should be called from a file input `onchange` event: - -```js -var input_dom_element = document.getElementById("file"); -function handle_ie() { - /* get data from selected file */ - var path = input_dom_element.value; - var bstr = IE_LoadFile(path); - /* read workbook */ - var wb = XLSX.read(bstr, {type: 'binary'}); - /* DO SOMETHING WITH workbook HERE */ -} -input_dom_element.attachEvent('onchange', handle_ie); -``` - - -## Download Strategies - -#### IE10 and IE11 File API - -As part of the File API implementation, IE10 and IE11 provide the `msSaveBlob` -and `msSaveOrOpenBlob` functions to save blobs to the client computer. This -approach is embedded in `XLSX.writeFile` and no additional shims are necessary. - -#### Flash-based Download - -It is possible to write to the file system using a SWF. `Downloadify` library -implements one solution. Since a genuine click is required, there is no way to -force a download. The demo generates a button for each desired output format. - -#### ActiveX-based Download - -Through the `Scripting.FileSystemObject` object model, a script in the VBScript -scripting language can write to an arbitrary path on the filesystem. The shim -includes a special `IE_SaveFile` function to write binary strings to file. It -attempts to write to the Downloads folder or Documents folder or Desktop. - -This approach can be triggered, but it requires the user to enable ActiveX. It -is embedded as a strategy in `writeFile` and used only if the shim script is -included in the page and the relevant features are enabled on the target system. - - -## Demo - -#### Download - -The included demo starts from an array of arrays, generating an editable HTML -table with `aoa_to_sheet` and adding it to the page: - -```js -var ws = XLSX.utils.aoa_to_sheet(aoa); -var html_string = XLSX.utils.sheet_to_html(ws, { id: "table", editable: true }); -document.getElementById("container").innerHTML = html_string; -``` - -The included download buttons use `table_to_book` to construct a new workbook -based on the table and `writeFile` to force a download: - - -```js -var elt = document.getElementById('table'); -var wb = XLSX.utils.table_to_book(elt, { sheet: "Sheet JS" }); -XLSX.writeFile(wb, filename); -``` - -The shim is included in the HTML page, unlocking the ActiveX pathway if enabled -in browser settings. - -The corresponding SWF buttons are displayed in environments where Flash is -available and `Downloadify` is supported. The easiest solution involves writing -to a Base64 string and passing to the library: - -```js -Downloadify.create(element_id, { - /* the demo includes the other options required by Downloadify */ - filename: "test.xlsx", - data: function() { return XLSX.write(wb, {bookType:"xlsx", type:'base64'}); }, - dataType: 'base64' -}); -``` - -#### Upload - -The demo also includes an HTML file input element for updating the data table: - -```js -var ws = wb.Sheets[wb.SheetNames[0]]; -var html_string = XLSX.utils.sheet_to_html(ws, { id: "table", editable: true }); -document.getElementById("container").innerHTML = html_string; -``` - -The specific strategy is determined based on the presence of `IE_LoadFile`: - -```js -var handler = typeof IE_LoadFile !== 'undefined' ? handle_ie : handle_fr; -if(input_dom_element.attachEvent) input_dom_element.attachEvent('onchange', handler); -else input_dom_element.addEventListener('change', handler, false); -``` +[The new demo](https://docs.sheetjs.com/docs/demos/legacy#internet-explorer) +includes a live example and easier integration bundle. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/oldie/base64.min.js b/demos/oldie/base64.min.js deleted file mode 100644 index 2ad238a..0000000 --- a/demos/oldie/base64.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){function t(t){this.message=t}var r="undefined"!=typeof exports?exports:self,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=new Error,t.prototype.name="InvalidCharacterError",r.btoa||(r.btoa=function(r){for(var o,n,a=String(r),i=0,c=e,d="";a.charAt(0|i)||(c="=",i%1);d+=c.charAt(63&o>>8-i%1*8)){if(n=a.charCodeAt(i+=.75),n>255)throw new t("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return d}),r.atob||(r.atob=function(r){var o=String(r).replace(/=+$/,"");if(o.length%4==1)throw new t("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,a,i=0,c=0,d="";a=o.charAt(c++);~a&&(n=i%4?64*n+a:a,i++%4)?d+=String.fromCharCode(255&n>>(-2*i&6)):0)a=e.indexOf(a);return d})}(); diff --git a/demos/oldie/download.png b/demos/oldie/download.png deleted file mode 100755 index d2fabbf5a2bae5496b4d5db6fbd4c5338ff46cff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2500 zcmV;#2|MnEsHmv0u&|t*o~o*Io}QqtuCA)8tm5M0 z!otI+r>L~FwydnKsHm#3v9YhOu(!9khlhx{xw)I0od5s-$jHfecXwxJXI@@jkB^Uj zet&awbI#7sZ*Om+qNBdPzV*cn*8l(rnn^@KRCwClS!=Gwk|h{OAv>yII7nhNf?*KJNibeVBKp7+NjBU+7XVy(U<{iGuz?6)h?W}& zQNsWjkLL!Lcl(=_;ydW>Yi3W`mis@e9vk^~W8XMrovCH@b zKo5%yGP5?0Tc*NZO(C-$vuk)x_HZx`abmfwFqn%&w6VPk1s+`T7lsO|Q9x=KDO@L@ z2lfSqSg^L)KwFR(lmm^1+?Mrft&7c5e+m+0)CSCd+93D9*-B;z~U zXDsTvJx*wGS~6I4g(M%<9r*!sG07{~SJfV>%A12dt2~7gwcrsJSXHH9%0>ze_vDF9 z%6wI!6jo?1PD}2Kejv%>bAZ3j=ks5mpW4so=Z}VC@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q8FsgWA5toQ%*=*UTR;PTPYA@CAmtn~tG!v|1kM%$sX zUU(NwO}~Q#oCT4%Lzq|{I;aUX@f9Rf_!ytbng{CO zF?z%C9w_VIM*nz*J%X=B*rC0=~PpN>}<>ac92m#i> z|DX>VndNrqa#VVb-y!G??vgq?f&e&i-}y0QCO?e5sLSA3+C} diff --git a/demos/oldie/index.html b/demos/oldie/index.html deleted file mode 100644 index c741667..0000000 --- a/demos/oldie/index.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - -SheetJS JS-XLSX In-Browser HTML Table Demo - - - - - - - - - - - - -
-

SheetJS JS-XLSX In-Browser HTML Table Demo

-Compatibility notes: -- Editable table leverages the HTML5 contenteditable feature, supported in most browsers. -- IE6-9 requires ActiveX to upload files and ActiveX or Flash to download files. -- iOS Safari file download may not work. This is a known issue. - -Update Spreadsheet: (submit file to update table; file parsed in browser) - - -Editable Data Table: (click a cell to edit it) -
-
- -
-
Export it!
- - - - - - -
XLSX Excel 2007+ XML
-

-

Flash required for actually downloading the generated file.

-
XLSB Excel 2007+ Binary
-

-

Flash required for actually downloading the generated file.

-
XLS Excel 97-2004 Binary
-

-

Flash required for actually downloading the generated file.

-
ODS
-

-

Flash required for actually downloading the generated file.

-
Flat ODS
-

-

Flash required for actually downloading the generated file.

-
-
Powered by the community version of js-xlsx
- - - - diff --git a/demos/oldie/shim.min.js b/demos/oldie/shim.min.js deleted file mode 120000 index cfd40cc..0000000 --- a/demos/oldie/shim.min.js +++ /dev/null @@ -1 +0,0 @@ -../../dist/shim.min.js \ No newline at end of file diff --git a/demos/oldie/swfobject.js b/demos/oldie/swfobject.js deleted file mode 100755 index f9e4489..0000000 --- a/demos/oldie/swfobject.js +++ /dev/null @@ -1,4 +0,0 @@ -/* SWFObject v2.2 - is released under the MIT License -*/ -var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab - -Reproducing the full project is straightforward: - -```bash -$ make native # build the project -$ make ios # build and run the iOS demo -$ make android # build and run the android demo -``` - -The app will prompt before reading and after writing data. The printed location -depends on the environment: - -- android: path in the device filesystem -- iOS simulator: local path to file -- iOS device: a path accessible from iTunes App Documents view - -Components used in the demo: -- [`react-native-table-component`](https://npm.im/react-native-table-component) -- [`react-native-file-access`](https://npm.im/react-native-file-access) - -React Native does not provide a native component for reading and writing files. -The sample script `react-native.js` uses `react-native-file-access` and has -notes for integrations with `react-native-fetch-blob` and `react-native-fs`. - -Note: for real app deployments, the `UIFileSharingEnabled` flag must be manually -set in the iOS project `Info.plist` file. +[The new demo](https://docs.sheetjs.com/docs/demos/mobile#react-native) uses +up-to-date file I/O and file picker libraries. ## Server-Rendered React Components with Next.js diff --git a/demos/react/native.sh b/demos/react/native.sh deleted file mode 100755 index 6c415ef..0000000 --- a/demos/react/native.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ - -# Create starter project -if [ ! -e SheetJS ]; then react-native init SheetJS --version="0.67.2"; fi - -# Install dependencies -cd SheetJS; npm i -S https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz react-native-table-component; cd - - -cd SheetJS; npm i -S react-native-file-access@2.x; cd - -# cd SheetJS; npm i -S react-native-fs; cd - -# cd SheetJS; npm i -S react-native-fetch-blob; cd - - -# Copy demo assets -if [ ! -e SheetJS/logo.png ]; then - curl -O http://oss.sheetjs.com/assets/img/logo.png - mv logo.png SheetJS/logo.png -fi -if [ -e SheetJS/index.ios.js ]; then - cp react-native.js SheetJS/index.ios.js - cp react-native.js SheetJS/index.android.js -else - cp react-native.js SheetJS/index.js -fi - -# Link -cd SheetJS; RNFB_ANDROID_PERMISSIONS=true react-native link; cd - diff --git a/demos/react/react-native.js b/demos/react/react-native.js deleted file mode 100644 index 2c11a98..0000000 --- a/demos/react/react-native.js +++ /dev/null @@ -1,179 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import * as XLSX from 'xlsx'; -import React, { Component } from 'react'; -import { - AppRegistry, - StyleSheet, - Text, - View, - Button, - Alert, - Image, - ScrollView, - TouchableWithoutFeedback -} from 'react-native'; -import { Table, Row, Rows, TableWrapper } from 'react-native-table-component'; - -// react-native-file-access -var Base64 = function() { - var map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - return { - encode: function(input) { - var o = ""; - var c1 = 0, c2 = 0, c3 = 0, e1 = 0, e2 = 0, e3 = 0, e4 = 0; - for (var i = 0; i < input.length; ) { - c1 = input.charCodeAt(i++); - e1 = c1 >> 2; - c2 = input.charCodeAt(i++); - e2 = (c1 & 3) << 4 | c2 >> 4; - c3 = input.charCodeAt(i++); - e3 = (c2 & 15) << 2 | c3 >> 6; - e4 = c3 & 63; - if (isNaN(c2)) { - e3 = e4 = 64; - } else if (isNaN(c3)) { - e4 = 64; - } - o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4); - } - return o; - }, - decode: function(input) { - var o = ""; - var c1 = 0, c2 = 0, c3 = 0, e1 = 0, e2 = 0, e3 = 0, e4 = 0; - input = input.replace(/[^\w\+\/\=]/g, ""); - for (var i = 0; i < input.length; ) { - e1 = map.indexOf(input.charAt(i++)); - e2 = map.indexOf(input.charAt(i++)); - c1 = e1 << 2 | e2 >> 4; - o += String.fromCharCode(c1); - e3 = map.indexOf(input.charAt(i++)); - c2 = (e2 & 15) << 4 | e3 >> 2; - if (e3 !== 64) { - o += String.fromCharCode(c2); - } - e4 = map.indexOf(input.charAt(i++)); - c3 = (e3 & 3) << 6 | e4; - if (e4 !== 64) { - o += String.fromCharCode(c3); - } - } - return o; - } - }; -}(); - -import { Dirs, FileSystem } from 'react-native-file-access'; -const DDP = Dirs.DocumentDir + "/"; -const readFile = (path, enc) => FileSystem.readFile(path, "base64"); -const writeFile = (path, data, enc) => FileSystem.writeFile(path, data, "base64"); -const input = res => Base64.decode(res); -const output = str => Base64.encode(str); - -// react-native-fs -/* -import { writeFile, readFile, DocumentDirectoryPath } from 'react-native-fs'; -const DDP = DocumentDirectoryPath + "/"; -const input = res => res; -const output = str => str; -*/ -// react-native-fetch-blob -/* -import RNFetchBlob from 'react-native-fetch-blob'; -const { writeFile, readFile, dirs:{ DocumentDir } } = RNFetchBlob.fs; -const DDP = DocumentDir + "/"; -const input = res => res.map(x => String.fromCharCode(x)).join(""); -const output = str => str.split("").map(x => x.charCodeAt(0)); -*/ - -const make_cols = refstr => Array.from({length: XLSX.utils.decode_range(refstr).e.c + 1}, (x,i) => XLSX.utils.encode_col(i)); -const make_width = refstr => Array.from({length: XLSX.utils.decode_range(refstr).e.c + 1}, () => 60); - -export default class SheetJS extends Component { - constructor(props) { - super(props); - this.state = { - data: [[2,3,4],[3,4,5]], - widthArr: [60, 60, 60], - cols: make_cols("A1:C2") - }; - this.importFile = this.importFile.bind(this); - this.exportFile = this.exportFile.bind(this); - }; - importFile() { - Alert.alert("Rename file to sheetjs.xlsx", "Copy to " + DDP, [ - {text: 'Cancel', onPress: () => {}, style: 'cancel' }, - {text: 'Import', onPress: () => { - readFile(DDP + "sheetjs.xlsx", 'ascii').then((res) => { - /* parse file */ - const wb = XLSX.read(input(res), {type:'binary'}); - - /* convert first worksheet to AOA */ - const wsname = wb.SheetNames[0]; - const ws = wb.Sheets[wsname]; - const data = XLSX.utils.sheet_to_json(ws, {header:1}); - - /* update state */ - this.setState({ data: data, cols: make_cols(ws['!ref']), widthArr: make_width(ws['!ref']) }); - }).catch((err) => { Alert.alert("importFile Error", "Error " + err.message); }); - }} - ]); - } - exportFile() { - /* convert AOA back to worksheet */ - const ws = XLSX.utils.aoa_to_sheet(this.state.data); - - /* build new workbook */ - const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet(wb, ws, "SheetJS"); - - /* write file */ - const wbout = XLSX.write(wb, {type:'binary', bookType:"xlsx"}); - const file = DDP + "sheetjsw.xlsx"; - writeFile(file, output(wbout), 'ascii').then((res) =>{ - Alert.alert("exportFile success", "Exported to " + file); - }).catch((err) => { Alert.alert("exportFile Error", "Error " + err.message); }); - }; - - render() { - return ( - - - SheetJS React Native Demo - Import Data -