diff --git a/bits/38_xlstypes.js b/bits/38_xlstypes.js index 32e3cbc..b0b4106 100644 --- a/bits/38_xlstypes.js +++ b/bits/38_xlstypes.js @@ -41,6 +41,18 @@ function parse_VtStringBase(blob, stringType, pad) { function parse_VtString(blob, t/*:number*/, pad/*:?boolean*/) { return parse_VtStringBase(blob, t, pad === false ? 0: 4); } function parse_VtUnalignedString(blob, t/*:number*/) { if(!t) throw new Error("VtUnalignedString must have positive length"); return parse_VtStringBase(blob, t, 0); } +/* [MS-OSHARED] 2.3.3.1.7 VtVecLpwstrValue */ +function parse_VtVecLpwstrValue(blob)/*:Array*/ { + var length = blob.read_shift(4); + var ret/*:Array*/ = []; + for(var i = 0; i != length; ++i) { + var start = blob.l; + ret[i] = blob.read_shift(0, 'lpwstr').replace(chr0,''); + if((blob.l - start) & 0x02) blob.l += 2; + } + return ret; +} + /* [MS-OSHARED] 2.3.3.1.9 VtVecUnalignedLpstrValue */ function parse_VtVecUnalignedLpstrValue(blob)/*:Array*/ { var length = blob.read_shift(4); @@ -49,14 +61,12 @@ function parse_VtVecUnalignedLpstrValue(blob)/*:Array*/ { return ret; } -/* [MS-OSHARED] 2.3.3.1.10 VtVecUnalignedLpstr */ -function parse_VtVecUnalignedLpstr(blob)/*:Array*/ { - return parse_VtVecUnalignedLpstrValue(blob); -} /* [MS-OSHARED] 2.3.3.1.13 VtHeadingPair */ function parse_VtHeadingPair(blob) { + var start = blob.l; var headingString = parse_TypedPropertyValue(blob, VT_USTR); + if(blob[blob.l] == 0x00 && blob[blob.l+1] == 0x00 && ((blob.l - start) & 0x02)) blob.l += 2; var headerParts = parse_TypedPropertyValue(blob, VT_I4); return [headingString, headerParts]; } @@ -65,16 +75,10 @@ function parse_VtHeadingPair(blob) { function parse_VtVecHeadingPairValue(blob) { var cElements = blob.read_shift(4); var out = []; - for(var i = 0; i != cElements / 2; ++i) out.push(parse_VtHeadingPair(blob)); + for(var i = 0; i < cElements / 2; ++i) out.push(parse_VtHeadingPair(blob)); return out; } -/* [MS-OSHARED] 2.3.3.1.15 VtVecHeadingPair */ -function parse_VtVecHeadingPair(blob) { - // NOTE: When invoked, wType & padding were already consumed - return parse_VtVecHeadingPairValue(blob); -} - /* [MS-OLEPS] 2.18.1 Dictionary (uses 2.17, 2.16) */ function parse_dictionary(blob,CodePage) { var cnt = blob.read_shift(4); @@ -113,7 +117,7 @@ function parse_TypedPropertyValue(blob, type/*:number*/, _opts)/*:any*/ { var t = blob.read_shift(2), ret, opts = _opts||{}; blob.l += 2; if(type !== VT_VARIANT) - if(t !== type && VT_CUSTOM.indexOf(type)===-1) throw new Error('Expected type ' + type + ' saw ' + t); + if(t !== type && VT_CUSTOM.indexOf(type)===-1 && !((type & 0xFFFE) == 0x101E && (t & 0xFFFE) == 0x101E)) throw new Error('Expected type ' + type + ' saw ' + t); switch(type === VT_VARIANT ? t : type) { case 0x02 /*VT_I2*/: ret = blob.read_shift(2, 'i'); if(!opts.raw) blob.l += 2; return ret; case 0x03 /*VT_I4*/: ret = blob.read_shift(4, 'i'); return ret; @@ -126,8 +130,10 @@ function parse_TypedPropertyValue(blob, type/*:number*/, _opts)/*:any*/ { case 0x47 /*VT_CF*/: return parse_ClipboardData(blob); case 0x50 /*VT_STRING*/: return parse_VtString(blob, t, !opts.raw).replace(chr0,''); case 0x51 /*VT_USTR*/: return parse_VtUnalignedString(blob, t/*, 4*/).replace(chr0,''); - case 0x100C /*VT_VECTOR|VT_VARIANT*/: return parse_VtVecHeadingPair(blob); - case 0x101E /*VT_LPSTR*/: return parse_VtVecUnalignedLpstr(blob); + case 0x100C /*VT_VECTOR|VT_VARIANT*/: return parse_VtVecHeadingPairValue(blob); + case 0x101E /*VT_VECTOR|VT_LPSTR*/: + case 0x101F /*VT_VECTOR|VT_LPWSTR*/: + return t == 0x101F ? parse_VtVecLpwstrValue(blob) : parse_VtVecUnalignedLpstrValue(blob); default: throw new Error("TypedPropertyValue unrecognized type " + type + " " + t); } } diff --git a/demos/README.md b/demos/README.md index 802aad1..8f5c989 100644 --- a/demos/README.md +++ b/demos/README.md @@ -19,7 +19,7 @@ can be installed with Bash on Windows or with `cygwin`. **Frameworks and APIs** - [`angularjs`](angular/) -- [`angular 2 / 4 / 5 / 6 and ionic`](angular2/) +- [`angular and ionic`](angular2/) - [`knockout`](knockout/) - [`meteor`](meteor/) - [`react and react-native`](react/) diff --git a/demos/altjs/.gitignore b/demos/altjs/.gitignore index 535d624..6626d47 100644 --- a/demos/altjs/.gitignore +++ b/demos/altjs/.gitignore @@ -7,3 +7,4 @@ rhino shim.min.js xlsx.*.js payload.js +goja diff --git a/demos/altjs/Makefile b/demos/altjs/Makefile index b71399f..7fc69e0 100644 --- a/demos/altjs/Makefile +++ b/demos/altjs/Makefile @@ -27,7 +27,6 @@ swift: base ## swift demo .PHONY: goja goja: base ## goja demo - if [ ! -e xlsx.core.min.js ]; then cp ../../dist/xlsx.core.min.js .; fi go build goja.go for ext in xlsx xlsb biff8.xls xml.xls; do ./goja sheetjs.$$ext; done diff --git a/demos/altjs/README.md b/demos/altjs/README.md index f473866..55de233 100644 --- a/demos/altjs/README.md +++ b/demos/altjs/README.md @@ -51,7 +51,7 @@ Binary strings can be passed back and forth using `String.Encoding.isoLatin1`: /* parse sheetjs.xls */ let file_path = shared_dir.appendingPathComponent("sheetjs.xls"); let data: String! = try String(contentsOf: file_path, encoding: String.Encoding.isoLatin1); -context.setObject(data, forKeyedSubscript: "payload" as (NSCopying & NSObjectProtocol)!); +context.setObject(data, forKeyedSubscript: "payload" as (NSCopying & NSObjectProtocol)); src = "var wb = XLSX.read(payload, {type:'binary'});"; context.evaluateScript(src); @@ -108,14 +108,15 @@ target builds a very simple payload with the data. ## Duktape [Duktape](http://duktape.org/) is an embeddable JS engine written in C. The -amalgamation makes integration extremely simple! It supports `Buffer` natively: +amalgamation makes integration extremely simple! It supports `Buffer` natively +but should be sliced before processing: ```C /* parse a C char array as a workbook object */ duk_push_external_buffer(ctx); duk_config_buffer(ctx, -1, buf, len); duk_put_global_string(ctx, "buf"); -duk_eval_string_noresult("workbook = XLSX.read(buf, {type:'buffer'});"); +duk_eval_string_noresult("workbook = XLSX.read(buf.slice(0, buf.length), {type:'buffer'});"); /* write a workbook object to a C char array */ duk_eval_string(ctx, "XLSX.write(workbook, {type:'array', bookType:'xlsx'})"); @@ -157,9 +158,8 @@ wh.write(out, 0, ab.byteLength); wh.close(); ## Goja -Goja is a pure Go implementation of ECMAScript 5. As of this writing, there are -some issues with processing Unicode data, but the `xlsx.core.min.js` script can -be processed. `[]byte` should be transformed to a binary string in the engine: +Goja is a pure Go implementation of ECMAScript 5. `[]byte` should be converted +to a binary string in the engine: ```go /* read file */ diff --git a/demos/altjs/SheetJSCore.swift b/demos/altjs/SheetJSCore.swift index 1555278..4f56647 100755 --- a/demos/altjs/SheetJSCore.swift +++ b/demos/altjs/SheetJSCore.swift @@ -9,7 +9,7 @@ enum SJSError: Error { class SJSWorksheet { var context: JSContext!; - var wb: JSValue!; var ws: JSValue!; + var wb: JSValue; var ws: JSValue; var idx: Int32; func toCSV() throws -> String { @@ -26,7 +26,7 @@ class SJSWorksheet { class SJSWorkbook { var context: JSContext!; - var wb: JSValue!; var SheetNames: JSValue!; var Sheets: JSValue!; + var wb: JSValue; var SheetNames: JSValue; var Sheets: JSValue; func getSheetAtIndex(idx: Int32) throws -> SJSWorksheet { let SheetName: String = SheetNames.atIndex(Int(idx)).toString(); @@ -37,8 +37,8 @@ class SJSWorkbook { func writeBStr(bookType: String = "xlsx") throws -> String { let XLSX: JSValue! = context.objectForKeyedSubscript("XLSX"); context.evaluateScript(String(format: "var writeopts = {type:'binary', bookType:'%@'}", bookType)); - let writeopts: JSValue! = context.objectForKeyedSubscript("writeopts"); - let writefunc: JSValue! = XLSX.objectForKeyedSubscript("write"); + let writeopts: JSValue = context.objectForKeyedSubscript("writeopts"); + let writefunc: JSValue = XLSX.objectForKeyedSubscript("write"); return writefunc.call(withArguments: [wb, writeopts]).toString(); } @@ -58,7 +58,7 @@ class SheetJSCore { var context: JSContext! do { context = JSContext(); - context.exceptionHandler = { ctx, X in if let e = X { print(e.toString()); }; }; + context.exceptionHandler = { _, X in if let e = X { print(e.toString()!); }; }; context.evaluateScript("var global = (function(){ return this; }).call(null);"); context.evaluateScript("if(typeof wbs == 'undefined') wbs = [];"); let src = try String(contentsOfFile: "xlsx.full.min.js"); @@ -79,7 +79,7 @@ class SheetJSCore { } func readBStr(data: String) throws -> SJSWorkbook { - context.setObject(data, forKeyedSubscript: "payload" as (NSCopying & NSObjectProtocol)!); + context.setObject(data, forKeyedSubscript: "payload" as (NSCopying & NSObjectProtocol)); context.evaluateScript("var wb = XLSX.read(payload, {type:'binary'});"); let wb: JSValue! = context.objectForKeyedSubscript("wb"); if wb == nil { throw SJSError.badJSWorkbook; } diff --git a/demos/altjs/duktape.sh b/demos/altjs/duktape.sh index e9b4ca8..d0b5f81 100755 --- a/demos/altjs/duktape.sh +++ b/demos/altjs/duktape.sh @@ -1,5 +1,5 @@ #!/bin/bash -DUKTAPE_VER=2.2.0 +DUKTAPE_VER=2.6.0 if [ ! -e duktape-$DUKTAPE_VER ]; then if [ ! -e duktape-$DUKTAPE_VER.tar ]; then if [ ! -e duktape-$DUKTAPE_VER.tar.xz ]; then diff --git a/demos/altjs/goja.go b/demos/altjs/goja.go index 64a0843..6b29202 100644 --- a/demos/altjs/goja.go +++ b/demos/altjs/goja.go @@ -39,7 +39,7 @@ func main() { /* load library */ safe_run_file(vm, "shim.min.js") - safe_run_file(vm, "xlsx.core.min.js") + safe_run_file(vm, "xlsx.full.min.js") /* get version string */ v := eval_string(vm, "XLSX.version") diff --git a/demos/angular/README.md b/demos/angular/README.md index b7c9c56..4aa1b7e 100644 --- a/demos/angular/README.md +++ b/demos/angular/README.md @@ -10,6 +10,8 @@ into web pages with script tags: Strictly speaking, there should be no need for an Angular demo! You can proceed as you would with any other browser-friendly library. +This demo uses AngularJS 1.5.0. + ## Array of Objects @@ -87,13 +89,13 @@ function SheetJSImportDirective() { reader.onload = function (e) { /* read workbook */ - var bstr = e.target.result; - var workbook = XLSX.read(bstr, {type:'binary'}); + var ab = e.target.result; + var workbook = XLSX.read(ab); /* DO SOMETHING WITH workbook HERE */ }; - reader.readAsBinaryString(changeEvent.target.files[0]); + reader.readAsArrayBuffer(changeEvent.target.files[0]); }); } }; @@ -133,7 +135,7 @@ directive for a HTML File Input control. It also includes a sample service for export which adds an item to the export menu. The demo `SheetJSImportDirective` follows the prescription from the README for -File input controls using `readAsBinaryString`, converting to a suitable +File input controls using `readAsArrayBuffer`, converting to a suitable representation and updating the scope. `SheetJSExportService` exposes export functions for `XLSB` and `XLSX`. Other diff --git a/demos/angular/SheetJS-angular.js b/demos/angular/SheetJS-angular.js index 6e69d63..7175397 100644 --- a/demos/angular/SheetJS-angular.js +++ b/demos/angular/SheetJS-angular.js @@ -60,8 +60,8 @@ function SheetJSImportDirective() { reader.onload = function(e) { /* read workbook */ - var bstr = e.target.result; - var wb = XLSX.read(bstr, {type:'binary'}); + var ab = e.target.result; + var wb = XLSX.read(ab); /* grab first sheet */ var wsname = wb.SheetNames[0]; @@ -78,7 +78,7 @@ function SheetJSImportDirective() { data[r-1] = {}; for(i = 0; i < aoa[r].length; ++i) { if(aoa[r][i] == null) continue; - data[r-1][aoa[0][i]] = aoa[r][i] + data[r-1][aoa[0][i]] = aoa[r][i]; } } @@ -89,7 +89,7 @@ function SheetJSImportDirective() { }); }; - reader.readAsBinaryString(changeEvent.target.files[0]); + reader.readAsArrayBuffer(changeEvent.target.files[0]); }); } }; diff --git a/demos/angular/grid.html b/demos/angular/grid.html index f7cce9a..3f8687f 100644 --- a/demos/angular/grid.html +++ b/demos/angular/grid.html @@ -10,8 +10,8 @@ - - + + diff --git a/demos/angular/index.html b/demos/angular/index.html index b608679..b06978a 100644 --- a/demos/angular/index.html +++ b/demos/angular/index.html @@ -5,7 +5,7 @@ SheetJS + AngularJS - + diff --git a/demos/angular2/.eslintrc b/demos/angular2/.eslintrc new file mode 100644 index 0000000..31ada8c --- /dev/null +++ b/demos/angular2/.eslintrc @@ -0,0 +1,6 @@ +{ + "parser": "@typescript-eslint/parser", + "extends": [ + "eslint:recommended" + ] +} diff --git a/demos/angular2/.gitattributes b/demos/angular2/.gitattributes new file mode 100644 index 0000000..80fa1f4 --- /dev/null +++ b/demos/angular2/.gitattributes @@ -0,0 +1 @@ +*.*-ng* linguist-generated=true binary diff --git a/demos/angular2/.gitignore b/demos/angular2/.gitignore index dc9ebf8..10187c9 100644 --- a/demos/angular2/.gitignore +++ b/demos/angular2/.gitignore @@ -2,3 +2,6 @@ dist hooks SheetJSIonic SheetJSNS +angular.json +tsconfig.app.json +src/polyfills.ts diff --git a/demos/angular2/Makefile b/demos/angular2/Makefile index 64f5b0c..8cee869 100644 --- a/demos/angular2/Makefile +++ b/demos/angular2/Makefile @@ -1,22 +1,30 @@ -.PHONY: all -all: angular5 - -.PHONY: angular2 angular4 angular5 -angular2 angular4 angular5: - cp package.json-$@ package.json +.PHONY: ng2 ng4 ng5 ng6 ng7 ng8 ng9 ng10 ng11 ng12 +ng2 ng4 ng5 ng6 ng7 ng8 ng9 ng10 ng11 ng12: + rm -f angular.json tsconfig.app.json src/polyfills.ts + cp versions/package.json-$@ package.json + if [ -e versions/angular.json-$@ ]; then cp versions/angular.json-$@ angular.json; fi + if [ -e versions/tsconfig.app.json-$@ ]; then cp versions/tsconfig.app.json-$@ tsconfig.app.json; fi + if [ -e versions/polyfills.ts-$@ ]; then cp versions/polyfills.ts-$@ src/polyfills.ts; fi rm -rf node_modules npm install if [ ! -e node_modules ]; then mkdir node_modules; fi if [ ! -e node_modules/xlsx ]; then cd node_modules; ln -s ../../../ xlsx; cd -; fi npm run build +.PHONY: all +all: + for i in 2 4 5 6 7 8 9 10 11 12; do make ng$$i; done + .PHONY: ionic ionic: bash ./ionic.sh .PHONY: ios android browser -ios android browser: ionic +ios browser: ionic cd SheetJSIonic; ionic cordova emulate $@ { /* read workbook */ - const bstr: string = e.target.result; - const wb: XLSX.WorkBook = XLSX.read(bstr, {type: 'binary'}); + const ab: ArrayBuffer = e.target.result; + const wb: XLSX.WorkBook = XLSX.read(ab); /* grab first sheet */ const wsname: string = wb.SheetNames[0]; @@ -64,7 +64,7 @@ XLSX.writeFile(wb, 'SheetJS.xlsx'); /* save data */ this.data = (XLSX.utils.sheet_to_json(ws, {header: 1})); }; - reader.readAsBinaryString(target.files[0]); + reader.readAsArrayBuffer(target.files[0]); } ``` @@ -73,17 +73,20 @@ XLSX.writeFile(wb, 'SheetJS.xlsx'); Modules that work with Angular 2 largely work as-is with Angular 4+. Switching between versions is mostly a matter of installing the correct version of the core and associated modules. This demo includes `package.json-angular#` files -for Angular 2, Angular 4, and Angular 5 +for every major version of Angular up to 12. To test a particular Angular version, overwrite `package.json`: ```bash # switch to Angular 2 -$ cp package.json-angular2 package.json +$ cp package.json-ng2 package.json $ npm install $ ng serve ``` +Note: when running the demos, Angular 2 requires Node <= 14. This is due to a +tooling issue with `ng` and does not affect browser use. + ## XLSX Symbolic Link In this tree, `node_modules/xlsx` is a link pointing back to the root. This @@ -137,14 +140,14 @@ script performs the necessary installation steps. ``` -`@ionic-native/file` reads and writes files on devices. `readAsBinaryString` -returns strings that can be parsed with the `binary` type, and `array` type can +`@ionic-native/file` reads and writes files on devices. `readAsArrayBuffer` +returns `ArrayBuffer` objects suitable for `array` type, and `array` type can be converted to blobs that can be exported with `writeFile`: ```typescript /* read a workbook */ -const bstr: string = await this.file.readAsBinaryString(url, filename); -const wb: XLSX.WorkBook = XLSX.read(bstr, {type: 'binary'}); +const ab: ArrayBuffer = await this.file.readAsArrayBuffer(url, filename); +const wb: XLSX.WorkBook = XLSX.read(bstr, {type: 'array'}); /* write a workbook */ const wbout: ArrayBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); @@ -164,16 +167,19 @@ const XLSX = require("./xlsx.full.min.js"); ``` The `ISO_8859_1` encoding from the text module specifies `"binary"` strings. -`fs.File#readText` and `fs.File#writeText` reads and writes files: +`File#readText` and `File#writeText` reads and writes files: ```typescript /* read a workbook */ -const bstr: string = await file.readText(textModule.encoding.ISO_8859_1); +const bstr: string = await file.readText(encoding.ISO_8859_1); const wb = XLSX.read(bstr, { type: "binary" }); /* write a workbook */ const wbout: string = XLSX.write(wb, { bookType: 'xlsx', type: 'binary' }); -await file.writeText(wbout, textModule.encoding.ISO_8859_1); +await file.writeText(wbout, encoding.ISO_8859_1); ``` +Note: some versions of NativeScript do not properly support typed arrays or +binary strings. See + [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) diff --git a/demos/angular2/ionic-app.module.ts b/demos/angular2/ionic-app.module.ts new file mode 100644 index 0000000..5d92df0 --- /dev/null +++ b/demos/angular2/ionic-app.module.ts @@ -0,0 +1,22 @@ +/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +/* vim: set ts=2: */ +/* NOTE: this file exists because `File` must be added as a provider */ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { RouteReuseStrategy } from '@angular/router'; + +import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; + +import { AppComponent } from './app.component'; +import { AppRoutingModule } from './app-routing.module'; + +import { File } from '@ionic-native/file/ngx'; + +@NgModule({ + declarations: [AppComponent], + entryComponents: [], + imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], + providers: [File, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }], + bootstrap: [AppComponent], +}) +export class AppModule {} diff --git a/demos/angular2/ionic.sh b/demos/angular2/ionic.sh index 0afb5bb..efffac6 100755 --- a/demos/angular2/ionic.sh +++ b/demos/angular2/ionic.sh @@ -1,17 +1,16 @@ #!/bin/bash if [ ! -e SheetJSIonic ]; then - ionic start SheetJSIonic blank --cordova --no-git --no-link src/app/app.module.ts + cp ../ionic-app.module.ts src/app/app.module.ts cd - fi -cp ionic.ts SheetJSIonic/src/pages/home/home.ts -rm -f SheetJSIonic/src/pages/home/home.html +cp ionic.ts SheetJSIonic/src/app/home/home.page.ts diff --git a/demos/angular2/ionic.ts b/demos/angular2/ionic.ts index 0e2e39c..fedc321 100644 --- a/demos/angular2/ionic.ts +++ b/demos/angular2/ionic.ts @@ -1,19 +1,30 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ import { Component } from '@angular/core'; - +import { File } from '@ionic-native/file/ngx'; import * as XLSX from 'xlsx'; -import { File } from '@ionic-native/file'; type AOA = any[][]; @Component({ - selector: 'page-home', + selector: 'app-home', + //templateUrl: 'home.page.html', + styleUrls: ['home.page.scss'], template: ` -SheetJS Ionic Demo + + + SheetJS Ionic Demo + + + + + + + SheetJS Demo + + - @@ -23,7 +34,7 @@ type AOA = any[][]; - + @@ -33,18 +44,18 @@ type AOA = any[][]; export class HomePage { data: any[][] = [[1,2,3],[4,5,6]]; - constructor(public file: File) {}; + constructor(public file: File) {} - read(bstr: string) { + read(ab: ArrayBuffer) { /* read workbook */ - const wb: XLSX.WorkBook = XLSX.read(bstr, {type: 'binary'}); + const wb: XLSX.WorkBook = XLSX.read(new Uint8Array(ab), {type: 'array'}); /* grab first sheet */ const wsname: string = wb.SheetNames[0]; const ws: XLSX.WorkSheet = wb.Sheets[wsname]; /* save data */ - this.data = (XLSX.utils.sheet_to_json(ws, {header: 1})); + this.data = (XLSX.utils.sheet_to_json(ws, {header: 1}) as AOA); }; write(): XLSX.WorkBook { @@ -61,14 +72,14 @@ export class HomePage { /* File Input element for browser */ onFileChange(evt: any) { /* wire up file reader */ - const target: DataTransfer = (evt.target); - if (target.files.length !== 1) throw new Error('Cannot use multiple files'); + const target: DataTransfer = (evt.target as DataTransfer); + if (target.files.length !== 1) { throw new Error('Cannot use multiple files'); } const reader: FileReader = new FileReader(); reader.onload = (e: any) => { - const bstr: string = e.target.result; - this.read(bstr); + const ab: ArrayBuffer = e.target.result; + this.read(ab); }; - reader.readAsBinaryString(target.files[0]); + reader.readAsArrayBuffer(target.files[0]); }; /* Import button for mobile */ @@ -77,23 +88,22 @@ export class HomePage { const target: string = this.file.documentsDirectory || this.file.externalDataDirectory || this.file.dataDirectory || ''; const dentry = await this.file.resolveDirectoryUrl(target); const url: string = dentry.nativeURL || ''; - alert(`Attempting to read SheetJSIonic.xlsx from ${url}`) - const bstr: string = await this.file.readAsBinaryString(url, "SheetJSIonic.xlsx"); - this.read(bstr); + alert(`Attempting to read SheetJSIonic.xlsx from ${url}`); + const ab: ArrayBuffer = await this.file.readAsArrayBuffer(url, 'SheetJSIonic.xlsx'); + this.read(ab); } catch(e) { const m: string = e.message; - alert(m.match(/It was determined/) ? "Use File Input control" : `Error: ${m}`); + alert(m.match(/It was determined/) ? 'Use File Input control' : `Error: ${m}`); } }; /* Export button */ async export() { const wb: XLSX.WorkBook = this.write(); - const filename: string = "SheetJSIonic.xlsx"; + const filename = 'SheetJSIonic.xlsx'; try { /* generate Blob */ const wbout: ArrayBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); - const blob: Blob = new Blob([wbout], {type: 'application/octet-stream'}); /* find appropriate path for mobile */ const target: string = this.file.documentsDirectory || this.file.externalDataDirectory || this.file.dataDirectory || ''; @@ -101,14 +111,15 @@ export class HomePage { const url: string = dentry.nativeURL || ''; /* attempt to save blob to file */ - await this.file.writeFile(url, filename, blob, {replace: true}); + await this.file.writeFile(url, filename, wbout, {replace: true}); alert(`Wrote to SheetJSIonic.xlsx in ${url}`); } catch(e) { if(e.message.match(/It was determined/)) { /* in the browser, use writeFile */ XLSX.writeFile(wb, filename); + } else { + alert(`Error: ${e.message}`); } - else alert(`Error: ${e.message}`); } }; } diff --git a/demos/angular2/nscript.sh b/demos/angular2/nscript.sh index ef81500..f9f76ec 100755 --- a/demos/angular2/nscript.sh +++ b/demos/angular2/nscript.sh @@ -1,15 +1,10 @@ #!/bin/bash if [ ! -e SheetJSNS ]; then - tns create SheetJSNS --template nativescript-template-ng-tutorial + ns create SheetJSNS --ng cd SheetJSNS - tns plugin add nativescript-nodeify npm install xlsx - cd app - npm install xlsx - cd ../.. + cd .. fi -cp ../../dist/xlsx.full.min.js SheetJSNS/ -cp ../../dist/xlsx.full.min.js SheetJSNS/app/ -cp nsmain.ts SheetJSNS/app/main.ts -cp nscript.ts SheetJSNS/app/app.component.ts +<../../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 index 538660e..75e1956 100644 --- a/demos/angular2/nscript.ts +++ b/demos/angular2/nscript.ts @@ -1,21 +1,19 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ -import { Component } from "@angular/core"; -import * as dockModule from "tns-core-modules/ui/layouts/dock-layout"; -import * as buttonModule from "tns-core-modules/ui/button"; -import * as textModule from "tns-core-modules/text"; -import * as dialogs from "ui/dialogs"; -import * as fs from "tns-core-modules/file-system"; +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'; -/* NativeScript does not support import syntax for npm modules */ -const XLSX = require("./xlsx.full.min.js"); +import * as XLSX from './xlsx.full.min'; @Component({ - selector: "my-app", + selector: 'ns-app', template: ` + - @@ -25,6 +23,7 @@ const XLSX = require("./xlsx.full.min.js"); + ` }) @@ -37,16 +36,16 @@ export class AppComponent { /* Import button */ async import() { - const filename: string = "SheetJSNS.xlsx"; + const filename: string = "SheetJSNS.csv"; /* find appropriate path */ - const target: fs.Folder = fs.knownFolders.documents() || fs.knownFolders.ios.sharedPublic(); - const url: string = fs.path.normalize(target.path + "///" + filename); - const file: fs.File = fs.File.fromPath(url); + 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(textModule.encoding.ISO_8859_1); + const bstr: string = await file.readText(encoding.ISO_8859_1); /* read workbook */ const wb = XLSX.read(bstr, { type: "binary" }); @@ -57,27 +56,27 @@ export class AppComponent { /* update table */ this.html = XLSX.utils.sheet_to_html(ws); - dialogs.alert(`Attempting to read to SheetJSNS.xlsx in ${url}`); + Dialogs.alert(`Attempting to read to ${filename} in ${url}`); } catch(e) { - dialogs.alert(e.message); + Dialogs.alert(e.message); } }; /* Export button */ async export() { const wb = XLSX.read(this.html, { type: "string" }); - const filename: string = "SheetJSNS.xlsx"; + const filename: string = "SheetJSNS.csv"; /* generate binary string */ - const wbout: string = XLSX.write(wb, { bookType: 'xlsx', type: 'binary' }); + const wbout: string = XLSX.write(wb, { bookType: 'csv', type: 'binary' }); /* find appropriate path */ - const target: fs.Folder = fs.knownFolders.documents() || fs.knownFolders.ios.sharedPublic(); - const url: string = fs.path.normalize(target.path + "///" + filename); - const file: fs.File = fs.File.fromPath(url); + 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, textModule.encoding.ISO_8859_1); - dialogs.alert(`Wrote to SheetJSNS.xlsx in ${url}`); + await file.writeText(wbout, encoding.ISO_8859_1); + Dialogs.alert(`Wrote to ${filename} in ${url}`); }; } diff --git a/demos/angular2/nsmain.ts b/demos/angular2/nsmain.ts deleted file mode 100644 index d84762f..0000000 --- a/demos/angular2/nsmain.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { platformNativeScriptDynamic } from "nativescript-angular/platform"; -import { AppModule } from "./app.module"; - -/*! **************************************************************************** -Code based on @Microsoft/tslib - -Original license header: - -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -// tslint:disable -if (!('__awaiter' in global)) { - global['__awaiter'] = function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; -} - -if (!('__generator' in global)) { - global['__generator'] = function (thisArg, body) { - var _: any = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [0, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; -} - -platformNativeScriptDynamic().bootstrapModule(AppModule); diff --git a/demos/angular2/src/app/sheetjs.component.ts b/demos/angular2/src/app/sheetjs.component.ts index 57f1a4a..7551a10 100644 --- a/demos/angular2/src/app/sheetjs.component.ts +++ b/demos/angular2/src/app/sheetjs.component.ts @@ -9,6 +9,7 @@ type AOA = any[][]; @Component({ selector: 'sheetjs', template: ` +
Version: {{ver}}
@@ -25,6 +26,7 @@ export class SheetJSComponent { data: AOA = [ [1, 2], [3, 4] ]; wopts: XLSX.WritingOptions = { bookType: 'xlsx', type: 'array' }; fileName: string = 'SheetJS.xlsx'; + ver: string = XLSX.version; onFileChange(evt: any) { /* wire up file reader */ @@ -33,8 +35,8 @@ export class SheetJSComponent { const reader: FileReader = new FileReader(); reader.onload = (e: any) => { /* read workbook */ - const bstr: string = e.target.result; - const wb: XLSX.WorkBook = XLSX.read(bstr, {type: 'binary'}); + const ab: ArrayBuffer = e.target.result; + const wb: XLSX.WorkBook = XLSX.read(ab); /* grab first sheet */ const wsname: string = wb.SheetNames[0]; @@ -43,7 +45,7 @@ export class SheetJSComponent { /* save data */ this.data = (XLSX.utils.sheet_to_json(ws, {header: 1})); }; - reader.readAsBinaryString(target.files[0]); + reader.readAsArrayBuffer(target.files[0]); } export(): void { diff --git a/demos/angular2/src/environments/environment.prod.ts b/demos/angular2/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/demos/angular2/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/demos/angular2/src/environments/environment.ts b/demos/angular2/src/environments/environment.ts new file mode 100644 index 0000000..ffe8aed --- /dev/null +++ b/demos/angular2/src/environments/environment.ts @@ -0,0 +1,3 @@ +export const environment = { + production: false +}; diff --git a/demos/angular2/src/styles.css b/demos/angular2/src/styles.css new file mode 100644 index 0000000..90d4ee0 --- /dev/null +++ b/demos/angular2/src/styles.css @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/demos/angular2/versions/angular.json-ng10 b/demos/angular2/versions/angular.json-ng10 new file mode 100644 index 0000000..9e7228c --- /dev/null +++ b/demos/angular2/versions/angular.json-ng10 @@ -0,0 +1,125 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": true, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "sheetjs:build" + }, + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "sheetjs:serve" + }, + "configurations": { + "production": { + "devServerTarget": "sheetjs:serve:production" + } + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/angular.json-ng11 b/demos/angular2/versions/angular.json-ng11 new file mode 100644 index 0000000..a1563c1 --- /dev/null +++ b/demos/angular2/versions/angular.json-ng11 @@ -0,0 +1,124 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": true, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "sheetjs:build" + }, + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "sheetjs:serve" + }, + "configurations": { + "production": { + "devServerTarget": "sheetjs:serve:production" + } + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/angular.json-ng12 b/demos/angular2/versions/angular.json-ng12 new file mode 100644 index 0000000..69d02ea --- /dev/null +++ b/demos/angular2/versions/angular.json-ng12 @@ -0,0 +1,106 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": { + "@schematics/angular:application": { + "strict": true + } + }, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "initial", + "maximumWarning": "500kb", + "maximumError": "2mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" + } + ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + }, + "development": { + "browserTarget": "sheetjs:build:development" + } + }, + "defaultConfiguration": "development" + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/angular.json-ng6 b/demos/angular2/versions/angular.json-ng6 new file mode 100644 index 0000000..30e40df --- /dev/null +++ b/demos/angular2/versions/angular.json-ng6 @@ -0,0 +1,127 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "sheetjs:build" + }, + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.spec.json", + "karmaConfig": "src/karma.conf.js", + "styles": [ + "src/styles.css" + ], + "scripts": [], + "assets": [ + "src/favicon.ico", + "src/assets" + ] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "src/tsconfig.app.json", + "src/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } + }, + "sheetjs-e2e": { + "root": "e2e/", + "projectType": "application", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "sheetjs:serve" + }, + "configurations": { + "production": { + "devServerTarget": "sheetjs:serve:production" + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": "e2e/tsconfig.e2e.json", + "exclude": [ + "**/node_modules/**" + ] + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/angular.json-ng7 b/demos/angular2/versions/angular.json-ng7 new file mode 100644 index 0000000..be12951 --- /dev/null +++ b/demos/angular2/versions/angular.json-ng7 @@ -0,0 +1,136 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.app.json", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [], + "es5BrowserSupport": true + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "sheetjs:build" + }, + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "src/tsconfig.spec.json", + "karmaConfig": "src/karma.conf.js", + "styles": [ + "src/styles.css" + ], + "scripts": [], + "assets": [ + "src/favicon.ico", + "src/assets" + ] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "src/tsconfig.app.json", + "src/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } + }, + "sheetjs-e2e": { + "root": "e2e/", + "projectType": "application", + "prefix": "", + "architect": { + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "sheetjs:serve" + }, + "configurations": { + "production": { + "devServerTarget": "sheetjs:serve:production" + } + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": "e2e/tsconfig.e2e.json", + "exclude": [ + "**/node_modules/**" + ] + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/angular.json-ng8 b/demos/angular2/versions/angular.json-ng8 new file mode 100644 index 0000000..de608c0 --- /dev/null +++ b/demos/angular2/versions/angular.json-ng8 @@ -0,0 +1,126 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": false, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "sheetjs:build" + }, + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "sheetjs:serve" + }, + "configurations": { + "production": { + "devServerTarget": "sheetjs:serve:production" + } + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/angular.json-ng9 b/demos/angular2/versions/angular.json-ng9 new file mode 100644 index 0000000..9e7228c --- /dev/null +++ b/demos/angular2/versions/angular.json-ng9 @@ -0,0 +1,125 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "sheetjs": { + "root": "", + "sourceRoot": "src", + "projectType": "application", + "prefix": "app", + "schematics": {}, + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/sheetjs", + "index": "src/index.html", + "main": "src/main.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.app.json", + "aot": true, + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + }, + "configurations": { + "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] + } + } + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "sheetjs:build" + }, + "configurations": { + "production": { + "browserTarget": "sheetjs:build:production" + } + } + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "sheetjs:build" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "src/test.ts", + "polyfills": "src/polyfills.ts", + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/favicon.ico", + "src/assets" + ], + "styles": [ + "src/styles.css" + ], + "scripts": [] + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "tsconfig.app.json", + "tsconfig.spec.json", + "e2e/tsconfig.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + }, + "e2e": { + "builder": "@angular-devkit/build-angular:protractor", + "options": { + "protractorConfig": "e2e/protractor.conf.js", + "devServerTarget": "sheetjs:serve" + }, + "configurations": { + "production": { + "devServerTarget": "sheetjs:serve:production" + } + } + } + } + } + }, + "defaultProject": "sheetjs" +} diff --git a/demos/angular2/versions/package.json-ng10 b/demos/angular2/versions/package.json-ng10 new file mode 100644 index 0000000..fff68df --- /dev/null +++ b/demos/angular2/versions/package.json-ng10 @@ -0,0 +1,39 @@ +{ + "name": "angular10", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "~10.2.4", + "@angular/common": "~10.2.4", + "@angular/compiler": "~10.2.4", + + "@angular/core": "~10.2.4", + "@angular/forms": "~10.2.4", + + "@angular/platform-browser": "~10.2.4", + "@angular/platform-browser-dynamic": "~10.2.4", + + "@angular/router": "~10.2.4", + + + "rxjs": "~6.6.0", + "tslib": "^2.0.0", + "zone.js": "~0.10.2" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.1002.3", + "@angular/cli": "~10.2.3", + "@angular/compiler-cli": "~10.2.4", + + "@types/node": "^12.11.1", + "ts-node": "~8.3.0", + "tslint": "~6.1.0", + "typescript": "~4.0.2" + } +} diff --git a/demos/angular2/versions/package.json-ng11 b/demos/angular2/versions/package.json-ng11 new file mode 100644 index 0000000..9bb80a8 --- /dev/null +++ b/demos/angular2/versions/package.json-ng11 @@ -0,0 +1,39 @@ +{ + "name": "angular11", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "~11.2.14", + "@angular/common": "~11.2.14", + "@angular/compiler": "~11.2.14", + + "@angular/core": "~11.2.14", + "@angular/forms": "~11.2.14", + + "@angular/platform-browser": "~11.2.14", + "@angular/platform-browser-dynamic": "~11.2.14", + + "@angular/router": "~11.2.14", + + + "rxjs": "~6.6.0", + "tslib": "^2.0.0", + "zone.js": "~0.11.3" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.1102.13", + "@angular/cli": "~11.2.14", + "@angular/compiler-cli": "~11.2.14", + + "@types/node": "^12.11.1", + "ts-node": "~8.3.0", + "tslint": "~6.1.0", + "typescript": "~4.1.5" + } +} diff --git a/demos/angular2/versions/package.json-ng12 b/demos/angular2/versions/package.json-ng12 new file mode 100644 index 0000000..74df6c5 --- /dev/null +++ b/demos/angular2/versions/package.json-ng12 @@ -0,0 +1,39 @@ +{ + "name": "angular12", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "~12.2.0", + "@angular/common": "~12.2.0", + "@angular/compiler": "~12.2.0", + + "@angular/core": "~12.2.0", + "@angular/forms": "~12.2.0", + + "@angular/platform-browser": "~12.2.0", + "@angular/platform-browser-dynamic": "~12.2.0", + + "@angular/router": "~12.2.0", + + + "rxjs": "~6.6.0", + "tslib": "^2.3.0", + "zone.js": "~0.11.4" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~12.2.7", + "@angular/cli": "~12.2.7", + "@angular/compiler-cli": "~12.2.0", + + "@types/node": "^12.11.1", + + + "typescript": "~4.3.5" + } +} diff --git a/demos/angular2/package.json-angular2 b/demos/angular2/versions/package.json-ng2 similarity index 87% rename from demos/angular2/package.json-angular2 rename to demos/angular2/versions/package.json-ng2 index 84f0026..c6cdfe9 100644 --- a/demos/angular2/package.json-angular2 +++ b/demos/angular2/versions/package.json-ng2 @@ -9,7 +9,6 @@ }, "private": true, "dependencies": { - "@angular/animations": "^4.0.0", "@angular/common": "~2.4.1", "@angular/compiler": "~2.4.1", "@angular/compiler-cli": "^2.4.1", @@ -28,8 +27,8 @@ }, "devDependencies": { "@angular/cli": "1.1.2", - "@angular/compiler-cli": "^4.0.0", - "@angular/language-service": "^4.0.0", + "@angular/compiler-cli": "^2.0.0", + "@angular/language-service": "^2.0.0", "@types/node": "~6.0.60", "ts-node": "~3.0.4", "tslint": "~5.3.2", diff --git a/demos/angular2/package.json-angular4 b/demos/angular2/versions/package.json-ng4 similarity index 100% rename from demos/angular2/package.json-angular4 rename to demos/angular2/versions/package.json-ng4 diff --git a/demos/angular2/package.json-angular5 b/demos/angular2/versions/package.json-ng5 similarity index 100% rename from demos/angular2/package.json-angular5 rename to demos/angular2/versions/package.json-ng5 diff --git a/demos/angular2/versions/package.json-ng6 b/demos/angular2/versions/package.json-ng6 new file mode 100644 index 0000000..a6df172 --- /dev/null +++ b/demos/angular2/versions/package.json-ng6 @@ -0,0 +1,39 @@ +{ + "name": "angular6", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "^6.1.0", + "@angular/common": "^6.1.0", + "@angular/compiler": "^6.1.0", + + "@angular/core": "^6.1.0", + "@angular/forms": "^6.1.0", + "@angular/http": "^6.1.0", + "@angular/platform-browser": "^6.1.0", + "@angular/platform-browser-dynamic": "^6.1.0", + + "@angular/router": "^6.1.0", + "core-js": "^2.5.4", + + "rxjs": "~6.2.0", + + "zone.js": "~0.8.26" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.8.0", + "@angular/cli": "~6.2.9", + "@angular/compiler-cli": "^6.1.0", + "@angular/language-service": "^6.1.0", + "@types/node": "~8.9.4", + "ts-node": "~7.0.0", + "tslint": "~5.11.0", + "typescript": "~2.9.2" + } +} diff --git a/demos/angular2/versions/package.json-ng7 b/demos/angular2/versions/package.json-ng7 new file mode 100644 index 0000000..841dab7 --- /dev/null +++ b/demos/angular2/versions/package.json-ng7 @@ -0,0 +1,39 @@ +{ + "name": "angular7", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "~7.2.0", + "@angular/common": "~7.2.0", + "@angular/compiler": "~7.2.0", + + "@angular/core": "~7.2.0", + "@angular/forms": "~7.2.0", + + "@angular/platform-browser": "~7.2.0", + "@angular/platform-browser-dynamic": "~7.2.0", + + "@angular/router": "~7.2.0", + "core-js": "^2.5.4", + + "rxjs": "~6.3.3", + "tslib": "^1.9.0", + "zone.js": "~0.8.26" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.13.0", + "@angular/cli": "~7.3.10", + "@angular/compiler-cli": "~7.2.0", + "@angular/language-service": "~7.2.0", + "@types/node": "~8.9.4", + "ts-node": "~7.0.0", + "tslint": "~5.11.0", + "typescript": "~3.2.2" + } +} diff --git a/demos/angular2/versions/package.json-ng8 b/demos/angular2/versions/package.json-ng8 new file mode 100644 index 0000000..5643841 --- /dev/null +++ b/demos/angular2/versions/package.json-ng8 @@ -0,0 +1,39 @@ +{ + "name": "angular8", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "~8.2.14", + "@angular/common": "~8.2.14", + "@angular/compiler": "~8.2.14", + + "@angular/core": "~8.2.14", + "@angular/forms": "~8.2.14", + + "@angular/platform-browser": "~8.2.14", + "@angular/platform-browser-dynamic": "~8.2.14", + + "@angular/router": "~8.2.14", + + + "rxjs": "~6.4.0", + "tslib": "^1.10.0", + "zone.js": "~0.9.1" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.803.29", + "@angular/cli": "~8.3.29", + "@angular/compiler-cli": "~8.2.14", + "@angular/language-service": "~8.2.14", + "@types/node": "~8.9.4", + "ts-node": "~7.0.0", + "tslint": "~5.15.0", + "typescript": "~3.5.3" + } +} diff --git a/demos/angular2/versions/package.json-ng9 b/demos/angular2/versions/package.json-ng9 new file mode 100644 index 0000000..fe6c382 --- /dev/null +++ b/demos/angular2/versions/package.json-ng9 @@ -0,0 +1,39 @@ +{ + "name": "angular9", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build" + }, + "private": true, + "dependencies": { + "@angular/animations": "~9.1.13", + "@angular/common": "~9.1.13", + "@angular/compiler": "~9.1.13", + + "@angular/core": "~9.1.13", + "@angular/forms": "~9.1.13", + + "@angular/platform-browser": "~9.1.13", + "@angular/platform-browser-dynamic": "~9.1.13", + + "@angular/router": "~9.1.13", + + + "rxjs": "~6.5.4", + "tslib": "^1.10.0", + "zone.js": "~0.10.2" + }, + "devDependencies": { + "@angular-devkit/build-angular": "~0.901.15", + "@angular/cli": "~9.1.15", + "@angular/compiler-cli": "~9.1.13", + + "@types/node": "^12.11.1", + "ts-node": "~8.3.0", + "tslint": "~6.1.0", + "typescript": "~3.8.3" + } +} diff --git a/demos/angular2/versions/polyfills.ts-ng10 b/demos/angular2/versions/polyfills.ts-ng10 new file mode 100644 index 0000000..741c886 --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng10 @@ -0,0 +1 @@ +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng11 b/demos/angular2/versions/polyfills.ts-ng11 new file mode 100644 index 0000000..741c886 --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng11 @@ -0,0 +1 @@ +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng12 b/demos/angular2/versions/polyfills.ts-ng12 new file mode 100644 index 0000000..aa09a9f --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng12 @@ -0,0 +1 @@ +import 'zone.js'; diff --git a/demos/angular2/src/polyfills.ts b/demos/angular2/versions/polyfills.ts-ng2 similarity index 100% rename from demos/angular2/src/polyfills.ts rename to demos/angular2/versions/polyfills.ts-ng2 diff --git a/demos/angular2/versions/polyfills.ts-ng4 b/demos/angular2/versions/polyfills.ts-ng4 new file mode 100644 index 0000000..2143ebf --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng4 @@ -0,0 +1,3 @@ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng5 b/demos/angular2/versions/polyfills.ts-ng5 new file mode 100644 index 0000000..2143ebf --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng5 @@ -0,0 +1,3 @@ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng6 b/demos/angular2/versions/polyfills.ts-ng6 new file mode 100644 index 0000000..2143ebf --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng6 @@ -0,0 +1,3 @@ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng7 b/demos/angular2/versions/polyfills.ts-ng7 new file mode 100644 index 0000000..2143ebf --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng7 @@ -0,0 +1,3 @@ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng8 b/demos/angular2/versions/polyfills.ts-ng8 new file mode 100644 index 0000000..741c886 --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng8 @@ -0,0 +1 @@ +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/polyfills.ts-ng9 b/demos/angular2/versions/polyfills.ts-ng9 new file mode 100644 index 0000000..741c886 --- /dev/null +++ b/demos/angular2/versions/polyfills.ts-ng9 @@ -0,0 +1 @@ +import 'zone.js/dist/zone'; diff --git a/demos/angular2/versions/tsconfig.app.json-ng10 b/demos/angular2/versions/tsconfig.app.json-ng10 new file mode 100644 index 0000000..f758d98 --- /dev/null +++ b/demos/angular2/versions/tsconfig.app.json-ng10 @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/demos/angular2/versions/tsconfig.app.json-ng11 b/demos/angular2/versions/tsconfig.app.json-ng11 new file mode 100644 index 0000000..f758d98 --- /dev/null +++ b/demos/angular2/versions/tsconfig.app.json-ng11 @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/demos/angular2/versions/tsconfig.app.json-ng12 b/demos/angular2/versions/tsconfig.app.json-ng12 new file mode 100644 index 0000000..f758d98 --- /dev/null +++ b/demos/angular2/versions/tsconfig.app.json-ng12 @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/demos/angular2/versions/tsconfig.app.json-ng8 b/demos/angular2/versions/tsconfig.app.json-ng8 new file mode 100644 index 0000000..565a11a --- /dev/null +++ b/demos/angular2/versions/tsconfig.app.json-ng8 @@ -0,0 +1,18 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "src/test.ts", + "src/**/*.spec.ts" + ] +} diff --git a/demos/angular2/versions/tsconfig.app.json-ng9 b/demos/angular2/versions/tsconfig.app.json-ng9 new file mode 100644 index 0000000..f758d98 --- /dev/null +++ b/demos/angular2/versions/tsconfig.app.json-ng9 @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "files": [ + "src/main.ts", + "src/polyfills.ts" + ], + "include": [ + "src/**/*.d.ts" + ] +} diff --git a/demos/browserify/app.js b/demos/browserify/app.js index e2b629d..1bc148e 100644 --- a/demos/browserify/app.js +++ b/demos/browserify/app.js @@ -3,13 +3,6 @@ var XLSX = require('../../'); // test against development version //var XLSX = require('xlsx'); // use in production /*jshint browser:true */ /*global require */ -var X = XLSX; -var XW = { - /* worker message */ - msg: 'xlsx', - /* worker scripts */ - worker: './worker.min.js' -}; var global_wb; @@ -27,7 +20,7 @@ var process_wb = (function() { var to_json = function to_json(workbook) { var result = {}; workbook.SheetNames.forEach(function(sheetName) { - var roa = X.utils.sheet_to_json(workbook.Sheets[sheetName]); + var roa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]); if(roa.length) result[sheetName] = roa; }); return JSON.stringify(result, 2, 2); @@ -36,7 +29,7 @@ var process_wb = (function() { var to_csv = function to_csv(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var csv = X.utils.sheet_to_csv(workbook.Sheets[sheetName]); + var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]); if(csv.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -49,7 +42,7 @@ var process_wb = (function() { var to_fmla = function to_fmla(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var formulae = X.utils.get_formulae(workbook.Sheets[sheetName]); + var formulae = XLSX.utils.get_formulae(workbook.Sheets[sheetName]); if(formulae.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -62,7 +55,7 @@ var process_wb = (function() { var to_html = function to_html(workbook) { HTMLOUT.innerHTML = ""; workbook.SheetNames.forEach(function(sheetName) { - var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); + var htmlstr = XLSX.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); HTMLOUT.innerHTML += htmlstr; }); return ""; @@ -89,7 +82,7 @@ var b64it = window.b64it = (function() { var tarea = document.getElementById('b64data'); return function b64it() { if(typeof console !== 'undefined') console.log("onload", new Date()); - var wb = X.read(tarea.value, {type:'base64', WTF:false}); + var wb = XLSX.read(tarea.value, {type:'base64', WTF:false}); process_wb(wb); }; })(); @@ -100,12 +93,12 @@ var do_file = (function() { if(!use_worker) domwork.disabled = !(domwork.checked = false); var xw = function xw(data, cb) { - var worker = new Worker(XW.worker); + var worker = new Worker('./worker.min.js'); 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; + case 'xlsx': cb(JSON.parse(e.data.d)); break; } }; worker.postMessage({d:data,b:'array'}); @@ -120,7 +113,7 @@ var do_file = (function() { var data = e.target.result; data = new Uint8Array(data); if(use_worker) xw(data, process_wb); - else process_wb(X.read(data, {type: 'array'})); + else process_wb(XLSX.read(data, {type: 'array'})); }; reader.readAsArrayBuffer(f); }; diff --git a/demos/datagrid/index.html b/demos/datagrid/index.html index 158a798..157dab2 100644 --- a/demos/datagrid/index.html +++ b/demos/datagrid/index.html @@ -47,7 +47,6 @@ a { text-decoration: none } /* eslint no-use-before-define:0 */ /*global Uint8Array, Uint16Array, ArrayBuffer */ /*global XLSX */ -var X = XLSX; var cDg; @@ -86,7 +85,7 @@ var do_file = (function() { if(typeof console !== 'undefined') console.log("onload", new Date()); var data = e.target.result; data = new Uint8Array(data); - process_wb(X.read(data, {type: 'array'})); + process_wb(XLSX.read(data, {type: 'array'})); }; reader.readAsArrayBuffer(f); }; diff --git a/demos/oldie/README.md b/demos/oldie/README.md index 205517e..02ede9d 100644 --- a/demos/oldie/README.md +++ b/demos/oldie/README.md @@ -16,14 +16,12 @@ IE10 and IE11 support the standard HTML5 FileReader API: function handle_fr(e) { var files = e.target.files, f = files[0]; var reader = new FileReader(); - var rABS = !!reader.readAsBinaryString; reader.onload = function(e) { - var data = e.target.result; - if(!rABS) data = new Uint8Array(data); - var wb = XLSX.read(data, {type: rABS ? 'binary' : 'array'}); + var data = new Uint8Array(e.target.result); + var wb = XLSX.read(data, {type: 'array'}); process_wb(wb); }; - if(rABS) reader.readAsBinaryString(f); else reader.readAsArrayBuffer(f); + reader.readAsArrayBuffer(f); } input_dom_element.addEventListener('change', handle_fr, false); ``` @@ -42,7 +40,7 @@ function handle_ie() { var path = input_dom_element.value; var bstr = IE_LoadFile(path); /* read workbook */ - var wb = XLSX.read(bstr, {type:'binary'}); + var wb = XLSX.read(bstr, {type: 'binary'}); /* DO SOMETHING WITH workbook HERE */ } input_dom_element.attachEvent('onchange', handle_ie); diff --git a/demos/oldie/index.html b/demos/oldie/index.html index b6d214f..ca511fa 100644 --- a/demos/oldie/index.html +++ b/demos/oldie/index.html @@ -95,20 +95,19 @@ function process_wb(wb) { function handle_ie() { var path = input_dom_element.value; var data = IE_LoadFile(path); - var wb = XLSX.read(data, {type:'binary'}); + var wb = XLSX.read(data, {type: 'binary'}); process_wb(wb); } function handle_fr(e) { var files = e.target.files, f = files[0]; var reader = new FileReader(); - var rABS = !!reader.readAsBinaryString; reader.onload = function(e) { var data = e.target.result; - if(!rABS) data = new Uint8Array(data); - var wb = XLSX.read(data, {type: rABS ? 'binary' : 'array'}); + data = new Uint8Array(data); + var wb = XLSX.read(data, {type: 'array'}); process_wb(wb); }; - if(rABS) reader.readAsBinaryString(f); else reader.readAsArrayBuffer(f); + reader.readAsArrayBuffer(f); } var handler = typeof IE_LoadFile !== 'undefined' ? handle_ie : handle_fr; if(input_dom_element.attachEvent) input_dom_element.attachEvent('onchange', handler); diff --git a/demos/requirejs/app.js b/demos/requirejs/app.js index ea6dc98..264a094 100644 --- a/demos/requirejs/app.js +++ b/demos/requirejs/app.js @@ -1,7 +1,5 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ require(["xlsx"], function(XLSX2) { -console.log(XLSX2); -var X = XLSX2; var global_wb; @@ -19,7 +17,7 @@ var process_wb = (function() { var to_json = function to_json(workbook) { var result = {}; workbook.SheetNames.forEach(function(sheetName) { - var roa = X.utils.sheet_to_json(workbook.Sheets[sheetName]); + var roa = XLSX2.utils.sheet_to_json(workbook.Sheets[sheetName]); if(roa.length) result[sheetName] = roa; }); return JSON.stringify(result, 2, 2); @@ -28,7 +26,7 @@ var process_wb = (function() { var to_csv = function to_csv(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var csv = X.utils.sheet_to_csv(workbook.Sheets[sheetName]); + var csv = XLSX2.utils.sheet_to_csv(workbook.Sheets[sheetName]); if(csv.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -41,7 +39,7 @@ var process_wb = (function() { var to_fmla = function to_fmla(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var formulae = X.utils.get_formulae(workbook.Sheets[sheetName]); + var formulae = XLSX2.utils.get_formulae(workbook.Sheets[sheetName]); if(formulae.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -54,7 +52,7 @@ var process_wb = (function() { var to_html = function to_html(workbook) { HTMLOUT.innerHTML = ""; workbook.SheetNames.forEach(function(sheetName) { - var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); + var htmlstr = XLSX2.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); HTMLOUT.innerHTML += htmlstr; }); return ""; @@ -81,7 +79,7 @@ var b64it = window.b64it = (function() { var tarea = document.getElementById('b64data'); return function b64it() { if(typeof console !== 'undefined') console.log("onload", new Date()); - var wb = X.read(tarea.value, {type:'base64', WTF:false}); + var wb = XLSX2.read(tarea.value, {type:'base64', WTF:false}); process_wb(wb); }; })(); @@ -112,7 +110,7 @@ var do_file = (function() { var data = e.target.result; data = new Uint8Array(data); if(use_worker) xw(data, process_wb); - else process_wb(X.read(data, {type: 'array'})); + else process_wb(XLSX2.read(data, {type: 'array'})); }; reader.readAsArrayBuffer(f); }; diff --git a/demos/rollup/Makefile b/demos/rollup/Makefile index bea7264..9b7a745 100644 --- a/demos/rollup/Makefile +++ b/demos/rollup/Makefile @@ -19,5 +19,5 @@ worker.min.js: worker.js .PHONY: init init: - @npm install rollup-plugin-node-resolve rollup-plugin-commonjs + #@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/app.js b/demos/rollup/app.js index 73f9158..c08410b 100644 --- a/demos/rollup/app.js +++ b/demos/rollup/app.js @@ -2,7 +2,6 @@ /*jshint browser:true */ /*global XLSX */ import XLSX from 'xlsx'; -var X = XLSX; var global_wb; @@ -20,7 +19,7 @@ var process_wb = (function() { var to_json = function to_json(workbook) { var result = {}; workbook.SheetNames.forEach(function(sheetName) { - var roa = X.utils.sheet_to_json(workbook.Sheets[sheetName]); + var roa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]); if(roa.length) result[sheetName] = roa; }); return JSON.stringify(result, 2, 2); @@ -29,7 +28,7 @@ var process_wb = (function() { var to_csv = function to_csv(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var csv = X.utils.sheet_to_csv(workbook.Sheets[sheetName]); + var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]); if(csv.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -42,7 +41,7 @@ var process_wb = (function() { var to_fmla = function to_fmla(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var formulae = X.utils.get_formulae(workbook.Sheets[sheetName]); + var formulae = XLSX.utils.get_formulae(workbook.Sheets[sheetName]); if(formulae.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -55,7 +54,7 @@ var process_wb = (function() { var to_html = function to_html(workbook) { HTMLOUT.innerHTML = ""; workbook.SheetNames.forEach(function(sheetName) { - var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); + var htmlstr = XLSX.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); HTMLOUT.innerHTML += htmlstr; }); return ""; @@ -82,7 +81,7 @@ var b64it = window.b64it = (function() { var tarea = document.getElementById('b64data'); return function b64it() { if(typeof console !== 'undefined') console.log("onload", new Date()); - var wb = X.read(tarea.value, {type:'base64', WTF:false}); + var wb = XLSX.read(tarea.value, {type:'base64', WTF:false}); process_wb(wb); }; })(); @@ -93,12 +92,12 @@ var do_file = (function() { if(!use_worker) domwork.disabled = !(domwork.checked = false); var xw = function xw(data, cb) { - var worker = new Worker(XW.worker); + 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 XW.msg: cb(JSON.parse(e.data.d)); break; + case 'xlsx': cb(JSON.parse(e.data.d)); break; } }; worker.postMessage({d:data,b:'array'}); @@ -113,7 +112,7 @@ var do_file = (function() { var data = e.target.result; data = new Uint8Array(data); if(use_worker) xw(data, process_wb); - else process_wb(X.read(data, {type: 'array'})); + else process_wb(XLSX.read(data, {type: 'array'})); }; reader.readAsArrayBuffer(f); }; diff --git a/demos/rollup/rollup.config.js b/demos/rollup/rollup.config.js index 3b62c00..d624d06 100644 --- a/demos/rollup/rollup.config.js +++ b/demos/rollup/rollup.config.js @@ -1,13 +1,12 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; export default { input: 'app.js', output: { file: 'rollup.js', format: 'iife' }, - entry: 'app.js', //dest: 'rollup.js', plugins: [ resolve({ @@ -16,5 +15,4 @@ export default { }), commonjs() ], - format: 'iife' }; diff --git a/demos/rollup/rollup.config.node.js b/demos/rollup/rollup.config.node.js index 7aaf1b1..4c01f4c 100644 --- a/demos/rollup/rollup.config.node.js +++ b/demos/rollup/rollup.config.node.js @@ -1,19 +1,18 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; export default { input: 'main.js', output: { file: 'rollup.node.js', format: 'cjs' }, - entry: 'main.js', //dest: 'rollup.node.js', plugins: [ resolve({ - module: false + module: false, + browser: true, }), commonjs() ], - format: 'cjs' }; diff --git a/demos/rollup/rollup.config.worker.js b/demos/rollup/rollup.config.worker.js index 966332c..46286d2 100644 --- a/demos/rollup/rollup.config.worker.js +++ b/demos/rollup/rollup.config.worker.js @@ -1,13 +1,12 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -import resolve from 'rollup-plugin-node-resolve'; -import commonjs from 'rollup-plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; export default { input: 'xlsxworker.js', output: { file: 'worker.js', format: 'iife' }, - entry: 'xlsxworker.js', //dest: 'worker.js', plugins: [ resolve({ @@ -16,5 +15,4 @@ export default { }), commonjs() ], - format: 'iife' }; diff --git a/demos/rollup/rollup.html b/demos/rollup/rollup.html index 86692f9..f597307 100644 --- a/demos/rollup/rollup.html +++ b/demos/rollup/rollup.html @@ -45,14 +45,6 @@ Use Web Workers: (when available)

- diff --git a/demos/systemjs/main.js b/demos/systemjs/main.js index eb17fcd..c29c394 100644 --- a/demos/systemjs/main.js +++ b/demos/systemjs/main.js @@ -2,7 +2,6 @@ /*jshint browser:true */ /*global XLSX */ var XLSX = require('xlsx'); -var X = XLSX; var global_wb; @@ -20,7 +19,7 @@ var process_wb = (function() { var to_json = function to_json(workbook) { var result = {}; workbook.SheetNames.forEach(function(sheetName) { - var roa = X.utils.sheet_to_json(workbook.Sheets[sheetName]); + var roa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]); if(roa.length) result[sheetName] = roa; }); return JSON.stringify(result, 2, 2); @@ -29,7 +28,7 @@ var process_wb = (function() { var to_csv = function to_csv(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var csv = X.utils.sheet_to_csv(workbook.Sheets[sheetName]); + var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]); if(csv.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -42,7 +41,7 @@ var process_wb = (function() { var to_fmla = function to_fmla(workbook) { var result = []; workbook.SheetNames.forEach(function(sheetName) { - var formulae = X.utils.get_formulae(workbook.Sheets[sheetName]); + var formulae = XLSX.utils.get_formulae(workbook.Sheets[sheetName]); if(formulae.length){ result.push("SHEET: " + sheetName); result.push(""); @@ -55,7 +54,7 @@ var process_wb = (function() { var to_html = function to_html(workbook) { HTMLOUT.innerHTML = ""; workbook.SheetNames.forEach(function(sheetName) { - var htmlstr = X.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); + var htmlstr = XLSX.write(workbook, {sheet:sheetName, type:'string', bookType:'html'}); HTMLOUT.innerHTML += htmlstr; }); return ""; @@ -82,7 +81,7 @@ var b64it = window.b64it = (function() { var tarea = document.getElementById('b64data'); return function b64it() { if(typeof console !== 'undefined') console.log("onload", new Date()); - var wb = X.read(tarea.value, {type:'base64', WTF:false}); + var wb = XLSX.read(tarea.value, {type:'base64', WTF:false}); process_wb(wb); }; })(); @@ -95,7 +94,7 @@ var do_file = (function() { if(typeof console !== 'undefined') console.log("onload", new Date()); var data = e.target.result; data = new Uint8Array(data); - process_wb(X.read(data, {type: 'array'})); + process_wb(XLSX.read(data, {type: 'array'})); }; reader.readAsArrayBuffer(f); }; diff --git a/docbits/11_demos.md b/docbits/11_demos.md index 1bae7ed..48f661a 100644 --- a/docbits/11_demos.md +++ b/docbits/11_demos.md @@ -4,7 +4,7 @@ The [`demos` directory](demos/) includes sample projects for: **Frameworks and APIs** - [`angularjs`](demos/angular/) -- [`angular 2 / 4 / 5 / 6 and ionic`](demos/angular2/) +- [`angular and ionic`](demos/angular2/) - [`knockout`](demos/knockout/) - [`meteor`](demos/meteor/) - [`react and react-native`](demos/react/) diff --git a/docbits/20_import.md b/docbits/20_import.md index 1dbffdd..e75a6e3 100644 --- a/docbits/20_import.md +++ b/docbits/20_import.md @@ -87,8 +87,7 @@ req.open("GET", url, true); req.responseType = "arraybuffer"; req.onload = function(e) { - var data = new Uint8Array(req.response); - var workbook = XLSX.read(data, {type:"array"}); + var workbook = XLSX.read(req.response); /* DO SOMETHING WITH workbook HERE */ } @@ -101,16 +100,29 @@ req.send();
Browser drag-and-drop (click to show) -Drag-and-drop uses the HTML5 `FileReader` API. +For modern browsers, `Blob#arrayBuffer` can read data from files: + +```js +async function handleDropAsync(e) { + e.stopPropagation(); e.preventDefault(); + const f = evt.dataTransfer.files[0]; + const data = await f.arrayBuffer(); + const workbook = XLSX.read(data); + + /* DO SOMETHING WITH workbook HERE */ +} +drop_dom_element.addEventListener('drop', handleDropAsync, false); +``` + +For maximal compatibility, the `FileReader` API should be used: ```js function handleDrop(e) { e.stopPropagation(); e.preventDefault(); - var files = e.dataTransfer.files, f = files[0]; + var f = e.dataTransfer.files[0]; var reader = new FileReader(); reader.onload = function(e) { - var data = new Uint8Array(e.target.result); - var workbook = XLSX.read(data, {type: 'array'}); + var workbook = XLSX.read(e.target.result); /* DO SOMETHING WITH workbook HERE */ }; @@ -124,16 +136,30 @@ drop_dom_element.addEventListener('drop', handleDrop, false);
Browser file upload form element (click to show) -Data from file input elements can be processed using the same `FileReader` API -as in the drag-and-drop example: +Data from file input elements can be processed using the same APIs as in the +drag-and-drop example. + +Using `Blob#arrayBuffer`: + +```js +async function handleFileAsync(e) { + const file = evt.target.files[0]; + const data = await file.arrayBuffer(); + const workbook = XLSX.read(data); + + /* DO SOMETHING WITH workbook HERE */ +} +input_dom_element.addEventListener('change', handleFileAsync, false); +``` + +Using `FileReader`: ```js function handleFile(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 workbook = XLSX.read(data, {type: 'array'}); + var workbook = XLSX.read(e.target.result); /* DO SOMETHING WITH workbook HERE */ }; diff --git a/index.html b/index.html index bf422ad..e49a11a 100644 --- a/index.html +++ b/index.html @@ -41,7 +41,6 @@ Output Format:
Advanced Demo Options: Use Web Workers: (when available) -Use readAsBinaryString: (when available)

 
@@ -58,13 +57,6 @@ Use readAsBinaryString: (when available)