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 d2fabbf..0000000 Binary files a/demos/oldie/download.png and /dev/null differ diff --git a/demos/oldie/downloadify.min.js b/demos/oldie/downloadify.min.js deleted file mode 100755 index faf490c..0000000 --- a/demos/oldie/downloadify.min.js +++ /dev/null @@ -1,3 +0,0 @@ -/* Downloadify 0.2 (c) 2009 by Douglas Neiner. Licensed under the MIT license */ -/* See http://github.com/dcneiner/Downloadify for license and more info */ -(function(){Downloadify=window.Downloadify={queue:{},uid:new Date().getTime(),getTextForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getData();return""},getFileNameForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getFilename();return""},getDataTypeForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getDataType();return""},saveComplete:function(a){var b=Downloadify.queue[a];if(b)b.complete();return true},saveCancel:function(a){var b=Downloadify.queue[a];if(b)b.cancel();return true},saveError:function(a){var b=Downloadify.queue[a];if(b)b.error();return true},addToQueue:function(a){Downloadify.queue[a.queue_name]=a},getUID:function(a){if(a.id=="")a.id='downloadify_'+Downloadify.uid++;return a.id}};Downloadify.create=function(a,b){var c=(typeof(a)=="string"?document.getElementById(a):a);return new Downloadify.Container(c,b)};Downloadify.Container=function(d,e){var f=this;f.el=d;f.enabled=true;f.dataCallback=null;f.filenameCallback=null;f.data=null;f.filename=null;var g=function(){f.options=e;if(!f.options.append)f.el.innerHTML="";f.flashContainer=document.createElement('span');f.el.appendChild(f.flashContainer);f.queue_name=Downloadify.getUID(f.flashContainer);if(typeof(f.options.filename)==="function")f.filenameCallback=f.options.filename;else if(f.options.filename)f.filename=f.options.filename;if(typeof(f.options.data)==="function")f.dataCallback=f.options.data;else if(f.options.data)f.data=f.options.data;var a={queue_name:f.queue_name,width:f.options.width,height:f.options.height};var b={allowScriptAccess:'always'};var c={id:f.flashContainer.id,name:f.flashContainer.id};if(f.options.enabled===false)f.enabled=false;if(f.options.transparent===true)b.wmode="transparent";if(f.options.downloadImage)a.downloadImage=f.options.downloadImage;swfobject.embedSWF(f.options.swf,f.flashContainer.id,f.options.width,f.options.height,"10",null,a,b,c);Downloadify.addToQueue(f)};f.enable=function(){var a=document.getElementById(f.flashContainer.id);a.setEnabled(true);f.enabled=true};f.disable=function(){var a=document.getElementById(f.flashContainer.id);a.setEnabled(false);f.enabled=false};f.getData=function(){if(!f.enabled)return"";if(f.dataCallback)return f.dataCallback();else if(f.data)return f.data;else return""};f.getFilename=function(){if(f.filenameCallback)return f.filenameCallback();else if(f.filename)return f.filename;else return""};f.getDataType=function(){if(f.options.dataType)return f.options.dataType;return"string"};f.complete=function(){if(typeof(f.options.onComplete)==="function")f.options.onComplete()};f.cancel=function(){if(typeof(f.options.onCancel)==="function")f.options.onCancel()};f.error=function(){if(typeof(f.options.onError)==="function")f.options.onError()};g()};Downloadify.defaultOptions={swf:'media/downloadify.swf',downloadImage:'images/download.png',width:100,height:30,transparent:true,append:false,dataType:"string"}})();if(typeof(jQuery)!="undefined"){(function($){$.fn.downloadify=function(b){return this.each(function(){b=$.extend({},Downloadify.defaultOptions,b);var a=Downloadify.create(this,b);$(this).data('Downloadify',a)})}})(jQuery)};if(typeof(MooTools)!='undefined'){Element.implement({downloadify:function(a){a=$merge(Downloadify.defaultOptions,a);return this.store('Downloadify',Downloadify.create(this,a))}})}; \ No newline at end of file diff --git a/demos/oldie/downloadify.swf b/demos/oldie/downloadify.swf deleted file mode 100755 index 2a2f01c..0000000 Binary files a/demos/oldie/downloadify.swf and /dev/null differ 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 -