├── tests ├── shim.js ├── xlsx.mjs ├── xlsx.core.min.js ├── xlsx.full.min.js ├── testA.lst ├── make_fixtures.js └── write.html ├── .eslintignore ├── bits ├── .npmignore ├── 01_version.js ├── 03_consts.js ├── 00_header.js ├── 99_footer.js ├── 98_exports.js ├── 09_types.js ├── 60_macrovba.js ├── 59_vba.js ├── 54_drawing.js ├── 56_cmntcommon.js ├── 82_sheeter.js ├── 26_crypto.js ├── 65_fods.js ├── 04_base64.js └── 43_sstbin.js ├── demos ├── vue │ ├── package.json │ ├── shim.js │ ├── static │ │ ├── shim.js │ │ └── xlsx.full.min.js │ ├── .gitignore │ ├── xlsx.full.min.js │ ├── screen.png │ ├── nuxt.config.js │ ├── Makefile │ └── weex.sh ├── xhr │ ├── .gitignore │ ├── xlsx.full.min.js │ ├── Makefile │ ├── package.json │ └── server.js ├── angular │ ├── shim.js │ ├── xlsx.core.min.js │ └── xlsx.full.min.js ├── database │ ├── .gitignore │ ├── xlsx.full.min.js │ ├── .eslintrc │ ├── Makefile │ ├── SheetJSMongo.js │ ├── SheetJSStorage.js │ ├── SheetJSForage.js │ ├── LowDBTest.js │ ├── SheetJSLowDB.js │ └── LocalStorage.html ├── datagrid │ ├── shim.js │ └── xlsx.full.min.js ├── headless │ ├── .gitignore │ ├── sheetjs.xlsx │ ├── chromeless.js │ ├── puppeteer.js │ ├── phantomjs.js │ ├── slimerjs.js │ └── README.md ├── knockout │ ├── shim.js │ └── xlsx.full.min.js ├── typescript │ ├── .gitignore │ ├── index.html │ ├── tsconfig.json │ ├── Makefile │ ├── demo.js │ ├── src │ │ └── index.js │ ├── tslint.json │ ├── lib │ │ └── index.ts │ └── package.json ├── parcel │ ├── .gitignore │ ├── Makefile │ └── README.md ├── react │ ├── pages │ │ ├── .gitignore │ │ └── index.js │ ├── .gitignore │ ├── screen.png │ ├── nexthdr.js │ ├── native.sh │ ├── NOTES.md │ ├── Makefile │ └── index.html ├── xspreadsheet │ ├── shim.js │ └── xlsx.full.min.js ├── function │ ├── Firebase │ │ ├── firebase.json │ │ ├── functions │ │ │ ├── .gitignore │ │ │ ├── package.json │ │ │ └── index.js │ │ └── .gitignore │ ├── host.json │ ├── .eslintrc │ ├── local.settings.json │ ├── AzureHTTPTrigger │ │ ├── function.json │ │ └── index.js │ ├── LambdaProxy │ │ └── template.yaml │ ├── Makefile │ └── mcstream.js ├── oldie │ ├── shim.min.js │ ├── xlsx.full.min.js │ ├── download.png │ ├── downloadify.swf │ └── base64.min.js ├── server │ ├── .gitignore │ ├── _cors.js │ ├── _logit.js │ ├── Makefile │ ├── _request.js │ ├── sheetjs.csv │ ├── worker.js │ └── koasub.js ├── chrome │ ├── .gitignore │ ├── Makefile │ ├── popup.html │ ├── manifest.json │ ├── content.js │ ├── popup.js │ └── table.js ├── extendscript │ ├── indesign.base │ ├── .gitignore │ ├── estoolkit.base │ ├── photoshop.base │ ├── aftereffects.base │ ├── illustrator.base │ ├── sheetjs.xlsx │ ├── Makefile │ ├── test.jsx │ ├── estoolkit.jsx │ ├── indesign.jsx │ ├── photoshop.jsx │ ├── illustrator.jsx │ └── aftereffects.jsx ├── meteor │ ├── .gitignore │ ├── client │ │ ├── main.css │ │ ├── main.html │ │ └── main.js │ ├── Makefile │ ├── package.json │ └── server │ │ └── main.js ├── nwjs │ ├── xlsx.full.min.js │ ├── Makefile │ ├── package.json │ ├── index.html │ └── README.md ├── webpack │ ├── xlsx.core.min.js │ ├── xlsx.full.min.js │ ├── .gitignore │ ├── main.js │ ├── core.js │ ├── full.js │ ├── appworker.js │ ├── coreworker.js │ ├── fullworker.js │ ├── mainworker.js │ ├── Makefile │ ├── webpack.config.js │ └── webpack.app.js ├── systemjs │ ├── .gitignore │ ├── Makefile │ ├── app.node.js │ ├── main.simple.js │ ├── xlsxworker.js │ ├── test.node.js │ └── worker.js ├── angular2 │ ├── .gitignore │ ├── screen.png │ ├── src │ │ ├── polyfills.ts │ │ ├── main.ts │ │ ├── tsconfig.app.json │ │ ├── app │ │ │ └── app.module.ts │ │ └── index.html │ ├── nscript.sh │ ├── tsconfig.json │ ├── .angular-cli.json │ ├── ionic.sh │ ├── Makefile │ ├── package.json │ ├── package.json-angular4 │ ├── package.json-angular5 │ └── package.json-angular2 ├── fusebox │ ├── .gitignore │ ├── Makefile │ ├── fuse.js │ ├── sheetjs.ts │ └── index.html ├── requirejs │ ├── .gitignore │ ├── build.js │ ├── Makefile │ └── README.md ├── altjs │ ├── .swiftlint.yml │ ├── .gitignore │ ├── global.js │ ├── chakra.js │ ├── com │ │ └── sheetjs │ │ │ ├── ObjectNotFoundException.java │ │ │ ├── SheetJSFile.java │ │ │ └── SheetJSSheet.java │ ├── duktape.sh │ ├── qjs.js │ ├── main.swift │ ├── SheetJSRhino.java │ └── nashorn.js ├── browserify │ ├── .gitignore │ ├── Makefile │ ├── xlsxworker.js │ └── README.md ├── rollup │ ├── .gitignore │ ├── main.js │ ├── xlsxworker.js │ ├── rollup.config.node.js │ ├── rollup.config.js │ ├── rollup.config.worker.js │ ├── Makefile │ └── README.md ├── array │ ├── Makefile │ └── linest.js ├── electron │ ├── .eslintrc │ ├── Makefile │ ├── package.json │ ├── main.js │ └── index.html ├── google-sheet │ ├── package.json │ └── index.js └── showcase │ └── README.md ├── packages └── s │ ├── .gitignore │ ├── misc │ ├── .gitignore │ ├── parcel.html │ ├── xlsx.mini.min.js │ ├── standalone.js │ ├── webpack.config.js │ ├── make_mjs.sh │ ├── parcel.js │ ├── standalone.html │ ├── module.html │ ├── require_test.njs │ ├── import_test.mjs │ ├── puppetsta.js │ ├── puppetpcl.js │ └── puppetmjs.js │ ├── .npmignore │ ├── dist │ ├── typings │ │ ├── umd.d.ts │ │ ├── s │ │ │ ├── Range.d.ts │ │ │ ├── XLSXWrapper.d.ts │ │ │ ├── worksheet │ │ │ │ └── WorksheetCollection.d.ts │ │ │ ├── names │ │ │ │ ├── DefinedName.d.ts │ │ │ │ ├── DefinedNameCollection.d.ts │ │ │ │ └── WorkbookDefinedNameCollection.d.ts │ │ │ └── Workbook.d.ts │ │ └── index.d.ts │ ├── cjs │ │ ├── umd.js.map │ │ ├── s │ │ │ ├── Range.js.map │ │ │ ├── names │ │ │ │ ├── DefinedNameCollection.js.map │ │ │ │ ├── DefinedNameCollection.js │ │ │ │ ├── DefinedName.js.map │ │ │ │ └── DefinedName.js │ │ │ ├── worksheet │ │ │ │ ├── WorksheetCollection.js.map │ │ │ │ └── WorksheetCollection.js │ │ │ ├── Range.js │ │ │ ├── XLSXWrapper.js.map │ │ │ ├── XLSXWrapper.js │ │ │ ├── Workbook.js.map │ │ │ └── Workbook.js │ │ ├── index.js.map │ │ ├── umd.js │ │ └── index.js │ ├── esm │ │ ├── umd.js.map │ │ ├── umd.js │ │ ├── s │ │ │ ├── Range.js │ │ │ ├── names │ │ │ │ ├── DefinedNameCollection.js │ │ │ │ ├── DefinedNameCollection.js.map │ │ │ │ ├── DefinedName.js.map │ │ │ │ └── DefinedName.js │ │ │ ├── Range.js.map │ │ │ ├── worksheet │ │ │ │ ├── WorksheetCollection.js.map │ │ │ │ └── WorksheetCollection.js │ │ │ ├── XLSXWrapper.js │ │ │ ├── XLSXWrapper.js.map │ │ │ ├── Workbook.js.map │ │ │ └── Workbook.js │ │ ├── index.js │ │ └── index.js.map │ └── mjs │ │ ├── umd.js.map │ │ ├── umd.mjs │ │ ├── s │ │ ├── Range.mjs │ │ ├── Range.js.map │ │ ├── names │ │ │ ├── DefinedNameCollection.mjs │ │ │ ├── DefinedNameCollection.js.map │ │ │ ├── DefinedName.js.map │ │ │ └── DefinedName.mjs │ │ ├── worksheet │ │ │ ├── WorksheetCollection.js.map │ │ │ └── WorksheetCollection.mjs │ │ ├── XLSXWrapper.js.map │ │ ├── XLSXWrapper.mjs │ │ ├── Workbook.js.map │ │ └── Workbook.mjs │ │ ├── index.js.map │ │ └── index.mjs │ ├── src │ ├── umd.ts │ ├── s │ │ ├── Range.ts │ │ ├── worksheet │ │ │ ├── Worksheet.ts │ │ │ └── WorksheetCollection.ts │ │ ├── XLSXWrapper.ts │ │ ├── names │ │ │ ├── DefinedName.ts │ │ │ └── DefinedNameCollection.ts │ │ └── Workbook.ts │ └── index.ts │ ├── esm.mjs │ ├── index.js │ ├── tsconfig │ ├── tsconfig.cjs.json │ ├── tsconfig.esm.json │ ├── tsconfig.types.json │ └── tsconfig.base.json │ ├── tsconfig.json │ ├── tsconfig.base.json │ ├── tsconfig.vscode.json │ ├── README.md │ ├── test.ts │ ├── Makefile │ └── package.json ├── misc ├── docs │ ├── formats.png │ ├── legend.png │ └── style.css ├── suppress_export.js ├── strip_flow.js ├── prof.js ├── 00_esmheader.js ├── node_version.sh ├── 98_esmxport.js ├── spin.sh ├── strip_sourcemap.sh ├── legend.dot └── help.sh ├── .jshintrc ├── types ├── Makefile ├── .npmignore ├── tslint.json └── tsconfig.json ├── formats.png ├── legend.png ├── .github ├── FUNDING.yml └── workflows │ ├── require-allow-edits.yml │ ├── rebase.yml │ ├── node-pretest.yml │ └── node-iojs.yml ├── .gitmodules ├── .jscs.json ├── docbits ├── 01_toc.md ├── 97_license.md ├── 60_features.md ├── 55_wbobject.md ├── 64_cellprops.md ├── 50_csf.md ├── 66_comments.md ├── 10_install.md ├── 73_sheetprops.md ├── 31_writestream.md ├── 11_demos.md └── 56_wbprops.md ├── .fossaignore ├── bower.json ├── xlsxworker.js ├── .gitattributes ├── .gitignore ├── .eslintrc ├── xlsxworker.flow.js ├── book.json ├── .flowconfig ├── .npmignore ├── make.cmd └── mini.lst /tests/shim.js: -------------------------------------------------------------------------------- 1 | ../shim.js -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | xlsx.js 2 | -------------------------------------------------------------------------------- /bits/.npmignore: -------------------------------------------------------------------------------- 1 | *.js 2 | -------------------------------------------------------------------------------- /tests/xlsx.mjs: -------------------------------------------------------------------------------- 1 | ../xlsx.mjs -------------------------------------------------------------------------------- /demos/vue/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /demos/vue/shim.js: -------------------------------------------------------------------------------- 1 | ../../shim.js -------------------------------------------------------------------------------- /demos/xhr/.gitignore: -------------------------------------------------------------------------------- 1 | files/ 2 | -------------------------------------------------------------------------------- /packages/s/.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | -------------------------------------------------------------------------------- /demos/angular/shim.js: -------------------------------------------------------------------------------- 1 | ../../shim.js -------------------------------------------------------------------------------- /demos/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | -------------------------------------------------------------------------------- /demos/datagrid/shim.js: -------------------------------------------------------------------------------- 1 | ../../shim.js -------------------------------------------------------------------------------- /demos/headless/.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | -------------------------------------------------------------------------------- /demos/knockout/shim.js: -------------------------------------------------------------------------------- 1 | ../../shim.js -------------------------------------------------------------------------------- /demos/typescript/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | -------------------------------------------------------------------------------- /demos/vue/static/shim.js: -------------------------------------------------------------------------------- 1 | ../shim.js -------------------------------------------------------------------------------- /misc/docs/formats.png: -------------------------------------------------------------------------------- 1 | ../../formats.png -------------------------------------------------------------------------------- /misc/docs/legend.png: -------------------------------------------------------------------------------- 1 | ../../legend.png -------------------------------------------------------------------------------- /demos/parcel/.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | dist 3 | -------------------------------------------------------------------------------- /demos/react/pages/.gitignore: -------------------------------------------------------------------------------- 1 | sheetjs.js 2 | -------------------------------------------------------------------------------- /demos/vue/.gitignore: -------------------------------------------------------------------------------- 1 | SheetJS 2 | .nuxt 3 | -------------------------------------------------------------------------------- /demos/xspreadsheet/shim.js: -------------------------------------------------------------------------------- 1 | ../../shim.js -------------------------------------------------------------------------------- /bits/01_version.js: -------------------------------------------------------------------------------- 1 | XLSX.version = '0.17.2'; 2 | -------------------------------------------------------------------------------- /demos/function/Firebase/firebase.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /demos/oldie/shim.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/shim.min.js -------------------------------------------------------------------------------- /demos/server/.gitignore: -------------------------------------------------------------------------------- 1 | xlsx.full.min.js 2 | -------------------------------------------------------------------------------- /packages/s/misc/.gitignore: -------------------------------------------------------------------------------- 1 | S.js 2 | parcel/ 3 | -------------------------------------------------------------------------------- /tests/xlsx.core.min.js: -------------------------------------------------------------------------------- 1 | ../dist/xlsx.core.min.js -------------------------------------------------------------------------------- /tests/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/chrome/.gitignore: -------------------------------------------------------------------------------- 1 | xlsx.*.js 2 | logo.png 3 | -------------------------------------------------------------------------------- /demos/extendscript/indesign.base: -------------------------------------------------------------------------------- 1 | #target indesign 2 | -------------------------------------------------------------------------------- /demos/meteor/.gitignore: -------------------------------------------------------------------------------- 1 | .meteor 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /demos/vue/static/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../xlsx.full.min.js -------------------------------------------------------------------------------- /demos/vue/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/xhr/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/angular/xlsx.core.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.core.min.js -------------------------------------------------------------------------------- /demos/angular/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/database/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/datagrid/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/extendscript/.gitignore: -------------------------------------------------------------------------------- 1 | xlsx.extendscript.js 2 | -------------------------------------------------------------------------------- /demos/extendscript/estoolkit.base: -------------------------------------------------------------------------------- 1 | #target estoolkit 2 | -------------------------------------------------------------------------------- /demos/extendscript/photoshop.base: -------------------------------------------------------------------------------- 1 | #target photoshop 2 | -------------------------------------------------------------------------------- /demos/function/Firebase/functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /demos/function/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0" 3 | } -------------------------------------------------------------------------------- /demos/headless/sheetjs.xlsx: -------------------------------------------------------------------------------- 1 | ../extendscript/sheetjs.xlsx -------------------------------------------------------------------------------- /demos/knockout/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/nwjs/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/oldie/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /demos/webpack/xlsx.core.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.core.min.js -------------------------------------------------------------------------------- /demos/webpack/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /bits/03_consts.js: -------------------------------------------------------------------------------- 1 | var DENSE = null; 2 | var DIF_XL = true; 3 | -------------------------------------------------------------------------------- /demos/extendscript/aftereffects.base: -------------------------------------------------------------------------------- 1 | #target aftereffects 2 | -------------------------------------------------------------------------------- /demos/extendscript/illustrator.base: -------------------------------------------------------------------------------- 1 | #target illustrator 2 | -------------------------------------------------------------------------------- /demos/systemjs/.gitignore: -------------------------------------------------------------------------------- 1 | systemjs/ 2 | xlsx.full.min.js 3 | -------------------------------------------------------------------------------- /demos/xspreadsheet/xlsx.full.min.js: -------------------------------------------------------------------------------- 1 | ../../dist/xlsx.full.min.js -------------------------------------------------------------------------------- /packages/s/misc/parcel.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/s/misc/xlsx.mini.min.js: -------------------------------------------------------------------------------- 1 | ../../../dist/xlsx.mini.min.js -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": false, 3 | "curly": false 4 | } 5 | -------------------------------------------------------------------------------- /demos/typescript/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/webpack/.gitignore: -------------------------------------------------------------------------------- 1 | main.js 2 | main.min.js 3 | *.out.js 4 | -------------------------------------------------------------------------------- /types/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: tslint 2 | tslint: 3 | @make -C.. tslint 4 | -------------------------------------------------------------------------------- /demos/angular2/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | hooks 3 | SheetJSIonic 4 | SheetJSNS 5 | -------------------------------------------------------------------------------- /formats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/formats.png -------------------------------------------------------------------------------- /legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/legend.png -------------------------------------------------------------------------------- /packages/s/misc/standalone.js: -------------------------------------------------------------------------------- 1 | var S = require("../"); 2 | module.exports = S; -------------------------------------------------------------------------------- /demos/fusebox/.gitignore: -------------------------------------------------------------------------------- 1 | .fusebox 2 | tsconfig.json 3 | client.js 4 | server.js 5 | -------------------------------------------------------------------------------- /demos/react/.gitignore: -------------------------------------------------------------------------------- 1 | SheetJS 2 | .next 3 | static/shim.js 4 | public/shim.js 5 | -------------------------------------------------------------------------------- /demos/requirejs/.gitignore: -------------------------------------------------------------------------------- 1 | xlsx.full* 2 | r.js 3 | require.js 4 | app-built.js 5 | -------------------------------------------------------------------------------- /types/.npmignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *xlsx*.ts 3 | doc.ts 4 | write.ts 5 | tslint.json 6 | -------------------------------------------------------------------------------- /demos/altjs/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - trailing_semicolon 3 | - identifier_name 4 | -------------------------------------------------------------------------------- /demos/meteor/client/main.css: -------------------------------------------------------------------------------- 1 | /* CSS declarations go here */ 2 | a { text-decoration: none } 3 | -------------------------------------------------------------------------------- /demos/vue/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/demos/vue/screen.png -------------------------------------------------------------------------------- /misc/suppress_export.js: -------------------------------------------------------------------------------- 1 | var DO_NOT_EXPORT_CODEPAGE = true; 2 | var DO_NOT_EXPORT_JSZIP = true; 3 | -------------------------------------------------------------------------------- /tests/testA.lst: -------------------------------------------------------------------------------- 1 | calendar_stress_test.xlsx 2 | large_strings.xlsb 3 | time_stress_test_1.xlsb 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: SheetJSDev 2 | custom: https://sheetjs.com 3 | open_collective: s5s 4 | -------------------------------------------------------------------------------- /demos/browserify/.gitignore: -------------------------------------------------------------------------------- 1 | browserify.js 2 | browserify.min.js 3 | worker.js 4 | worker.min.js 5 | -------------------------------------------------------------------------------- /demos/oldie/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/demos/oldie/download.png -------------------------------------------------------------------------------- /demos/react/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/demos/react/screen.png -------------------------------------------------------------------------------- /demos/angular2/screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/demos/angular2/screen.png -------------------------------------------------------------------------------- /demos/rollup/.gitignore: -------------------------------------------------------------------------------- 1 | rollup.js 2 | rollup.min.js 3 | rollup.node.js 4 | worker.js 5 | worker.min.js 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test_files"] 2 | path = test_files 3 | url = https://github.com/SheetJS/test_files 4 | -------------------------------------------------------------------------------- /demos/oldie/downloadify.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/demos/oldie/downloadify.swf -------------------------------------------------------------------------------- /demos/extendscript/sheetjs.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/milad-azami/sheetjs/HEAD/demos/extendscript/sheetjs.xlsx -------------------------------------------------------------------------------- /packages/s/.npmignore: -------------------------------------------------------------------------------- 1 | .cache/ 2 | src/ 3 | misc/ 4 | tsconfig/ 5 | *.tgz 6 | test.ts 7 | Makefile 8 | tsconfig.* 9 | -------------------------------------------------------------------------------- /packages/s/dist/typings/umd.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | export * from "./index"; 3 | -------------------------------------------------------------------------------- /demos/angular2/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | import 'core-js/es6/reflect'; 2 | import 'core-js/es7/reflect'; 3 | import 'zone.js/dist/zone'; 4 | -------------------------------------------------------------------------------- /demos/react/nexthdr.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import XLSX from 'xlsx'; 3 | import React from 'react'; -------------------------------------------------------------------------------- /demos/rollup/main.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import XLSX from 'xlsx'; 3 | export default XLSX; 4 | -------------------------------------------------------------------------------- /packages/s/dist/typings/s/Range.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | export declare class Range { 3 | } 4 | -------------------------------------------------------------------------------- /packages/s/src/umd.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | export * from "./index"; -------------------------------------------------------------------------------- /.jscs.json: -------------------------------------------------------------------------------- 1 | { 2 | "requireCommaBeforeLineBreak": true, 3 | "disallowTrailingWhitespace": true, 4 | "disallowTrailingComma": true 5 | } 6 | 7 | -------------------------------------------------------------------------------- /packages/s/src/s/Range.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | export class Range { 5 | }; -------------------------------------------------------------------------------- /demos/altjs/.gitignore: -------------------------------------------------------------------------------- 1 | sheetjs.* 2 | SheetJSSwift 3 | duk* 4 | *.class 5 | *.jar 6 | rhino 7 | shim.min.js 8 | xlsx.*.js 9 | payload.js 10 | -------------------------------------------------------------------------------- /demos/altjs/global.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var global = (function(){ return this; }).call(null); 3 | 4 | -------------------------------------------------------------------------------- /demos/array/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: tfjs 2 | tfjs: 3 | npm install @tensorflow/tfjs 4 | node tf.js 5 | 6 | .PHONY: propel 7 | propel: 8 | node propel.js 9 | -------------------------------------------------------------------------------- /demos/parcel/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: app 2 | app: 3 | parcel build index.html --public-url ./ 4 | 5 | .PHONY: ctest 6 | ctest: 7 | parcel index.html 8 | -------------------------------------------------------------------------------- /packages/s/esm.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | export * from "./dist/mjs/index.mjs"; -------------------------------------------------------------------------------- /packages/s/index.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | module.exports = require('./dist/cjs/'); -------------------------------------------------------------------------------- /demos/xhr/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: serve 2 | serve: 3 | npm start 4 | 5 | .PHONY: init 6 | init: 7 | if [ ! -e sheetjs.xlsx ]; then ln -s ../../sheetjs.xlsx; fi 8 | -------------------------------------------------------------------------------- /packages/s/src/s/worksheet/Worksheet.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | export class Worksheet { 5 | } -------------------------------------------------------------------------------- /demos/nwjs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: init 2 | init: 3 | if [ ! -e xlsx.full.min.js ]; then ln -s ../../dist/xlsx.full.min.js . ; fi 4 | 5 | .PHONY: run 6 | run: 7 | nw . 8 | -------------------------------------------------------------------------------- /demos/systemjs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test ctest 2 | test: 3 | cp ../../dist/xlsx.full.min.js . 4 | node test.node.js 5 | 6 | ctest: 7 | python -mSimpleHTTPServer 8 | -------------------------------------------------------------------------------- /docbits/01_toc.md: -------------------------------------------------------------------------------- 1 | ## Table of Contents 2 | 3 |
4 | Expand to show Table of Contents 5 | 6 | 7 |
8 | 9 | -------------------------------------------------------------------------------- /demos/database/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { "shared-node-browser":true }, 3 | "parserOptions": { 4 | "ecmaVersion": 8 5 | }, 6 | "plugins": [ "html", "json" ] 7 | } 8 | -------------------------------------------------------------------------------- /demos/function/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { "shared-node-browser":true }, 3 | "parserOptions": { 4 | "ecmaVersion": 8 5 | }, 6 | "plugins": [ "html", "json" ] 7 | } 8 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/umd.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;;;;AAEpB,6BAAwB"} -------------------------------------------------------------------------------- /packages/s/dist/esm/umd.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,cAAc,SAAS,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/umd.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,cAAc,SAAS,CAAC"} -------------------------------------------------------------------------------- /demos/webpack/main.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('../../'); 3 | console.log("it works!"); 4 | module.exports = XLSX; 5 | -------------------------------------------------------------------------------- /misc/strip_flow.js: -------------------------------------------------------------------------------- 1 | process.stdout.write(require("fs").readFileSync("xlsx.flow.js","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,"")) 2 | -------------------------------------------------------------------------------- /packages/s/dist/esm/umd.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | export * from "./index"; 4 | //# sourceMappingURL=umd.js.map -------------------------------------------------------------------------------- /demos/webpack/core.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('./xlsx.core.min'); 3 | console.log("it works!"); 4 | module.exports = XLSX; 5 | -------------------------------------------------------------------------------- /demos/webpack/full.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('./xlsx.full.min'); 3 | console.log("it works!"); 4 | module.exports = XLSX; 5 | -------------------------------------------------------------------------------- /packages/s/dist/mjs/umd.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | export * from "./index.mjs"; 4 | //# sourceMappingURL=umd.js.map 5 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/Range.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | export class Range { 4 | } 5 | ; 6 | //# sourceMappingURL=Range.js.map -------------------------------------------------------------------------------- /packages/s/dist/esm/s/names/DefinedNameCollection.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | ; 4 | //# sourceMappingURL=DefinedNameCollection.js.map -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/Range.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | export class Range { 4 | } 5 | ; 6 | //# sourceMappingURL=Range.js.map 7 | -------------------------------------------------------------------------------- /demos/electron/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "node": true 5 | }, 6 | "parserOptions": { 7 | "ecmaVersion": 8 8 | }, 9 | "plugins": [ "html", "json" ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/Range.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,MAAM,OAAO,KAAK;CACjB;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/Range.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,MAAM,OAAO,KAAK;CACjB;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/names/DefinedNameCollection.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | ; 4 | //# sourceMappingURL=DefinedNameCollection.js.map 5 | -------------------------------------------------------------------------------- /packages/s/dist/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | export { Workbook } from "./s/Workbook"; 3 | export { get_XLSX, set_XLSX } from "./s/XLSXWrapper"; 4 | -------------------------------------------------------------------------------- /demos/altjs/chakra.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var wb = XLSX.read(payload, {type:'base64'}); 3 | console.log(XLSX.utils.sheet_to_csv(wb.Sheets[wb.SheetNames[0]])); 4 | -------------------------------------------------------------------------------- /demos/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "outDir": "./dist", 7 | "strict": true 8 | } 9 | } -------------------------------------------------------------------------------- /packages/s/tsconfig/tsconfig.cjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "target": "es5", 6 | "outDir": "../dist/cjs" 7 | } 8 | } -------------------------------------------------------------------------------- /.fossaignore: -------------------------------------------------------------------------------- 1 | bits/ 2 | demos/ 3 | dist/ 4 | docbits/ 5 | misc/ 6 | node_modules/ 7 | types/ 8 | tests/ 9 | test_files 10 | *.md 11 | 12 | *.json 13 | *.log 14 | *.sh 15 | .DS_Store 16 | .Trashes 17 | -------------------------------------------------------------------------------- /demos/angular2/src/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | import { AppModule } from './app/app.module'; 3 | platformBrowserDynamic().bootstrapModule(AppModule); 4 | -------------------------------------------------------------------------------- /docbits/97_license.md: -------------------------------------------------------------------------------- 1 | ## License 2 | 3 | Please consult the attached LICENSE file for details. All rights not explicitly 4 | granted by the Apache 2.0 License are reserved by the Original Author. 5 | 6 | 7 | -------------------------------------------------------------------------------- /packages/s/misc/webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | output: { 3 | libraryTarget: "var", 4 | library: "S" 5 | }, 6 | node: { 7 | process: false, 8 | browser: false 9 | } 10 | } -------------------------------------------------------------------------------- /packages/s/src/index.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | export { Workbook } from "./s/Workbook"; 5 | export { get_XLSX, set_XLSX } from "./s/XLSXWrapper"; -------------------------------------------------------------------------------- /misc/prof.js: -------------------------------------------------------------------------------- 1 | var describe = function(m,cb){if(cb) cb();}; 2 | describe.skip = function(m,cb){}; 3 | var it = function(m,cb){if(cb) cb();}; 4 | it.skip = function(m,cb){}; 5 | var before = function(cb){if(cb) cb();}; 6 | -------------------------------------------------------------------------------- /packages/s/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "baseUrl": ".", 5 | "paths": { 6 | "s": [ "./src/index" ] 7 | } 8 | }, 9 | "exclude": [ "./dist" ] 10 | } -------------------------------------------------------------------------------- /demos/nwjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sheetjs-nwjs", 3 | "author": "sheetjs", 4 | "version": "0.0.0", 5 | "main": "index.html", 6 | "dependencies": { 7 | "nw": "~0.24.4", 8 | "xlsx": "*" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /demos/requirejs/build.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | ({ 3 | baseUrl: ".", 4 | name: "app", 5 | paths: { 6 | xlsx: "xlsx.full.min" 7 | }, 8 | out: "app-built.js" 9 | }) 10 | -------------------------------------------------------------------------------- /demos/chrome/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: init 2 | init: 3 | cp ../../dist/xlsx.full.min.js . 4 | if [ ! -e logo.png ]; then curl -O http://sheetjs.com/logo.png; fi 5 | 6 | .PHONY: lint 7 | lint: 8 | eslint content.js popup.js table.js 9 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/names/DefinedNameCollection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAUnB,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/names/DefinedNameCollection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAUnB,CAAC"} -------------------------------------------------------------------------------- /demos/angular2/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "es2015", 6 | "baseUrl": "", 7 | "types": [] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/Range.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB;IAAA;IACA,CAAC;IAAD,YAAC;AAAD,CAAC,AADD,IACC;AADY,sBAAK;AACjB,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/names/DefinedNameCollection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAUnB,CAAC"} -------------------------------------------------------------------------------- /packages/s/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "moduleResolution": "node", 5 | "outDir": "./.out", 6 | "lib": [ "es5" ], 7 | "sourceMap": true, 8 | "noImplicitReturns": true 9 | } 10 | } -------------------------------------------------------------------------------- /packages/s/dist/cjs/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,yCAAwC;AAA/B,8BAAA,QAAQ,CAAA;AACjB,+CAAqD;AAA5C,iCAAA,QAAQ,CAAA;AAAE,iCAAA,QAAQ,CAAA"} -------------------------------------------------------------------------------- /packages/s/dist/esm/index.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | export { Workbook } from "./s/Workbook"; 4 | export { get_XLSX, set_XLSX } from "./s/XLSXWrapper"; 5 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /packages/s/dist/esm/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"} -------------------------------------------------------------------------------- /packages/s/misc/make_mjs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf dist/mjs/ 3 | cp -r dist/esm dist/mjs 4 | find dist/mjs -name '*.js' | while read x; do 5 | <"$x" awk '/(im|ex)port / { gsub(/";/, ".mjs\";"); } 1' > "${x%.js}.mjs" 6 | rm -f "$x" 7 | done 8 | 9 | -------------------------------------------------------------------------------- /demos/electron/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: init 2 | init: 3 | mkdir -p node_modules 4 | cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx ; fi; cd - 5 | 6 | .PHONY: lint 7 | lint: 8 | eslint *.js 9 | .PHONY: run 10 | run: 11 | electron . 12 | -------------------------------------------------------------------------------- /misc/00_esmheader.js: -------------------------------------------------------------------------------- 1 | /*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /*exported XLSX */ 4 | /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ 5 | var XLSX = {}; 6 | -------------------------------------------------------------------------------- /packages/s/dist/mjs/index.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | export { Workbook } from "./s/Workbook.mjs"; 4 | export { get_XLSX, set_XLSX } from "./s/XLSXWrapper.mjs"; 5 | //# sourceMappingURL=index.js.map 6 | -------------------------------------------------------------------------------- /demos/server/_cors.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var cors = function(req, res) { res.header('Access-Control-Allow-Origin', '*'); }; 3 | cors.mw = function(req, res, next) { cors(req, res); next(); }; 4 | module.exports = cors; 5 | -------------------------------------------------------------------------------- /demos/typescript/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: 3 | @npm run build 4 | 5 | .PHONY: lint 6 | lint: 7 | @npm run lint 8 | 9 | .PHONY: init 10 | init: 11 | mkdir -p node_modules 12 | npm install typescript 13 | cd node_modules; ln -s ../../../ xlsx; cd - 14 | -------------------------------------------------------------------------------- /packages/s/tsconfig.vscode.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true 5 | }, 6 | "exclude": [ 7 | "dist" 8 | ], 9 | "formatCodeOptions": { 10 | "indentSize": 2, 11 | "tabSize": 2 12 | } 13 | } -------------------------------------------------------------------------------- /demos/typescript/demo.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /* eslint-env node */ 4 | var readFirstSheet = require("./").readFirstSheet; 5 | console.log(readFirstSheet("../../sheetjs.xlsb", {type:"file", cellDates:true})); -------------------------------------------------------------------------------- /packages/s/dist/typings/s/XLSXWrapper.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /// 3 | export declare function get_XLSX(): typeof XLSX; 4 | export declare function set_XLSX(xlsx: typeof XLSX): void; 5 | -------------------------------------------------------------------------------- /packages/s/misc/parcel.js: -------------------------------------------------------------------------------- 1 | import * as S from "../esm"; 2 | const XLSX = require("./xlsx.mini.min.js"); 3 | function assert(x) { if(!x) throw "assert failed"; } 4 | 5 | assert(S != null); 6 | S.set_XLSX(XLSX); 7 | assert(S.get_XLSX() == XLSX); 8 | assert(S.get_XLSX().version); -------------------------------------------------------------------------------- /demos/systemjs/app.node.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX_1 = require('../../xlsx.js'); 3 | var XLSX_2 = require('../../dist/xlsx.core.min.js'); 4 | var XLSX_3 = require('../../dist/xlsx.full.min.js'); 5 | var XLSX_N = require('xlsx'); 6 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/names/DefinedNameCollection.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | ; 6 | //# sourceMappingURL=DefinedNameCollection.js.map -------------------------------------------------------------------------------- /.github/workflows/require-allow-edits.yml: -------------------------------------------------------------------------------- 1 | name: Require “Allow Edits” 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | name: "Require “Allow Edits”" 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: ljharb/require-allow-edits@main 13 | -------------------------------------------------------------------------------- /bits/00_header.js: -------------------------------------------------------------------------------- 1 | /*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /*exported XLSX */ 4 | /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ 5 | var XLSX = {}; 6 | function make_xlsx_lib(XLSX){ 7 | -------------------------------------------------------------------------------- /packages/s/tsconfig/tsconfig.esm.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "es2015", 5 | "importHelpers": true, 6 | "moduleResolution": "node", 7 | "target": "es2015", 8 | "outDir": "../dist/esm" 9 | } 10 | } -------------------------------------------------------------------------------- /demos/electron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sheetjs-electron", 3 | "author": "sheetjs", 4 | "version": "0.0.0", 5 | "main": "main.js", 6 | "dependencies": { 7 | "xlsx": "*", 8 | "electron": "^9.0.5" 9 | }, 10 | "scripts": { 11 | "start": "electron ." 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demos/typescript/src/index.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /* eslint-env browser */ 4 | /* global require */ 5 | var readFirstSheet = require("../").readFirstSheet; 6 | console.log(readFirstSheet("a,b,c\n1,2,3\n4,5,6", {type:"binary"})); -------------------------------------------------------------------------------- /misc/node_version.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # This script will check the current version of node and install another version 4 | # of npm if node is version 0.8 5 | 6 | version=$(node --version) 7 | 8 | if [[ $version =~ v0\.8\. ]] 9 | then 10 | npm install -g npm@4.3.0 11 | fi -------------------------------------------------------------------------------- /packages/s/dist/typings/s/worksheet/WorksheetCollection.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /// 3 | export declare class WorksheetCollection { 4 | private readonly _wb; 5 | constructor(wb: XLSX.WorkBook); 6 | } 7 | -------------------------------------------------------------------------------- /packages/s/misc/standalone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /demos/function/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 5 | "AzureWebJobsDashboard": "UseDevelopmentStorage=true" 6 | }, 7 | "Host": { 8 | "LocalHttpPort": 7262, 9 | "CORS": "*" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /demos/systemjs/main.simple.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('xlsx'); 3 | console.log(XLSX.version); 4 | var w = XLSX.read('abc,def\nghi,jkl', {type:'binary'}); 5 | var j = XLSX.utils.sheet_to_json(w.Sheets[w.SheetNames[0]], {header:1}); 6 | console.log(j); 7 | -------------------------------------------------------------------------------- /packages/s/tsconfig/tsconfig.types.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "es2015", 5 | "target": "esnext", 6 | "removeComments": false, 7 | "declaration": true, 8 | "declarationDir": "../dist/typings", 9 | "emitDeclarationOnly": true 10 | } 11 | } -------------------------------------------------------------------------------- /misc/98_esmxport.js: -------------------------------------------------------------------------------- 1 | export const version = XLSX.version; 2 | export { 3 | parse_xlscfb, 4 | parse_zip, 5 | readSync as read, 6 | readFileSync as readFile, 7 | readFileSync, 8 | writeSync as write, 9 | writeFileSync as writeFile, 10 | writeFileSync, 11 | writeFileAsync, 12 | utils, 13 | SSF, 14 | CFB 15 | }; 16 | -------------------------------------------------------------------------------- /demos/vue/nuxt.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | head: { 3 | script: [ 4 | // { src: "https://unpkg.com/xlsx/dist/shim.min.js" }, // CDN 5 | // { src: "https://unpkg.com/xlsx/dist/xlsx.full.min.js" } // CDN 6 | { src: "shim.js" }, // development 7 | { src: "xlsx.full.min.js" } // development 8 | ] 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /packages/s/dist/typings/s/names/DefinedName.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /// 3 | export declare class DefinedName { 4 | readonly _name: XLSX.DefinedName; 5 | constructor(name: XLSX.DefinedName); 6 | readonly raw: XLSX.DefinedName; 7 | } 8 | -------------------------------------------------------------------------------- /packages/s/misc/module.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demos/typescript/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint-config-airbnb", 3 | "rules": { 4 | "whitespace": false, 5 | "no-sparse-arrays": false, 6 | "only-arrow-functions": false, 7 | "no-consecutive-blank-lines": false, 8 | "prefer-conditional-expression": false, 9 | "one-variable-per-declaration": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /demos/xhr/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sheetjs-xhr-demo", 3 | "author": "sheetjs", 4 | "version": "0.72.62", 5 | "dependencies": { 6 | "printj": "1.1.0", 7 | "express": "4.15.4", 8 | "express-formidable": "1.0.0", 9 | "serve-index": "1.9.0" 10 | }, 11 | "scripts": { 12 | "start": "node server.js 7262" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /demos/server/_logit.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var sprintf = require('printj').sprintf; 3 | var logit = function(req, res) { 4 | console.log(sprintf("%s %s %d", req.method, req.url, res.statusCode)); 5 | }; 6 | logit.mw = function(req, res, next) { logit(req, res); next(); } 7 | module.exports = logit; 8 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/worksheet/WorksheetCollection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,mBAAmB;IAG9B,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACH;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/worksheet/WorksheetCollection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,mBAAmB;IAG9B,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACH;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/misc/require_test.njs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | var assert = require("assert"); 5 | var XLSX = require("../../../"); 6 | var S = require("../"); 7 | 8 | assert(S != null); 9 | S.set_XLSX(XLSX); 10 | assert(S.get_XLSX() == XLSX); 11 | assert(S.get_XLSX().version); -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | 3 | on: [pull_request_target] 4 | 5 | jobs: 6 | _: 7 | name: "Automatic Rebase" 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: ljharb/rebase@master 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | -------------------------------------------------------------------------------- /misc/spin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # spin.sh -- show a spinner (for coverage test) 3 | # Copyright (C) 2014-present SheetJS 4 | 5 | wpid=$1 6 | delay=1 7 | str="|/-\\" 8 | while [ $(ps -a|awk '$1=='$wpid' {print $1}') ]; do 9 | t=${str#?} 10 | printf " [%c]" "$str" 11 | str=$t${str%"$t"} 12 | sleep $delay 13 | printf "\b\b\b\b" 14 | done 15 | -------------------------------------------------------------------------------- /demos/meteor/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: start 2 | start: 3 | @meteor 4 | 5 | .PHONY: init 6 | init: 7 | if [ ! -e .meteor ]; then meteor create .; fi; 8 | @npm install babel-runtime meteor-node-stubs 9 | @meteor add check 10 | @mkdir -p node_modules; cd node_modules; ln -s ../../../ xlsx; cd - 11 | 12 | .PHONY: lint 13 | lint: 14 | @meteor npm run lint 15 | -------------------------------------------------------------------------------- /demos/headless/chromeless.js: -------------------------------------------------------------------------------- 1 | const { Chromeless } = require('chromeless'); 2 | const TEST = 'http://localhost:8000', TIME = 30 * 1000; 3 | (async() => { 4 | const browser = new Chromeless(); 5 | const pth = await browser.goto(TEST).wait(TIME).screenshot(); 6 | console.log(pth); 7 | await browser.end(); 8 | })().catch(e=>{ console.error(e); }); 9 | 10 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/worksheet/WorksheetCollection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,uCAAuC;AAEvC;IAGE,6BAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;IACJ,0BAAC;AAAD,CAAC,AAND,IAMC;AANY,kDAAmB;AAM/B,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/esm/s/worksheet/WorksheetCollection.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | export class WorksheetCollection { 5 | constructor(wb) { 6 | this._wb = wb; 7 | } 8 | ; 9 | } 10 | ; 11 | //# sourceMappingURL=WorksheetCollection.js.map -------------------------------------------------------------------------------- /packages/s/src/s/worksheet/WorksheetCollection.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | /// 5 | 6 | export class WorksheetCollection { 7 | private readonly _wb: XLSX.WorkBook; 8 | 9 | constructor(wb: XLSX.WorkBook) { 10 | this._wb = wb; 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/umd.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | function __export(m) { 5 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; 6 | } 7 | Object.defineProperty(exports, "__esModule", { value: true }); 8 | __export(require("./index")); 9 | //# sourceMappingURL=umd.js.map -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/worksheet/WorksheetCollection.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | export class WorksheetCollection { 5 | constructor(wb) { 6 | this._wb = wb; 7 | } 8 | ; 9 | } 10 | ; 11 | //# sourceMappingURL=WorksheetCollection.js.map 12 | -------------------------------------------------------------------------------- /packages/s/src/s/XLSXWrapper.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | /// 5 | 6 | let _XLSX: typeof XLSX; 7 | if(typeof XLSX !== "undefined") _XLSX = XLSX; 8 | 9 | export function get_XLSX() { return _XLSX; }; 10 | export function set_XLSX(xlsx: typeof XLSX) { _XLSX = xlsx; }; -------------------------------------------------------------------------------- /demos/fusebox/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all server.js client.js: fuse.js 3 | node fuse.js 4 | 5 | .PHONY: test ctest 6 | test: server.js 7 | @node server.js 8 | xlsx --dev sheetjsfbox.xlsb 9 | 10 | ctest: client.js 11 | python -mSimpleHTTPServer 12 | 13 | .PHONY: init 14 | init: 15 | mkdir -p node_modules 16 | cd node_modules; ln -s ../../../ xlsx; cd - 17 | 18 | -------------------------------------------------------------------------------- /docbits/60_features.md: -------------------------------------------------------------------------------- 1 | ### Document Features 2 | 3 | Even for basic features like date storage, the official Excel formats store the 4 | same content in different ways. The parsers are expected to convert from the 5 | underlying file format representation to the Common Spreadsheet Format. Writers 6 | are expected to convert from CSF back to the underlying file format. 7 | 8 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/names/DefinedName.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,WAAW;IAGtB,YAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CAAC;CAEpD;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/names/DefinedName.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,WAAW;IAGtB,YAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CAAC;CAEpD;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/tsconfig/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "noEmit": false, 5 | "baseUrl": "../src", 6 | "sourceRoot": "../src", 7 | "paths": { 8 | "s": [ "./" ], 9 | "s/*": [ "./*" ] 10 | } 11 | }, 12 | "files": [ 13 | "../src/index.ts", 14 | "../src/umd.ts" 15 | ] 16 | } -------------------------------------------------------------------------------- /demos/browserify/Makefile: -------------------------------------------------------------------------------- 1 | TOOL=browserify 2 | .PHONY: all 3 | all: $(TOOL).min.js worker.min.js 4 | 5 | $(TOOL).min.js: $(TOOL).js 6 | uglifyjs $< > $@ 7 | 8 | .PHONY: $(TOOL).js 9 | $(TOOL).js: app.js 10 | browserify $< > $@ 11 | 12 | worker.min.js: worker.js 13 | uglifyjs $< > $@ 14 | 15 | .PHONY: worker.js 16 | worker.js: xlsxworker.js 17 | browserify $< > $@ 18 | -------------------------------------------------------------------------------- /demos/rollup/xlsxworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import XLSX from 'xlsx'; 3 | postMessage({t:"ready"}); 4 | 5 | onmessage = function (evt) { 6 | var v; 7 | try { 8 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 9 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 10 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 11 | }; 12 | -------------------------------------------------------------------------------- /demos/extendscript/Makefile: -------------------------------------------------------------------------------- 1 | APPS= aftereffects estoolkit illustrator indesign photoshop 2 | TARGETS=$(patsubst %,%.jsx,$(APPS)) 3 | 4 | .PHONY: all 5 | all: deps $(TARGETS) 6 | 7 | .PHONY: deps 8 | deps: 9 | cp ../../dist/xlsx.extendscript.js . 10 | 11 | %.base: 12 | echo "#target $*" > $@ 13 | 14 | .PHONY: $(TARGETS) 15 | $(TARGETS):%.jsx:%.base test.jsx 16 | cat $^ > $@ 17 | -------------------------------------------------------------------------------- /demos/webpack/appworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('../../'); 3 | postMessage({t:"ready"}); 4 | 5 | onmessage = function (evt) { 6 | var v; 7 | try { 8 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 9 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 10 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 11 | }; 12 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/Range.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | var Range = /** @class */ (function () { 6 | function Range() { 7 | } 8 | return Range; 9 | }()); 10 | exports.Range = Range; 11 | ; 12 | //# sourceMappingURL=Range.js.map -------------------------------------------------------------------------------- /demos/altjs/com/sheetjs/ObjectNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | package com.sheetjs; 4 | 5 | import java.lang.Exception; 6 | 7 | public class ObjectNotFoundException extends Exception { 8 | public ObjectNotFoundException() {} 9 | public ObjectNotFoundException(String message) { super(message); } 10 | } 11 | -------------------------------------------------------------------------------- /demos/function/AzureHTTPTrigger/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "disabled": false, 3 | "bindings": [ 4 | { 5 | "authLevel": "function", 6 | "type": "httpTrigger", 7 | "direction": "in", 8 | "dataType": "binary", 9 | "name": "req" 10 | }, 11 | { 12 | "type": "http", 13 | "direction": "out", 14 | "name": "res" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /demos/webpack/coreworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | importScripts('core.out.js'); 3 | postMessage({t:"ready"}); 4 | 5 | onmessage = function (evt) { 6 | var v; 7 | try { 8 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 9 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 10 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 11 | }; 12 | -------------------------------------------------------------------------------- /demos/webpack/fullworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | importScripts('full.out.js'); 3 | postMessage({t:"ready"}); 4 | 5 | onmessage = function (evt) { 6 | var v; 7 | try { 8 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 9 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 10 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 11 | }; 12 | -------------------------------------------------------------------------------- /demos/webpack/mainworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | importScripts('main.min.js'); 3 | postMessage({t:"ready"}); 4 | 5 | onmessage = function (evt) { 6 | var v; 7 | try { 8 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 9 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 10 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 11 | }; 12 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/names/DefinedName.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | export class DefinedName { 5 | constructor(name) { 6 | this._name = name; 7 | } 8 | ; 9 | get raw() { return this._name; } 10 | ; 11 | } 12 | ; 13 | //# sourceMappingURL=DefinedName.js.map -------------------------------------------------------------------------------- /packages/s/dist/esm/s/XLSXWrapper.js: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | let _XLSX; 5 | if (typeof XLSX !== "undefined") 6 | _XLSX = XLSX; 7 | export function get_XLSX() { return _XLSX; } 8 | ; 9 | export function set_XLSX(xlsx) { _XLSX = xlsx; } 10 | ; 11 | //# sourceMappingURL=XLSXWrapper.js.map -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/names/DefinedName.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | export class DefinedName { 5 | constructor(name) { 6 | this._name = name; 7 | } 8 | ; 9 | get raw() { return this._name; } 10 | ; 11 | } 12 | ; 13 | //# sourceMappingURL=DefinedName.js.map 14 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/XLSXWrapper.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,CAAC;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/XLSXWrapper.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,CAAC;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/XLSXWrapper.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | let _XLSX; 5 | if (typeof XLSX !== "undefined") 6 | _XLSX = XLSX; 7 | export function get_XLSX() { return _XLSX; } 8 | ; 9 | export function set_XLSX(xlsx) { _XLSX = xlsx; } 10 | ; 11 | //# sourceMappingURL=XLSXWrapper.js.map 12 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/names/DefinedName.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,uCAAuC;AAEvC;IAGE,qBAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,sBAAI,4BAAG;aAAP,cAA8B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAErD,kBAAC;AAAD,CAAC,AATD,IASC;AATY,kCAAW;AASvB,CAAC"} -------------------------------------------------------------------------------- /packages/s/src/s/names/DefinedName.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | /// 5 | 6 | export class DefinedName { 7 | readonly _name: XLSX.DefinedName; 8 | 9 | constructor(name: XLSX.DefinedName) { 10 | this._name = name; 11 | }; 12 | 13 | get raw(): XLSX.DefinedName { return this._name; }; 14 | 15 | }; -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-xlsx", 3 | "homepage": "https://github.com/SheetJS/js-xlsx", 4 | "main": ["jszip.js", "xlsx.js"], 5 | "ignore": [ 6 | "bin", 7 | "bits", 8 | "misc", 9 | "**/.*" 10 | ], 11 | "keywords": [ 12 | "excel", 13 | "xls", 14 | "xml", 15 | "xlsx", 16 | "xlsm", 17 | "xlsb", 18 | "ods", 19 | "js-xls", 20 | "js-xlsx" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/XLSXWrapper.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,SAAgB,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAA5C,4BAA4C;AAAA,CAAC;AAC7C,SAAgB,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAA7D,4BAA6D;AAAA,CAAC"} -------------------------------------------------------------------------------- /demos/database/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: init 2 | init: 3 | rm -f node_modules/xlsx 4 | mkdir -p node_modules 5 | cd node_modules; ln -s ../../../ xlsx; cd - 6 | rm -f xlsx.full.min.js 7 | ln -s ../../dist/xlsx.full.min.js 8 | 9 | FILES=$(filter-out xlsx.full.min.js,$(wildcard *.js)) $(wildcard *.html) 10 | .PHONY: lint 11 | lint: $(FILES) 12 | eslint $(FILES) 13 | 14 | .PHONY: clean 15 | clean: 16 | rm -f *.db *.xlsx *.csv 17 | -------------------------------------------------------------------------------- /misc/docs/style.css: -------------------------------------------------------------------------------- 1 | a.anchorjs-link { 2 | color: rgba(65, 131, 196, 0.1); 3 | font-weight: 400; 4 | text-decoration: none; 5 | transition: color 100ms ease-out; 6 | z-index: 999; 7 | } 8 | 9 | a.anchorjs-link:hover { 10 | color: rgba(65, 131, 196, 1); 11 | } 12 | 13 | .gitbook-link { 14 | display: none !important; 15 | } 16 | 17 | #book-search-input { 18 | display: none !important; 19 | } 20 | -------------------------------------------------------------------------------- /types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "no-implicit-dependencies": false, 5 | "whitespace": false, 6 | "no-sparse-arrays": false, 7 | "only-arrow-functions": false, 8 | "no-consecutive-blank-lines": false, 9 | "prefer-conditional-expression": false, 10 | "one-variable-per-declaration": false, 11 | "strict-export-declare-modifiers": false, 12 | "prefer-template": false 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /demos/requirejs/Makefile: -------------------------------------------------------------------------------- 1 | TOOL=requirejs 2 | .PHONY: all 3 | all: $(TOOL).js 4 | 5 | .PHONY: $(TOOL).js 6 | $(TOOL).js: 7 | if [ ! -e require.js ]; then curl -O http://requirejs.org/docs/release/2.3.3/comments/require.js; fi 8 | if [ ! -e r.js ]; then curl -O http://requirejs.org/docs/release/2.3.3/r.js; fi 9 | rm -f xlsx.full.min.js; ln -s ../../dist/xlsx.full.min.js 10 | node r.js -o build.js paths.requireLib=./require include=requireLib 11 | -------------------------------------------------------------------------------- /demos/systemjs/xlsxworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('xlsx'); 3 | postMessage({t:"ready"}); 4 | 5 | /* expose a global that can be accessed from the worker script */ 6 | _cb = function (evt) { 7 | var v; 8 | try { 9 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 10 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 11 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 12 | }; 13 | -------------------------------------------------------------------------------- /bits/99_footer.js: -------------------------------------------------------------------------------- 1 | } 2 | /*global define */ 3 | /*:: declare var define:any; */ 4 | if(typeof exports !== 'undefined') make_xlsx_lib(exports); 5 | else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports); 6 | else if(typeof define === 'function' && define.amd) define(function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; }); 7 | else make_xlsx_lib(XLSX); 8 | /*exported XLS, ODS */ 9 | var XLS = XLSX, ODS = XLSX; 10 | -------------------------------------------------------------------------------- /demos/database/SheetJSMongo.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env node */ 3 | var XLSX = require("xlsx"); 4 | 5 | async function book_append_mongo(wb, coll, name) { 6 | const aoo = await coll.find({}, {projection:{_id:0}}).toArray(); 7 | const ws = XLSX.utils.json_to_sheet(aoo); 8 | XLSX.utils.book_append_sheet(wb, ws, name); 9 | return ws; 10 | } 11 | 12 | module.exports = { 13 | book_append_mongo 14 | }; -------------------------------------------------------------------------------- /demos/meteor/client/main.html: -------------------------------------------------------------------------------- 1 | 2 | meteor-xlsx 3 | 4 | 5 | 6 |
 7 | SheetJS Meteor Demo
 8 | 
 9 | {{> sheetjs}}
10 | 
11 | 
12 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /packages/s/dist/typings/s/names/DefinedNameCollection.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | import { DefinedName } from "./DefinedName"; 3 | import { Range } from "../Range"; 4 | export interface DefinedNameCollection { 5 | readonly items: DefinedName[]; 6 | readonly count: number; 7 | add(name: string, ref: string | Range, comment?: string): DefinedName; 8 | getName(name: string): DefinedName; 9 | } 10 | -------------------------------------------------------------------------------- /demos/vue/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: vue 2 | vue: ## Simple server for vue 3 | python -mSimpleHTTPServer 4 | 5 | .PHONY: nuxt 6 | nuxt: ## nuxt.js demo 7 | mkdir -p node_modules 8 | cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd .. 9 | npm i nuxt vue 10 | npx nuxt 11 | 12 | .PHONY: weex 13 | weex: ## Build weex project 14 | bash ./weex.sh 15 | 16 | .PHONY: ios 17 | ios: weex ## weex ios sim 18 | cd SheetJS; weexpack run ios; cd - 19 | -------------------------------------------------------------------------------- /packages/s/src/s/names/DefinedNameCollection.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | import { DefinedName } from "./DefinedName"; 5 | import { Range } from "../Range"; 6 | 7 | export interface DefinedNameCollection { 8 | readonly items: DefinedName[]; 9 | readonly count: number; 10 | add(name: string, ref: string | Range, comment?: string): DefinedName; 11 | getName(name: string): DefinedName; 12 | }; -------------------------------------------------------------------------------- /types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": [ "es5" ], 5 | "noImplicitAny": true, 6 | "noImplicitThis": true, 7 | "strictNullChecks": false, 8 | "baseUrl": ".", 9 | "paths": { "xlsx": ["."] }, 10 | "types": [], 11 | "noEmit": true, 12 | "strictFunctionTypes": true, 13 | "forceConsistentCasingInFileNames": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | var Workbook_1 = require("./s/Workbook"); 6 | exports.Workbook = Workbook_1.Workbook; 7 | var XLSXWrapper_1 = require("./s/XLSXWrapper"); 8 | exports.get_XLSX = XLSXWrapper_1.get_XLSX; 9 | exports.set_XLSX = XLSXWrapper_1.set_XLSX; 10 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /demos/altjs/duktape.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DUKTAPE_VER=2.2.0 3 | if [ ! -e duktape-$DUKTAPE_VER ]; then 4 | if [ ! -e duktape-$DUKTAPE_VER.tar ]; then 5 | if [ ! -e duktape-$DUKTAPE_VER.tar.xz ]; then 6 | curl -O https://duktape.org/duktape-$DUKTAPE_VER.tar.xz 7 | fi 8 | xz -d duktape-$DUKTAPE_VER.tar.xz 9 | fi 10 | tar -xf duktape-$DUKTAPE_VER.tar 11 | fi 12 | 13 | for f in duktape.{c,h} duk_config.h; do 14 | cp duktape-$DUKTAPE_VER/src/$f . 15 | done 16 | 17 | -------------------------------------------------------------------------------- /demos/angular2/nscript.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ ! -e SheetJSNS ]; then 3 | tns create SheetJSNS --template nativescript-template-ng-tutorial 4 | cd SheetJSNS 5 | tns plugin add nativescript-nodeify 6 | npm install xlsx 7 | cd app 8 | npm install xlsx 9 | cd ../.. 10 | fi 11 | 12 | cp ../../dist/xlsx.full.min.js SheetJSNS/ 13 | cp ../../dist/xlsx.full.min.js SheetJSNS/app/ 14 | cp nsmain.ts SheetJSNS/app/main.ts 15 | cp nscript.ts SheetJSNS/app/app.component.ts 16 | -------------------------------------------------------------------------------- /demos/google-sheet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "google-sheet", 3 | "version": "1.0.0", 4 | "description": " This demo is using 'drive-db' to fetch a public Google Sheet and then `xlsx` to save the data locally as test.xlsx", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "start": "node ." 9 | }, 10 | "keywords": [], 11 | "author": "Francisco Presencia (https://francisco.io/)", 12 | "license": "MIT" 13 | } 14 | -------------------------------------------------------------------------------- /demos/headless/puppeteer.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | const puppeteer = require('puppeteer'); 3 | 4 | (async () => { 5 | 6 | const browser = await puppeteer.launch(); 7 | const page = await browser.newPage(); 8 | await page.goto('http://oss.sheetjs.com/sheetjs/tests/', {waitUntil: 'load'}); 9 | await page.waitFor(30*1000); 10 | await page.pdf({path: 'test.pdf', format: 'A4'}); 11 | 12 | browser.close(); 13 | })(); 14 | 15 | -------------------------------------------------------------------------------- /demos/browserify/xlsxworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('../../'); // test against development version 3 | //var XLSX = require('xlsx'); // use in production 4 | postMessage({t:"ready"}); 5 | 6 | onmessage = function (evt) { 7 | var v; 8 | try { 9 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 10 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 11 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 12 | }; 13 | -------------------------------------------------------------------------------- /bits/98_exports.js: -------------------------------------------------------------------------------- 1 | if(typeof parse_xlscfb !== "undefined") XLSX.parse_xlscfb = parse_xlscfb; 2 | XLSX.parse_zip = parse_zip; 3 | XLSX.read = readSync; //xlsread 4 | XLSX.readFile = readFileSync; //readFile 5 | XLSX.readFileSync = readFileSync; 6 | XLSX.write = writeSync; 7 | XLSX.writeFile = writeFileSync; 8 | XLSX.writeFileSync = writeFileSync; 9 | XLSX.writeFileAsync = writeFileAsync; 10 | XLSX.utils = utils; 11 | XLSX.SSF = SSF; 12 | if(typeof CFB !== "undefined") XLSX.CFB = CFB; 13 | -------------------------------------------------------------------------------- /demos/typescript/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | import * as XLSX from 'xlsx'; 5 | 6 | const { read, utils: { sheet_to_json } } = XLSX; 7 | 8 | export function readFirstSheet(data: any, options: XLSX.ParsingOptions): any[][] { 9 | const wb: XLSX.WorkBook = read(data, options); 10 | const ws: XLSX.WorkSheet = wb.Sheets[wb.SheetNames[0]]; 11 | return sheet_to_json(ws, { header: 1, raw: true }); 12 | } 13 | -------------------------------------------------------------------------------- /packages/s/misc/import_test.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | import assert from "assert"; 5 | import * as S from "../esm"; 6 | 7 | /* song and dance for node 12 esm */ 8 | import { createRequire } from 'module'; 9 | const require = createRequire(import.meta.url); 10 | const XLSX = require("../../../"); 11 | 12 | assert(S != null); 13 | S.set_XLSX(XLSX); 14 | assert(S.get_XLSX() == XLSX); 15 | assert(S.get_XLSX().version); -------------------------------------------------------------------------------- /demos/server/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: init 2 | init: 3 | mkdir -p node_modules 4 | cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd - 5 | 6 | .PHONY: request 7 | request: init ## request demo 8 | node _request.js 9 | 10 | .PHONY: express 11 | express: init ## express demo 12 | node express.js 13 | 14 | .PHONY: koa 15 | koa: init ## koa demo 16 | node koa.js 17 | 18 | .PHONY: hapi 19 | hapi: init ## hapi demo 20 | cp ../../dist/xlsx.full.min.js . 21 | node hapi.js 22 | -------------------------------------------------------------------------------- /demos/rollup/rollup.config.node.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import resolve from 'rollup-plugin-node-resolve'; 3 | import commonjs from 'rollup-plugin-commonjs'; 4 | export default { 5 | input: 'main.js', 6 | output: { 7 | file: 'rollup.node.js', 8 | format: 'cjs' 9 | }, 10 | entry: 'main.js', 11 | //dest: 'rollup.node.js', 12 | plugins: [ 13 | resolve({ 14 | module: false 15 | }), 16 | commonjs() 17 | ], 18 | format: 'cjs' 19 | }; 20 | -------------------------------------------------------------------------------- /demos/server/_request.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('xlsx'), request = require('request'); 3 | var url = 'http://www.freddiemac.com/pmms/2017/historicalweeklydata.xls' 4 | request(url, {encoding: null}, function(err, res, data) { 5 | if(err || res.statusCode !== 200) return; 6 | var wb = XLSX.read(data, {type:'buffer'}); 7 | var ws = wb.Sheets[wb.SheetNames[0]]; 8 | console.log(XLSX.utils.sheet_to_csv(ws, {blankrows:false})); 9 | }); 10 | -------------------------------------------------------------------------------- /demos/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xlsx-ts", 3 | "main": "dist/index.js", 4 | "types": "dist/index.d.ts", 5 | "version": "0.0.0", 6 | "license": "Apache-2.0", 7 | "scripts": { 8 | "build": "tsc && browserify -o dist/browser.js src/index.js", 9 | "lint": "tslint lib/*.ts" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "xlsx": "*" 14 | }, 15 | "devDependencies": { 16 | "typescript": "~2.6.1", 17 | "browserify": "~14.5.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demos/webpack/Makefile: -------------------------------------------------------------------------------- 1 | TOOL=webpack 2 | WPOPTS=--display-modules --display-reasons --profile 3 | .PHONY: all 4 | all: main.min.js core.out.js full.out.js app.out.js 5 | 6 | main.min.js: main.out.js 7 | uglifyjs $< > $@ 8 | 9 | .PHONY: main.out.js core.out.js full.out.js 10 | main.out.js core.out.js full.out.js: %.out.js: %.js 11 | webpack $< --output-filename $@ $(WPOPTS) 12 | 13 | .PHONY: app.out.js 14 | app.out.js: webpack.app.js app.js appworker.js 15 | webpack --config $< $(WPOPTS) 16 | -------------------------------------------------------------------------------- /demos/angular2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "baseUrl": "src", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "target": "es5", 12 | "typeRoots": [ 13 | "node_modules/@types" 14 | ], 15 | "lib": [ 16 | "es2016", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demos/rollup/rollup.config.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import resolve from 'rollup-plugin-node-resolve'; 3 | import commonjs from 'rollup-plugin-commonjs'; 4 | export default { 5 | input: 'app.js', 6 | output: { 7 | file: 'rollup.js', 8 | format: 'iife' 9 | }, 10 | entry: 'app.js', 11 | //dest: 'rollup.js', 12 | plugins: [ 13 | resolve({ 14 | module: false, 15 | browser: true, 16 | }), 17 | commonjs() 18 | ], 19 | format: 'iife' 20 | }; 21 | -------------------------------------------------------------------------------- /packages/s/README.md: -------------------------------------------------------------------------------- 1 | # s 2 | 3 | TypeScript/JavaScript wrapper closely aligned with the OfficeJS Excel API in the 4 | MIT-licensed 5 | 6 | The `1.x.x` releases should not be treated as stable. `0.x.x` releases serve to 7 | preserve the original use of the `S` module. 8 | 9 | ## License 10 | 11 | Please consult the attached LICENSE file for details. All rights not explicitly 12 | granted by the Apache 2.0 License are reserved by the Original Author. 13 | -------------------------------------------------------------------------------- /misc/strip_sourcemap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # strip_sourcemap.sh -- strip sourcemaps from a JS file (missing from uglifyjs) 3 | # Copyright (C) 2014-present SheetJS 4 | # note: this version also renames write_shift / read_shift to _W / _R 5 | 6 | if [ $# -gt 0 ]; then 7 | if [ -e "$1" ]; then 8 | sed -i.sheetjs '/sourceMappingURL/d' "$1" 9 | sed -i.sheetjs 's/write_shift/_W/g; s/read_shift/_R/g' "$1" 10 | fi 11 | else 12 | cat - | sed '/sourceMappingURL/d' | sed 's/write_shift/_W/g; s/read_shift/_R/g' 13 | fi 14 | -------------------------------------------------------------------------------- /demos/rollup/rollup.config.worker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import resolve from 'rollup-plugin-node-resolve'; 3 | import commonjs from 'rollup-plugin-commonjs'; 4 | export default { 5 | input: 'xlsxworker.js', 6 | output: { 7 | file: 'worker.js', 8 | format: 'iife' 9 | }, 10 | entry: 'xlsxworker.js', 11 | //dest: 'worker.js', 12 | plugins: [ 13 | resolve({ 14 | module: false, 15 | browser: true, 16 | }), 17 | commonjs() 18 | ], 19 | format: 'iife' 20 | }; 21 | -------------------------------------------------------------------------------- /docbits/55_wbobject.md: -------------------------------------------------------------------------------- 1 | ### Workbook Object 2 | 3 | `workbook.SheetNames` is an ordered list of the sheets in the workbook 4 | 5 | `wb.Sheets[sheetname]` returns an object representing the worksheet. 6 | 7 | `wb.Props` is an object storing the standard properties. `wb.Custprops` stores 8 | custom properties. Since the XLS standard properties deviate from the XLSX 9 | standard, XLS parsing stores core properties in both places. 10 | 11 | `wb.Workbook` stores [workbook-level attributes](#workbook-level-attributes). 12 | 13 | -------------------------------------------------------------------------------- /demos/showcase/README.md: -------------------------------------------------------------------------------- 1 | # Showcase 2 | 3 | Many use cases are too complex to summarize in a short demo. The listed open 4 | source projects use SheetJS libraries in clever deployments. 5 | 6 | ### vscode-data-preview 7 | 8 | **Deployment**: Visual Studio Code Extension 9 | 10 | **Website**: 11 | 12 | **Repository**: 13 | 14 | **Notes**: Demonstrates reading and writing files. 15 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/XLSXWrapper.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | /// 6 | var _XLSX; 7 | if (typeof XLSX !== "undefined") 8 | _XLSX = XLSX; 9 | function get_XLSX() { return _XLSX; } 10 | exports.get_XLSX = get_XLSX; 11 | ; 12 | function set_XLSX(xlsx) { _XLSX = xlsx; } 13 | exports.set_XLSX = set_XLSX; 14 | ; 15 | //# sourceMappingURL=XLSXWrapper.js.map -------------------------------------------------------------------------------- /xlsxworker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | importScripts('dist/shim.js'); 3 | /* uncomment the next line for encoding support */ 4 | importScripts('dist/cpexcel.js'); 5 | importScripts('jszip.js'); 6 | importScripts('xlsx.js'); 7 | postMessage({t:"ready"}); 8 | 9 | onmessage = function (evt) { 10 | var v; 11 | try { 12 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 13 | postMessage({t:"xlsx", d:JSON.stringify(v)}); 14 | } catch(e) { postMessage({t:"e",d:e.stack||e}); } 15 | }; 16 | -------------------------------------------------------------------------------- /demos/google-sheet/index.js: -------------------------------------------------------------------------------- 1 | import xlsx from "xlsx"; 2 | import drive from "drive-db"; 3 | 4 | (async () => { 5 | const data = await drive("1fvz34wY6phWDJsuIneqvOoZRPfo6CfJyPg1BYgHt59k"); 6 | 7 | /* Create a new workbook */ 8 | const workbook = xlsx.utils.book_new(); 9 | 10 | /* make worksheet */ 11 | const worksheet = xlsx.utils.json_to_sheet(data); 12 | 13 | /* Add the worksheet to the workbook */ 14 | xlsx.utils.book_append_sheet(workbook, worksheet); 15 | 16 | xlsx.writeFile(workbook, "test.xlsx"); 17 | })(); 18 | -------------------------------------------------------------------------------- /demos/vue/weex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -e SheetJS ]; then 4 | weexpack create SheetJS 5 | cd SheetJS 6 | npm install 7 | weexpack platform add ios 8 | # see https://github.com/weexteam/weex-pack/issues/133#issuecomment-295806132 9 | sed -i.bak 's/ATSDK-Weex/ATSDK/g' platforms/ios/Podfile 10 | cd - 11 | fi 12 | cp native.vue SheetJS/src/index.vue 13 | if [ ! -e SheetJS/web/bootstrap.min.css ]; then 14 | curl -O https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css 15 | mv bootstrap.min.css SheetJS/web/ 16 | fi 17 | -------------------------------------------------------------------------------- /bits/09_types.js: -------------------------------------------------------------------------------- 1 | /*:: 2 | declare type Block = any; 3 | declare type BufArray = { 4 | newblk(sz:number):Block; 5 | next(sz:number):Block; 6 | end():any; 7 | push(buf:Block):void; 8 | }; 9 | 10 | type RecordHopperCB = {(d:any, Rn:string, RT:number):?boolean;}; 11 | 12 | type EvertType = {[string]:string}; 13 | type EvertNumType = {[string]:number}; 14 | type EvertArrType = {[string]:Array}; 15 | 16 | type StringConv = {(string):string}; 17 | 18 | type WriteObjStrFactory = {from_sheet(ws:Worksheet, o:any, wb:?Workbook):string}; 19 | */ 20 | -------------------------------------------------------------------------------- /demos/headless/phantomjs.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var fs = require('fs'); 3 | var xlsx = require('../../xlsx'); 4 | var page = require('webpage').create(); 5 | 6 | page.open('http://oss.sheetjs.com/sheetjs/tests/', function(status) { 7 | 8 | var data = fs.read('sheetjs.xlsx', {mode: 'rb', charset: 'utf8'}); 9 | var workbook = xlsx.read(data, {type: 'binary'}); 10 | data = xlsx.utils.sheet_to_csv(workbook.Sheets['SheetJS']); 11 | console.log("Data: " + data); 12 | 13 | phantom.exit(); 14 | }); 15 | 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-documentation 2 | 3 | *.md text eol=lf 4 | bits/*.js text eol=lf 5 | test.js text eol=lf 6 | xlsx*.js text eol=lf 7 | *.flow.js text eol=lf 8 | 9 | docbits/* linguist-documentation 10 | dist/* linguist-generated=true binary 11 | *.mjs linguist-generated=true binary 12 | xlsx.js linguist-generated=true binary 13 | xlsxworker.js linguist-generated=true binary 14 | tests/core.js linguist-generated=true binary 15 | tests/fixtures.js linguist-generated=true binary 16 | -------------------------------------------------------------------------------- /demos/function/LambdaProxy/template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion : '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | 4 | Description: Sample Lambda API Gateway Normalizer 5 | Resources: 6 | LambdaProxy: 7 | Type: AWS::Serverless::Function 8 | Properties: 9 | Runtime: nodejs6.10 10 | Handler: index.handler 11 | BinaryMediaTypes: '*/*' 12 | Events: 13 | Api: 14 | Type: Api 15 | Properties: 16 | Path: /LambdaProxy 17 | Method: any 18 | BinaryMediaTypes: '*/*' 19 | -------------------------------------------------------------------------------- /demos/chrome/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SheetJS Chrome Extension Export Test 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
Version
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /demos/headless/slimerjs.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var fs = require('fs'); 3 | var xlsx = require('../../dist/xlsx.full.min'); 4 | var page = require('webpage').create(); 5 | 6 | page.open('http://oss.sheetjs.com/sheetjs/tests/', function(status) { 7 | 8 | var data = fs.read('sheetjs.xlsx', {mode: 'rb', charset: 'utf8'}); 9 | var workbook = xlsx.read(data, {type: 'binary'}); 10 | data = xlsx.utils.sheet_to_csv(workbook.Sheets['SheetJS']); 11 | console.log("Data: " + data); 12 | 13 | phantom.exit(); 14 | }); 15 | 16 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/worksheet/WorksheetCollection.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | /// 6 | var WorksheetCollection = /** @class */ (function () { 7 | function WorksheetCollection(wb) { 8 | this._wb = wb; 9 | } 10 | ; 11 | return WorksheetCollection; 12 | }()); 13 | exports.WorksheetCollection = WorksheetCollection; 14 | ; 15 | //# sourceMappingURL=WorksheetCollection.js.map -------------------------------------------------------------------------------- /demos/angular2/.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "angular2" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "index": "index.html", 11 | "main": "main.ts", 12 | "polyfills": "polyfills.ts", 13 | "test": "test.ts", 14 | "tsconfig": "tsconfig.app.json", 15 | "prefix": "app", 16 | "scripts": [] 17 | } 18 | ], 19 | "defaults": { 20 | "styleExt": "css", 21 | "component": {} 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /demos/parcel/README.md: -------------------------------------------------------------------------------- 1 | # Parcel 2 | 3 | Parcel Bundler starting from version 1.5.0 should play nice with this library 4 | out of the box. The standard import form can be used in JS files: 5 | 6 | ```js 7 | import XLSX from 'xlsx' 8 | ``` 9 | 10 | Errors of the form `Could not statically evaluate fs call` stem from a parcel 11 | [bug](https://github.com/parcel-bundler/parcel/pull/523#issuecomment-357486164). 12 | Upgrade to version 1.5.0 or later. 13 | 14 | [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) 15 | -------------------------------------------------------------------------------- /demos/database/SheetJSStorage.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env browser */ 3 | /*global ObjUtils */ 4 | Storage.prototype.load = function(data) { 5 | var self = this; 6 | Object.keys(data).forEach(function(k) { 7 | self.setItem(k, JSON.stringify(data[k])); 8 | }); 9 | }; 10 | 11 | Storage.prototype.dump = function() { 12 | var obj = {}; 13 | for(var i = 0; i < this.length; ++i) { 14 | var key = this.key(i); 15 | obj[key] = JSON.parse(this.getItem(key)); 16 | } 17 | return ObjUtils.object_to_workbook(obj); 18 | }; 19 | -------------------------------------------------------------------------------- /demos/systemjs/test.node.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var SystemJS = require('systemjs'); 3 | SystemJS.config({ 4 | meta: { 5 | '../../xlsx.js': { format: 'global' }, 6 | '../../dist/xlsx.core.min.js': { format: 'global' }, 7 | '../../dist/xlsx.full.min.js': { format: 'global' }, 8 | }, 9 | paths: { 10 | 'npm:': '/usr/local/lib/node_modules/' 11 | }, 12 | map: { 13 | 'xlsx': 'npm:xlsx/xlsx.js', 14 | 'fs': '@node/fs', 15 | 'crypto': '@node/crypto', 16 | 'stream': '@node/stream' 17 | } 18 | }); 19 | SystemJS.import('./app.node.js'); 20 | -------------------------------------------------------------------------------- /tests/make_fixtures.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var fs = require('fs'); 3 | var paths = fs.readFileSync('tests/fixtures.lst','utf-8').replace(/\r/g,"").split("\n"); 4 | var aux = [ 5 | 'multiformat.lst', 6 | './misc/ssf.json', 7 | './test_files/biff5/number_format_greek.xls' 8 | ] 9 | var fullpaths = paths.concat(aux); 10 | fs.writeFileSync('tests/fixtures.js', 11 | fullpaths.map(function(x) { 12 | return [x, fs.existsSync(x) ? fs.readFileSync(x).toString('base64') : ""] 13 | }).map(function(w) { 14 | return "fs['" + w[0] + "'] = '" + w[1] + "';\n"; 15 | }).join("") 16 | ); 17 | -------------------------------------------------------------------------------- /packages/s/dist/typings/s/Workbook.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /// 3 | import { WorksheetCollection } from "./worksheet/WorksheetCollection"; 4 | import { DefinedNameCollection } from "./names/DefinedNameCollection"; 5 | export declare class Workbook { 6 | private readonly _wb; 7 | private readonly _ws; 8 | private readonly _names; 9 | constructor(wb?: XLSX.WorkBook); 10 | readonly wb: XLSX.WorkBook; 11 | readonly names: DefinedNameCollection; 12 | readonly worksheets: WorksheetCollection; 13 | } 14 | -------------------------------------------------------------------------------- /packages/s/misc/puppetsta.js: -------------------------------------------------------------------------------- 1 | const puppeteer = require("puppeteer"); 2 | const path = require("path"); 3 | 4 | const target = `file://${path.resolve(`${__dirname}/standalone.html`)}`; 5 | console.log(target); 6 | (async () => { 7 | const browser = await puppeteer.launch(); 8 | const page = await browser.newPage(); 9 | page.on('console', msg => console.log('PAGE LOG:', msg.text())); 10 | page.on('error', (err) => { console.error(err); process.exit(1); }); 11 | page.on('pageerror', (err) => { console.error(err); process.exit(2); }); 12 | await page.goto(target); 13 | await browser.close(); 14 | })(); -------------------------------------------------------------------------------- /demos/rollup/Makefile: -------------------------------------------------------------------------------- 1 | TOOL=rollup 2 | .PHONY: all 3 | all: $(TOOL).min.js worker.min.js 4 | 5 | $(TOOL).min.js: $(TOOL).js 6 | uglifyjs $< > $@ 7 | 8 | .PHONY: $(TOOL).js 9 | $(TOOL).js: 10 | # node 11 | rollup -c rollup.config.node.js 12 | node -e 'require("./rollup.node")' 13 | # browser 14 | rollup -c 15 | rollup -c rollup.config.worker.js 16 | 17 | worker.min.js: worker.js 18 | uglifyjs $< > $@ 19 | 20 | .PHONY: init 21 | init: 22 | @npm install rollup-plugin-node-resolve rollup-plugin-commonjs 23 | @mkdir -p node_modules; cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd - 24 | -------------------------------------------------------------------------------- /packages/s/misc/puppetpcl.js: -------------------------------------------------------------------------------- 1 | const puppeteer = require("puppeteer"); 2 | const path = require("path"); 3 | 4 | const target = `file://${path.resolve(`${__dirname}/parcel/parcelout.html`)}`; 5 | console.log(target); 6 | (async () => { 7 | const browser = await puppeteer.launch(); 8 | const page = await browser.newPage(); 9 | page.on('console', msg => console.log('PAGE LOG:', msg.text())); 10 | page.on('error', (err) => { console.error(err); process.exit(1); }); 11 | page.on('pageerror', (err) => { console.error(err); process.exit(2); }); 12 | await page.goto(target); 13 | await browser.close(); 14 | })(); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | *.tgz 4 | _book/ 5 | misc/coverage.html 6 | misc/prof.js 7 | v8.log 8 | tmp 9 | *.[tT][xX][tT] 10 | *.[cC][sS][vV] 11 | *.[dD][iIbB][fF] 12 | *.[pP][rR][nN] 13 | *.[pP][mM][dD]* 14 | *.[pP][dD][fF] 15 | *.[sS][lL][kK] 16 | *.socialcalc 17 | *.[xX][lL][sSwWcCaAtTmM] 18 | *.[xX][lL][sSaAtT][xXmMbB] 19 | *.[oO][dD][sS] 20 | *.[fF][oO][dD][sS] 21 | *.[xX][mM][lL] 22 | *.[uU][oO][sS] 23 | *.[wW][kKqQbB][S1234567890] 24 | *.[qQ][pP][wW] 25 | *.[bB][iI][fF][fF][23458] 26 | *.[rR][tT][fF] 27 | *.[eE][tT][hH] 28 | *.123 29 | *.htm 30 | *.html 31 | *.sheetjs 32 | *.exe 33 | *.img 34 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { "shared-node-browser":true }, 3 | "globals": {}, 4 | "parserOptions": { 5 | "ecmaVersion": 3 6 | }, 7 | "plugins": [ "html", "json" ], 8 | "extends": "eslint:recommended", 9 | "rules": { 10 | "comma-style": [ 2, "last" ], 11 | "comma-dangle": [ 2, "never" ], 12 | "curly": 0, 13 | "no-bitwise": 0, 14 | "no-console": 0, 15 | "no-control-regex": 0, 16 | "no-empty": 0, 17 | "no-trailing-spaces": 2, 18 | "no-use-before-define": [ 1, { 19 | "functions":false, "classes":true, "variables":false 20 | }], 21 | "no-useless-escape": 0, 22 | "semi": [ 2, "always" ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/s/misc/puppetmjs.js: -------------------------------------------------------------------------------- 1 | const puppeteer = require("puppeteer"); 2 | const path = require("path"); 3 | 4 | const target = "http://localhost:7262/misc/module.html"; 5 | (async () => { 6 | const browser = await puppeteer.launch(); 7 | const page = await browser.newPage(); 8 | await page.waitFor(1000); 9 | console.log("page"); 10 | page.on('console', msg => console.log('PAGE LOG:', msg.text())); 11 | page.on('error', (err) => { console.error(err); process.exit(1); }); 12 | page.on('pageerror', (err) => { console.error(err); process.exit(2); }); 13 | await page.goto(target); 14 | await browser.close(); 15 | })(); -------------------------------------------------------------------------------- /demos/webpack/webpack.config.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | module.exports = { 3 | /* ensure that the XLSX variable is exported */ 4 | output: { 5 | libraryTarget: 'var', 6 | library: 'XLSX' 7 | }, 8 | /* module.noParse needed for bower */ 9 | module: { 10 | noParse: [ 11 | /xlsx.core.min.js/, 12 | /xlsx.full.min.js/ 13 | ] 14 | }, 15 | /* Uncomment the next block to suppress codepage */ 16 | /* 17 | resolve: { 18 | alias: { "./dist/cpexcel.js": "" } 19 | }, 20 | */ 21 | /* suppress node shims */ 22 | node: { 23 | process: false, 24 | Buffer: false 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demos/fusebox/fuse.js: -------------------------------------------------------------------------------- 1 | const { FuseBox } = require("fuse-box"); 2 | const common_opts = { 3 | homeDir: ".", 4 | output: "$name.js" 5 | }; 6 | 7 | const browser_opts = { 8 | target: "browser", 9 | natives: { 10 | Buffer: false, 11 | stream: false, 12 | process: false 13 | }, 14 | ...common_opts 15 | }; 16 | 17 | const node_opts = { 18 | target: "node", 19 | ...common_opts 20 | } 21 | 22 | const fuse1 = FuseBox.init(browser_opts); 23 | fuse1.bundle("client").instructions(">sheetjs.ts"); fuse1.run(); 24 | 25 | const fuse2 = FuseBox.init(node_opts); 26 | fuse2.bundle("server").instructions(">sheetjs.ts"); fuse2.run(); 27 | -------------------------------------------------------------------------------- /demos/webpack/webpack.app.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var commonops = { 3 | /* suppress node shims */ 4 | node: { 5 | process: false, 6 | Buffer: false 7 | } 8 | } 9 | 10 | /* app.out.js */ 11 | var app_config = Object.assign({ 12 | entry: './app.js', 13 | output: { path:__dirname, filename: './app.out.js' } 14 | }, commonops); 15 | 16 | /* appworker.out.js */ 17 | var appworker_config = Object.assign({ 18 | entry: './appworker.js', 19 | output: { path:__dirname, filename: './appworker.out.js' } 20 | }, commonops); 21 | 22 | module.exports = [ 23 | app_config, 24 | appworker_config 25 | ] 26 | -------------------------------------------------------------------------------- /demos/angular2/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { SheetJSComponent } from './sheetjs.component'; 5 | 6 | 7 | import { Component } from '@angular/core'; 8 | 9 | @Component({ 10 | selector: 'app-root', 11 | template: `` 12 | }) 13 | export class AppComponent { 14 | title = 'test'; 15 | } 16 | 17 | @NgModule({ 18 | declarations: [ 19 | SheetJSComponent, 20 | AppComponent 21 | ], 22 | imports: [ 23 | BrowserModule 24 | ], 25 | providers: [], 26 | bootstrap: [AppComponent] 27 | }) 28 | export class AppModule { } 29 | -------------------------------------------------------------------------------- /xlsxworker.flow.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /*:: declare var XLSX: XLSXModule; */ 3 | /*:: declare var self: DedicatedWorkerGlobalScope; */ 4 | importScripts('dist/shim.js'); 5 | /* uncomment the next line for encoding support */ 6 | importScripts('dist/cpexcel.js'); 7 | importScripts('jszip.js'); 8 | importScripts('xlsx.js'); 9 | /*::self.*/postMessage({t:"ready"}); 10 | 11 | onmessage = function (evt) { 12 | var v; 13 | try { 14 | v = XLSX.read(evt.data.d, {type: evt.data.b}); 15 | /*::self.*/postMessage({t:"xlsx", d:JSON.stringify(v)}); 16 | } catch(e) { /*::self.*/postMessage({t:"e",d:e.stack||e}); } 17 | }; 18 | -------------------------------------------------------------------------------- /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": "./misc/docs", 3 | "title": "SheetJS js-xlsx", 4 | "author": "sheetjs", 5 | "gitbook": "3.2.2", 6 | "plugins": ["anchorjs", "ga", "sidebar-ad", "-sharing", "-search", "advanced-emoji", "-lunr"], 7 | "pluginsConfig": { 8 | "anchorjs": { 9 | "icon": "#", 10 | "placement": "left", 11 | "visible": "always" 12 | }, 13 | "ga": { 14 | "token": "UA-36810333-1" 15 | }, 16 | "sidebar-ad": { 17 | "imageUrl": "http://oss.sheetjs.com/assets/img/logo.png", 18 | "url": "http://sheetjs.com" 19 | }, 20 | "theme-default": { 21 | "showLevel": false, 22 | "styles": { 23 | "website": "style.css" 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /demos/react/native.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 3 | if [ ! -e SheetJS ]; then 4 | react-native init --version="0.62.2" SheetJS 5 | cd SheetJS 6 | npm i -S xlsx react-native-table-component react-native-fs 7 | cd - 8 | fi 9 | if [ ! -e SheetJS/logo.png ]; then 10 | curl -O http://oss.sheetjs.com/assets/img/logo.png 11 | mv logo.png SheetJS/logo.png 12 | fi 13 | if [ -e SheetJS/index.ios.js ]; then 14 | cp react-native.js SheetJS/index.ios.js 15 | cp react-native.js SheetJS/index.android.js 16 | else 17 | cp react-native.js SheetJS/index.js 18 | fi 19 | cd SheetJS; 20 | RNFB_ANDROID_PERMISSIONS=true react-native link 21 | cd -; 22 | -------------------------------------------------------------------------------- /demos/altjs/qjs.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env qjs 2 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 3 | /* load XLSX */ 4 | std.global.global = std.global; 5 | std.loadScript("xlsx.full.min.js"); 6 | 7 | /* read contents of file */ 8 | var rh = std.open("sheetjs.xlsx", "rb"); 9 | rh.seek(0, std.SEEK_END); 10 | var sz = rh.tell(); 11 | var ab = new ArrayBuffer(sz); 12 | rh.seek(); 13 | rh.read(ab, 0, sz); 14 | rh.close(); 15 | 16 | /* parse file */ 17 | var wb = XLSX.read(ab, {type: 'array'}); 18 | 19 | /* write array */ 20 | var out = XLSX.write(wb, {type: 'array'}); 21 | 22 | /* write contents to file */ 23 | var wh = std.open("sheetjs.qjs.xlsx", "wb"); 24 | wh.write(out, 0, out.byteLength); 25 | wh.close(); 26 | -------------------------------------------------------------------------------- /demos/database/SheetJSForage.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /*global ObjUtils, localforage */ 3 | localforage.load = async function foo(data) { 4 | var keys = Object.keys(data); 5 | for(var i = 0; i < keys.length; ++i) { 6 | var key = keys[i], val = JSON.stringify(data[keys[i]]) 7 | await localforage.setItem(key, val); 8 | } 9 | }; 10 | 11 | localforage.dump = async function() { 12 | var obj = {}; 13 | var length = await localforage.length(); 14 | for(var i = 0; i < length; ++i) { 15 | var key = await this.key(i); 16 | var val = await this.getItem(key); 17 | obj[key] = JSON.parse(val); 18 | } 19 | return ObjUtils.object_to_workbook(obj); 20 | }; 21 | -------------------------------------------------------------------------------- /demos/function/Firebase/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "description": "Cloud Functions for Firebase", 4 | "scripts": { 5 | "serve": "firebase emulators:start --only functions", 6 | "shell": "firebase functions:shell", 7 | "start": "npm run shell", 8 | "deploy": "firebase deploy --only functions", 9 | "logs": "firebase functions:log" 10 | }, 11 | "engines": { 12 | "node": "8" 13 | }, 14 | "dependencies": { 15 | "busboy": "^0.3.1", 16 | "firebase-admin": "^8.6.0", 17 | "firebase-functions": "^3.3.0", 18 | "xlsx": "^0.16.2" 19 | }, 20 | "devDependencies": { 21 | "firebase-functions-test": "^0.1.6" 22 | }, 23 | "private": true 24 | } 25 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/names/DefinedName.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | /// 6 | var DefinedName = /** @class */ (function () { 7 | function DefinedName(name) { 8 | this._name = name; 9 | } 10 | ; 11 | Object.defineProperty(DefinedName.prototype, "raw", { 12 | get: function () { return this._name; }, 13 | enumerable: true, 14 | configurable: true 15 | }); 16 | ; 17 | return DefinedName; 18 | }()); 19 | exports.DefinedName = DefinedName; 20 | ; 21 | //# sourceMappingURL=DefinedName.js.map -------------------------------------------------------------------------------- /demos/altjs/main.swift: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | 3 | let sheetjs = try SheetJSCore(); 4 | 5 | try print(sheetjs.version()); 6 | 7 | let filenames: [[String]] = [ 8 | ["xlsx", "xlsx"], 9 | ["xlsb", "xlsb"], 10 | ["biff8.xls", "xls"], 11 | ["xml.xls", "xlml"] 12 | ]; 13 | 14 | for fn in filenames { 15 | let wb: SJSWorkbook = try sheetjs.readFile(file: "sheetjs." + fn[0]); 16 | let ws: SJSWorksheet = try wb.getSheetAtIndex(idx: 0); 17 | let csv: String = try ws.toCSV(); 18 | print(csv); 19 | let wbout: String = try wb.writeBStr(bookType: fn[1]); 20 | try wbout.write(toFile: "sheetjsswift." + fn[0], atomically: false, encoding: String.Encoding.isoLatin1); 21 | } 22 | -------------------------------------------------------------------------------- /demos/systemjs/worker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | importScripts('https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.20.19/system.js'); 3 | 4 | SystemJS.config({ 5 | meta: { 6 | 'xlsx': { 7 | exports: 'XLSX' // <-- tell SystemJS to expose the XLSX variable 8 | } 9 | }, 10 | map: { 11 | 'xlsx': 'xlsx.full.min.js', // <-- make sure xlsx.full.min.js is in same dir 12 | 'fs': '', // <--| 13 | 'crypto': '', // <--| suppress native node modules 14 | 'stream': '' // <--| 15 | } 16 | }); 17 | 18 | onmessage = function(evt) { 19 | /* the real action is in the _cb function from xlsxworker.js */ 20 | SystemJS.import('xlsxworker.js').then(function() { _cb(evt); }); 21 | }; 22 | -------------------------------------------------------------------------------- /bits/60_macrovba.js: -------------------------------------------------------------------------------- 1 | RELS.DS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet"; 2 | RELS.MS = "http://schemas.microsoft.com/office/2006/relationships/xlMacrosheet"; 3 | 4 | /* macro and dialog sheet stubs */ 5 | function parse_ds_bin(/*::data:any, opts, idx:number, rels, wb, themes, styles*/)/*:Worksheet*/ { return {'!type':'dialog'}; } 6 | function parse_ds_xml(/*::data:any, opts, idx:number, rels, wb, themes, styles*/)/*:Worksheet*/ { return {'!type':'dialog'}; } 7 | function parse_ms_bin(/*::data:any, opts, idx:number, rels, wb, themes, styles*/)/*:Worksheet*/ { return {'!type':'macro'}; } 8 | function parse_ms_xml(/*::data:any, opts, idx:number, rels, wb, themes, styles*/)/*:Worksheet*/ { return {'!type':'macro'}; } 9 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/.* 3 | .*/dist/.* 4 | .*/tmp/.* 5 | 6 | .*/bits/.* 7 | .*/ctest/.* 8 | .*/misc/.* 9 | .*/perf/.* 10 | .*/_book/.* 11 | .*/packages/.* 12 | 13 | .*/demo/browser.js 14 | .*/shim.js 15 | 16 | .*/xlsx.js 17 | .*/xlsx.mini.js 18 | .*/xlsx.mini.flow.js 19 | .*/xlsxworker.js 20 | .*/jszip.js 21 | .*/tests/.* 22 | .*/demos/.* 23 | 24 | #.*/xlsx.flow.js 25 | [include] 26 | xlsxworker.flow.js 27 | xlsx.flow.js 28 | .*/bin/.*.njs 29 | .*/demo/browser.flow.js 30 | test.js 31 | 32 | [libs] 33 | bits/09_types.js 34 | misc/flow.js 35 | misc/flowdeps.js 36 | 37 | [options] 38 | module.file_ext=.js 39 | module.file_ext=.njs 40 | module.ignore_non_literal_requires=true 41 | suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore 42 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/Workbook.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,oCAAoC;AAEpC,6CAAyC;AACzC,uEAAsE;AAEtE,uFAAsF;AAEtF;IAKE,kBAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,sBAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6DAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,sBAAI,wBAAE;aAAN,cAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAE7C,sBAAI,2BAAK;aAAT,cAAqC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IAE1D,sBAAI,gCAAU;aAAd,cAAwC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAE7D,eAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,4BAAQ;AAiBpB,CAAC"} -------------------------------------------------------------------------------- /demos/angular2/ionic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ ! -e SheetJSIonic ]; then 3 | ionic start SheetJSIonic blank --cordova --no-git --no-link src/app/app.module.ts 13 | cd - 14 | fi 15 | 16 | cp ionic.ts SheetJSIonic/src/pages/home/home.ts 17 | rm -f SheetJSIonic/src/pages/home/home.html 18 | -------------------------------------------------------------------------------- /demos/react/NOTES.md: -------------------------------------------------------------------------------- 1 | # Additional Notes 2 | 3 | ## Java, React Native, Gradle versions 4 | 5 | This demo was tested and runs with React Native 0.62.2, Java 11, and Gradle 6 | 3.5.2. Running `make native` will invoke `native.sh`, which uses a fixed version 7 | of React Native 0.62.2 to build and run the demo. 8 | 9 | Make sure you have the correct version of Java (11) installed, since 0.62.2 might 10 | not work with newer versions of Java. 11 | 12 | ## Common Issues 13 | 14 | ``` 15 | ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 16 | ``` 17 | 18 | Add `export JAVA_HOME=`, replacing `` with the location of 19 | your Java install, to your `.bashrc` or any other shell that you are using. 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /packages/s/dist/esm/s/Workbook.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,MAAM,OAAO,QAAQ;IAKnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7C,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;CAE5D;AAAA,CAAC"} -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/Workbook.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,MAAM,OAAO,QAAQ;IAKnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7C,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;CAE5D;AAAA,CAAC"} -------------------------------------------------------------------------------- /demos/function/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: microcule 2 | microcule: mcstream.js 3 | microcule $< 4 | 5 | .PHONY: aws 6 | aws: lambda-proxy 7 | 8 | .PHONY: lambda-proxy 9 | lambda-proxy: 10 | cd LambdaProxy; mkdir -p node_modules; npm install xlsx busboy; sam local start-api; cd - 11 | 12 | .PHONY: init-azure 13 | init-azure: 14 | cd AzureHTTPTrigger; mkdir -p node_modules; npm install xlsx formidable fs 15 | 16 | .PHONY: azure 17 | azure: init-azure 18 | func start 19 | 20 | .PHONY: azure-server 21 | azure-server: 22 | mkdir -p /tmp/azurite 23 | azurite -l /tmp/azurite 24 | 25 | FILES=$(filter-out xlsx.full.min.js,$(wildcard *.js)) $(wildcard *.html) 26 | .PHONY: lint 27 | lint: $(FILES) 28 | eslint $(FILES) 29 | 30 | .PHONY: clean 31 | clean: 32 | rm -f *.db *.xlsx *.csv 33 | -------------------------------------------------------------------------------- /packages/s/test.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | /// 5 | 6 | import { Workbook, set_XLSX, get_XLSX } from "./"; 7 | import * as assert from 'assert'; 8 | const XLSXLib: typeof XLSX = require("../../"); 9 | set_XLSX(XLSXLib); 10 | 11 | import 'mocha'; 12 | 13 | describe('Defined Names', () => { 14 | let wb = new Workbook(); 15 | 16 | it('should add names to blank workbook', () => { 17 | let cnt = wb.names.count; 18 | assert.equal(cnt, 0); 19 | assert.throws(() => { const newname = wb.names.getName("wtf"); }); 20 | wb.names.add("wtf", "Sheet1!A1:A3", "dafuq"); 21 | assert.doesNotThrow(() => { const newname = wb.names.getName("wtf"); }); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /demos/chrome/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "SheetJS Demo", 4 | "description": "Sample Extension using SheetJS to interact with Chrome", 5 | "version": "0.0.1", 6 | "browser_action": { 7 | "default_popup": "popup.html", 8 | "default_icon": "logo.png" 9 | }, 10 | "background": { 11 | "scripts": ["xlsx.full.min.js", "table.js"], 12 | "persistent": false 13 | }, 14 | "content_scripts": [{ 15 | "matches": [""], 16 | "js": ["content.js", "xlsx.full.min.js"], 17 | "run_at": "document_end" 18 | }], 19 | "icons": { 20 | "16": "logo.png" 21 | }, 22 | "permissions": [ 23 | "activeTab", 24 | "", 25 | "bookmarks", 26 | "contextMenus", 27 | "downloads", 28 | "tabs" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /demos/oldie/base64.min.js: -------------------------------------------------------------------------------- 1 | !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})}(); 2 | -------------------------------------------------------------------------------- /demos/meteor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "meteor-xlsx", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "lint": "eslint .", 7 | "start": "meteor run" 8 | }, 9 | "eslintConfig": { 10 | "extends": "@meteorjs/eslint-config-meteor" 11 | }, 12 | "dependencies": { 13 | "babel-runtime": "^6.20.0", 14 | "meteor-node-stubs": "~0.2.4" 15 | }, 16 | "devDependencies": { 17 | "@meteorjs/eslint-config-meteor": "^1.0.5", 18 | "babel-eslint": "^7.2.3", 19 | "eslint": "^3.19.0", 20 | "eslint-config-airbnb": "^13.0.0", 21 | "eslint-import-resolver-meteor": "^0.3.4", 22 | "eslint-plugin-import": "^2.7.0", 23 | "eslint-plugin-jsx-a11y": "^2.2.3", 24 | "eslint-plugin-meteor": "^4.1.4", 25 | "eslint-plugin-react": "^6.10.3" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /demos/angular2/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: angular5 3 | 4 | .PHONY: angular2 angular4 angular5 5 | angular2 angular4 angular5: 6 | cp package.json-$@ package.json 7 | rm -rf node_modules 8 | npm install 9 | if [ ! -e node_modules ]; then mkdir node_modules; fi 10 | if [ ! -e node_modules/xlsx ]; then cd node_modules; ln -s ../../../ xlsx; cd -; fi 11 | npm run build 12 | 13 | .PHONY: ionic 14 | ionic: 15 | bash ./ionic.sh 16 | 17 | .PHONY: ios android browser 18 | ios android browser: ionic 19 | cd SheetJSIonic; ionic cordova emulate $@ 4 | import { get_XLSX } from "./XLSXWrapper"; 5 | import { WorksheetCollection } from "./worksheet/WorksheetCollection"; 6 | import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection"; 7 | export class Workbook { 8 | constructor(wb) { 9 | this._wb = wb || get_XLSX().utils.book_new(); 10 | this._ws = new WorksheetCollection(this._wb); 11 | this._names = new WorkbookDefinedNameCollection(this._wb); 12 | } 13 | ; 14 | get wb() { return this._wb; } 15 | ; 16 | get names() { return this._names; } 17 | get worksheets() { return this._ws; } 18 | ; 19 | } 20 | ; 21 | //# sourceMappingURL=Workbook.js.map -------------------------------------------------------------------------------- /demos/altjs/com/sheetjs/SheetJSFile.java: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | package com.sheetjs; 4 | 5 | import org.mozilla.javascript.NativeObject; 6 | import org.mozilla.javascript.Function; 7 | 8 | public class SheetJSFile { 9 | public NativeObject wb; 10 | public SheetJS sheetjs; 11 | public SheetJSFile() {} 12 | public SheetJSFile(NativeObject wb, SheetJS sheetjs) { this.wb = wb; this.sheetjs = sheetjs; } 13 | public String[] get_sheet_names() { 14 | try { 15 | return JSHelper.get_string_array("SheetNames", this.wb); 16 | } catch(ObjectNotFoundException e) { 17 | return null; 18 | } 19 | } 20 | public SheetJSSheet get_sheet(int idx) throws ObjectNotFoundException { 21 | return new SheetJSSheet(this, idx); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /demos/function/mcstream.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env node */ 3 | // cat file.xlsx | curl --header 'content-type: application/octet-stream' --data-binary @- "http://localhost:3000/" 4 | const XLSX = require('xlsx'); 5 | 6 | const process_RS = (stream, cb) => { 7 | var buffers = []; 8 | stream.on('data', function(data) { buffers.push(data); }); 9 | stream.on('end', function() { 10 | var buffer = Buffer.concat(buffers); 11 | var workbook = XLSX.read(buffer, {type:"buffer"}); 12 | cb(workbook); 13 | }); 14 | }; 15 | 16 | module.exports = (hook) => { 17 | process_RS(hook.req, (wb) => { 18 | hook.res.writeHead(200, { 'Content-Type': 'text/csv' }); 19 | const stream = XLSX.stream.to_csv(wb.Sheets[wb.SheetNames[0]]); 20 | stream.pipe(hook.res); 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /demos/react/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: react 2 | react: init ## Simple server for react and clones 3 | python -mSimpleHTTPServer 4 | 5 | .PHONY: next 6 | next: init ## next.js demo 7 | mkdir -p pages public 8 | cat nexthdr.js sheetjs.js > pages/sheetjs.js 9 | cp ../../shim.js public/shim.js 10 | next 11 | 12 | .PHONY: native 13 | native: ## Build react-native project 14 | bash ./native.sh 15 | 16 | .PHONY: ios 17 | ios: native ## react-native ios sim 18 | cd SheetJS; cd ios; pod install; cd -; react-native run-ios --simulator="iPhone X"; cd - 19 | 20 | .PHONY: android 21 | android: native ## react-native android sim 22 | cd SheetJS; react-native run-android; cd - 23 | 24 | .PHONY: init 25 | init: ## set up node_modules and symlink 26 | mkdir -p node_modules 27 | cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd - 28 | -------------------------------------------------------------------------------- /packages/s/dist/mjs/s/Workbook.mjs: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | /// 4 | import { get_XLSX } from "./XLSXWrapper.mjs"; 5 | import { WorksheetCollection } from "./worksheet/WorksheetCollection.mjs"; 6 | import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection.mjs"; 7 | export class Workbook { 8 | constructor(wb) { 9 | this._wb = wb || get_XLSX().utils.book_new(); 10 | this._ws = new WorksheetCollection(this._wb); 11 | this._names = new WorkbookDefinedNameCollection(this._wb); 12 | } 13 | ; 14 | get wb() { return this._wb; } 15 | ; 16 | get names() { return this._names; } 17 | get worksheets() { return this._ws; } 18 | ; 19 | } 20 | ; 21 | //# sourceMappingURL=Workbook.js.map 22 | -------------------------------------------------------------------------------- /demos/server/sheetjs.csv: -------------------------------------------------------------------------------- 1 | Text,Number,Rich,Span 2 | This is Bold,123,This is Bold,This is Bold 3 | This is Italic,234,This is Italic,This is Italic 4 | This is Underline,345,This is Underline,This is Underline 5 | This is Stricken,456,This is Stricken,This is Stricken 6 | This is 18 px,567,This is 18 px,This is 18 px 7 | This is superscript,678,This is superscript,This is superscript 8 | This is subscript,789,This is subscript,This is subscript 9 | This is red,135,This is red,This is red 10 | This is green,246,This is green,This is green 11 | This is Times,357,This is Times,This is Times 12 | This is BIU,159,This is 01324576 yes,This is BIU 13 | BG Green,255,White on Blue,Green on Black 14 | Standard Newline,W S,"BR 15 | New line","Pre 16 | New line" 17 | Height,100,px (not pt),yeah 18 | Top Left,80,Middle Center,Bottom Right 19 | Top Right,60,Bottom Center,Bottom Left 20 | -------------------------------------------------------------------------------- /packages/s/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: cjs esm mjs S types 3 | 4 | .PHONY: cjs esm types 5 | cjs esm types: %: ./tsconfig/tsconfig.%.json ./src/ 6 | @tsc -p ./tsconfig/tsconfig.$@.json 7 | 8 | .PHONY: mjs 9 | mjs: esm 10 | @./misc/make_mjs.sh 11 | 12 | .PHONY: S 13 | S: cjs 14 | @webpack-cli --config misc/webpack.config.js misc/standalone.js --output-filename S.js --display-modules --display-reasons --profile 15 | 16 | .PHONY: test 17 | test: mjs cjs S 18 | @node misc/require_test.njs 19 | @node --experimental-modules --es-module-specifier-resolution=node misc/import_test.mjs 20 | @cp dist/S.js misc && node misc/puppetsta.js 21 | @concurrently --kill-others -s first "http-server -s -p 7262" "node misc/puppetmjs.js" 22 | @parcel build misc/parcel.html -d misc/parcel -o parcelout.html --public-url "./" && node misc/puppetpcl.js 23 | @mocha -r ts-node/register test.ts -------------------------------------------------------------------------------- /demos/server/worker.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | var XLSX = require('xlsx'); 3 | var fs = require('fs'); 4 | 5 | onmessage = function(e) { 6 | try { switch(e.data.action) { 7 | case 'write': 8 | var ws = XLSX.utils.aoa_to_sheet(e.data.data); 9 | var wb = XLSX.utils.book_new(); 10 | XLSX.utils.book_append_sheet(wb, ws, "SheetJS"); 11 | postMessage({data: XLSX.write(wb, {type:'binary', bookType:e.data.type || e.data.file.match(/\.([^\.]*)$/)[1]})}); 12 | break; 13 | case 'read': 14 | var wb; 15 | if(e.data.file) wb = XLSX.readFile(e.data.file); 16 | else wb = XLSX.read(e.data.data); 17 | var ws = wb.Sheets[wb.SheetNames[0]]; 18 | postMessage({data: XLSX.utils.sheet_to_json(ws, {header:1})}); 19 | break; 20 | default: throw "unknown action"; 21 | }} catch(e) { postMessage({err:e.message || e}); } 22 | }; 23 | -------------------------------------------------------------------------------- /bits/59_vba.js: -------------------------------------------------------------------------------- 1 | var CT_VBA = "application/vnd.ms-office.vbaProject"; 2 | function make_vba_xls(cfb/*:CFBContainer*/) { 3 | var newcfb = CFB.utils.cfb_new({root:"R"}); 4 | cfb.FullPaths.forEach(function(p, i) { 5 | if(p.slice(-1) === "/" || !p.match(/_VBA_PROJECT_CUR/)) return; 6 | var newpath = p.replace(/^[^\/]*/,"R").replace(/\/_VBA_PROJECT_CUR\u0000*/, ""); 7 | CFB.utils.cfb_add(newcfb, newpath, cfb.FileIndex[i].content); 8 | }); 9 | return CFB.write(newcfb); 10 | } 11 | 12 | function fill_vba_xls(cfb/*:CFBContainer*/, vba/*:CFBContainer*/)/*:void*/ { 13 | vba.FullPaths.forEach(function(p, i) { 14 | if(i == 0) return; 15 | var newpath = p.replace(/[^\/]*[\/]/, "/_VBA_PROJECT_CUR/"); 16 | if(newpath.slice(-1) !== "/") CFB.utils.cfb_add(cfb, newpath, vba.FileIndex[i].content); 17 | }); 18 | } 19 | 20 | var VBAFMTS = [ "xlsb", "xlsm", "xlam", "biff8", "xla" ]; 21 | 22 | -------------------------------------------------------------------------------- /demos/database/LowDBTest.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env node */ 3 | var low = require('lowdb'); 4 | var SheetJSAdapter = require('./SheetJSLowDB'); 5 | var adapter = new SheetJSAdapter(); 6 | var db = low(adapter); 7 | 8 | db.defaults({ posts: [], user: {}, count: 0 }).write(); 9 | db.get('posts').push({ id: 1, title: 'lowdb is awesome'}).write(); 10 | db.set('user.name', 'typicode').write(); 11 | db.update('count', function(n) { return n + 1; }).write(); 12 | 13 | adapter.dumpFile('ldb1.xlsx'); 14 | 15 | var adapter2 = new SheetJSAdapter(); 16 | adapter2.loadFile('ldb1.xlsx'); 17 | var db2 = low(adapter2); 18 | 19 | db2.get('posts').push({ id: 2, title: 'mongodb is not'}).write(); 20 | db2.set('user.name', 'sheetjs').write(); 21 | db2.update('count', function(n) { return n + 1; }).write(); 22 | 23 | adapter2.dumpFile('ldb2.xlsx'); 24 | -------------------------------------------------------------------------------- /demos/altjs/SheetJSRhino.java: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | import com.sheetjs.SheetJS; 4 | import com.sheetjs.SheetJSFile; 5 | import com.sheetjs.SheetJSSheet; 6 | 7 | public class SheetJSRhino { 8 | public static void main(String args[]) throws Exception { 9 | try { 10 | SheetJS sjs = new SheetJS(); 11 | 12 | /* open file */ 13 | SheetJSFile xl = sjs.read_file(args[0]); 14 | 15 | /* get sheetnames */ 16 | String[] sheetnames = xl.get_sheet_names(); 17 | System.err.println(sheetnames[0]); 18 | 19 | /* convert to CSV */ 20 | SheetJSSheet sheet = xl.get_sheet(0); 21 | String csv = sheet.get_csv(); 22 | 23 | System.out.println(csv); 24 | 25 | } catch(Exception e) { 26 | throw e; 27 | } finally { 28 | SheetJS.close(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/node-pretest.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: pretest/posttest' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | pretest: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: ljharb/actions/node/install@main 12 | name: 'nvm install lts/* && npm install' 13 | with: 14 | node-version: 'lts/*' 15 | - run: make init 16 | - run: 'cd test_files; make all; cd -' 17 | - run: npm run pretest 18 | 19 | # posttest: 20 | # runs-on: ubuntu-latest 21 | 22 | # steps: 23 | # - uses: actions/checkout@v2 24 | # - uses: ljharb/actions/node/install@main 25 | # name: 'nvm install lts/* && npm install' 26 | # with: 27 | # node-version: 'lts/*' 28 | # - run: make init 29 | # - run: 'cd test_files; make all; cd -' 30 | # - run: npm run posttest 31 | -------------------------------------------------------------------------------- /demos/react/pages/index.js: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | import SheetJSApp from './sheetjs' 3 | const Index = () => ( 4 |
5 | 6 | 7 | SheetJS React Demo 8 | 9 | 10 | 13 | 14 | 20 | 21 |
22 | ); 23 | export default Index; -------------------------------------------------------------------------------- /demos/fusebox/sheetjs.ts: -------------------------------------------------------------------------------- 1 | import * as XLSX from 'xlsx'; 2 | 3 | console.log(XLSX.version); 4 | 5 | const bookType: string = "xlsb"; 6 | const fn: string = "sheetjsfbox." + bookType 7 | const sn: string = "SheetJSFBox"; 8 | const aoa: any[][] = [ ["Sheet", "JS"], ["Fuse", "Box"], [72, 62] ]; 9 | 10 | 11 | var wb: XLSX.WorkBook = XLSX.utils.book_new(); 12 | var ws: XLSX.WorkSheet = XLSX.utils.aoa_to_sheet(aoa); 13 | XLSX.utils.book_append_sheet(wb, ws, sn); 14 | 15 | var payload: string = ""; 16 | var w2: XLSX.WorkBook; 17 | if(typeof process != 'undefined' && process.versions && process.versions.node) { 18 | /* server */ 19 | XLSX.writeFile(wb, fn); 20 | w2 = XLSX.readFile(fn) 21 | } else { 22 | /* client */ 23 | payload = XLSX.write(wb, {bookType: "xlsb", type:"binary"}); 24 | w2 = XLSX.read(payload, {type:"binary"}); 25 | } 26 | 27 | var s2: XLSX.WorkSheet = w2.Sheets[sn]; 28 | console.log(XLSX.utils.sheet_to_csv(s2)); 29 | -------------------------------------------------------------------------------- /docbits/64_cellprops.md: -------------------------------------------------------------------------------- 1 | #### Hyperlinks 2 | 3 | Hyperlinks are stored in the `l` key of cell objects. The `Target` field of the 4 | hyperlink object is the target of the link, including the URI fragment. Tooltips 5 | are stored in the `Tooltip` field and are displayed when you move your mouse 6 | over the text. 7 | 8 | For example, the following snippet creates a link from cell `A3` to 9 | with the tip `"Find us @ SheetJS.com!"`: 10 | 11 | ```js 12 | ws['A3'].l = { Target:"https://sheetjs.com", Tooltip:"Find us @ SheetJS.com!" }; 13 | ``` 14 | 15 | Note that Excel does not automatically style hyperlinks -- they will generally 16 | be displayed as normal text. 17 | 18 | Links where the target is a cell or range or defined name in the same workbook 19 | ("Internal Links") are marked with a leading hash character: 20 | 21 | ```js 22 | ws['A2'].l = { Target:"#E2" }; /* link to cell E2 */ 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /bits/54_drawing.js: -------------------------------------------------------------------------------- 1 | /* 20.5 DrawingML - SpreadsheetML Drawing */ 2 | RELS.IMG = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"; 3 | RELS.DRAW = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"; 4 | 5 | /* 20.5.2.35 wsDr CT_Drawing */ 6 | function parse_drawing(data, rels/*:any*/) { 7 | if(!data) return "??"; 8 | /* 9 | Chartsheet Drawing: 10 | - 20.5.2.35 wsDr CT_Drawing 11 | - 20.5.2.1 absoluteAnchor CT_AbsoluteAnchor 12 | - 20.5.2.16 graphicFrame CT_GraphicalObjectFrame 13 | - 20.1.2.2.16 graphic CT_GraphicalObject 14 | - 20.1.2.2.17 graphicData CT_GraphicalObjectData 15 | - chart reference 16 | the actual type is based on the URI of the graphicData 17 | TODO: handle embedded charts and other types of graphics 18 | */ 19 | var id = (data.match(/]*r:id="([^"]*)"/)||["",""])[1]; 20 | 21 | return rels['!id'][id].Target; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /docbits/50_csf.md: -------------------------------------------------------------------------------- 1 | ## Common Spreadsheet Format 2 | 3 | SheetJS conforms to the Common Spreadsheet Format (CSF): 4 | 5 | ### General Structures 6 | 7 | Cell address objects are stored as `{c:C, r:R}` where `C` and `R` are 0-indexed 8 | column and row numbers, respectively. For example, the cell address `B5` is 9 | represented by the object `{c:1, r:4}`. 10 | 11 | Cell range objects are stored as `{s:S, e:E}` where `S` is the first cell and 12 | `E` is the last cell in the range. The ranges are inclusive. For example, the 13 | range `A3:B7` is represented by the object `{s:{c:0, r:2}, e:{c:1, r:6}}`. 14 | Utility functions perform a row-major order walk traversal of a sheet range: 15 | 16 | ```js 17 | for(var R = range.s.r; R <= range.e.r; ++R) { 18 | for(var C = range.s.c; C <= range.e.c; ++C) { 19 | var cell_address = {c:C, r:R}; 20 | /* if an A1-style address is needed, encode the address */ 21 | var cell_ref = XLSX.utils.encode_cell(cell_address); 22 | } 23 | } 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test_files/ 2 | packages/ 3 | .github/ 4 | tests/files/ 5 | demos/ 6 | index.html 7 | misc/ 8 | node_modules 9 | *.tgz 10 | _book 11 | book.json 12 | tmp 13 | *.[tT][xX][tT] 14 | *.[cC][sS][vV] 15 | *.[dD][iIbB][fF] 16 | *.[pP][rR][nN] 17 | *.[pP][mM][dD]* 18 | *.[pP][dD][fF] 19 | *.[sS][lL][kK] 20 | *.socialcalc 21 | *.[xX][lL][sSwWcCaAtTmM] 22 | *.[xX][lL][sSaAtT][xXmMbB] 23 | *.[oO][dD][sS] 24 | *.[fF][oO][dD][sS] 25 | *.[xX][mM][lL] 26 | *.[uU][oO][sS] 27 | *.[wW][kKqQbB][S1234567890] 28 | *.[qQ][pP][wW] 29 | *.[bB][iI][fF][fF][23458] 30 | *.[rR][tT][fF] 31 | *.[eE][tT][hH] 32 | *.123 33 | *.htm 34 | *.html 35 | *.sheetjs 36 | *.exe 37 | *.img 38 | .gitignore 39 | .gitattributes 40 | .fossaignore 41 | .spelling 42 | .eslintignore 43 | .eslintrc 44 | .jshintrc 45 | CONTRIBUTING.md 46 | Makefile 47 | make.cmd 48 | *.lst 49 | .npmignore 50 | xlsworker.js 51 | shim.js 52 | test.js 53 | .jscs.json 54 | .gitmodules 55 | .travis.yml 56 | .flowconfig 57 | *.flow.js 58 | bits/ 59 | docbits/ 60 | tests/ 61 | -------------------------------------------------------------------------------- /docbits/66_comments.md: -------------------------------------------------------------------------------- 1 | #### Cell Comments 2 | 3 | Cell comments are objects stored in the `c` array of cell objects. The actual 4 | contents of the comment are split into blocks based on the comment author. The 5 | `a` field of each comment object is the author of the comment and the `t` field 6 | is the plain text representation. 7 | 8 | For example, the following snippet appends a cell comment into cell `A1`: 9 | 10 | ```js 11 | if(!ws.A1.c) ws.A1.c = []; 12 | ws.A1.c.push({a:"SheetJS", t:"I'm a little comment, short and stout!"}); 13 | ``` 14 | 15 | Note: XLSB enforces a 54 character limit on the Author name. Names longer than 16 | 54 characters may cause issues with other formats. 17 | 18 | To mark a comment as normally hidden, set the `hidden` property: 19 | 20 | ```js 21 | if(!ws.A1.c) ws.A1.c = []; 22 | ws.A1.c.push({a:"SheetJS", t:"This comment is visible"}); 23 | 24 | if(!ws.A2.c) ws.A2.c = []; 25 | ws.A2.c.hidden = true; 26 | ws.A2.c.push({a:"SheetJS", t:"This comment will be hidden"}); 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /demos/angular2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular5", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@angular/animations": "^5.0.0", 13 | "@angular/common": "^5.0.0", 14 | "@angular/compiler": "^5.0.0", 15 | 16 | "@angular/core": "^5.0.0", 17 | "@angular/forms": "^5.0.0", 18 | "@angular/http": "^5.0.0", 19 | "@angular/platform-browser": "^5.0.0", 20 | "@angular/platform-browser-dynamic": "^5.0.0", 21 | 22 | "@angular/router": "^5.0.0", 23 | "core-js": "^2.4.1", 24 | 25 | "rxjs": "^5.5.2", 26 | 27 | "zone.js": "^0.8.14" 28 | }, 29 | "devDependencies": { 30 | "@angular/cli": "^1.5.3", 31 | "@angular/compiler-cli": "^5.0.0", 32 | "@angular/language-service": "^5.0.0", 33 | "@types/node": "~6.0.60", 34 | "ts-node": "~3.2.0", 35 | "tslint": "~5.7.0", 36 | "typescript": "~2.4.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demos/chrome/content.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env browser */ 3 | /* global XLSX, chrome */ 4 | var coords = [0,0]; 5 | document.addEventListener('mousedown', function(mouse) { 6 | if(mouse && mouse.button == 2) coords = [mouse.clientX, mouse.clientY]; 7 | }); 8 | 9 | chrome.runtime.onMessage.addListener(function(msg, sender, cb) { 10 | if(!msg && !msg['Sheet']) return; 11 | if(msg.Sheet == "JS") { 12 | var elt = document.elementFromPoint(coords[0], coords[1]); 13 | while(elt != null) { 14 | if(elt.tagName.toLowerCase() == "table") return cb(XLSX.utils.table_to_book(elt)); 15 | elt = elt.parentElement; 16 | } 17 | } else if(msg.Sheet == "J5") { 18 | var tables = document.getElementsByTagName("table"); 19 | var wb = XLSX.utils.book_new(); 20 | for(var i = 0; i < tables.length; ++i) { 21 | var ws = XLSX.utils.table_to_sheet(tables[i]); 22 | XLSX.utils.book_append_sheet(wb, ws, "Table" + i); 23 | } 24 | return cb(wb); 25 | } 26 | cb(coords); 27 | }); 28 | -------------------------------------------------------------------------------- /demos/angular2/package.json-angular4: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular4", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@angular/animations": "^4.0.0", 13 | "@angular/common": "^4.0.0", 14 | "@angular/compiler": "^4.0.0", 15 | 16 | "@angular/core": "^4.0.0", 17 | "@angular/forms": "^4.0.0", 18 | "@angular/http": "^4.0.0", 19 | "@angular/platform-browser": "^4.0.0", 20 | "@angular/platform-browser-dynamic": "^4.0.0", 21 | 22 | "@angular/router": "^4.0.0", 23 | "core-js": "^2.4.1", 24 | 25 | "rxjs": "^5.1.0", 26 | 27 | "zone.js": "^0.8.4" 28 | }, 29 | "devDependencies": { 30 | "@angular/cli": "1.1.2", 31 | "@angular/compiler-cli": "^4.0.0", 32 | "@angular/language-service": "^4.0.0", 33 | "@types/node": "~6.0.60", 34 | "ts-node": "~3.0.4", 35 | "tslint": "~5.3.2", 36 | "typescript": "~2.3.3" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demos/angular2/package.json-angular5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular5", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@angular/animations": "^5.0.0", 13 | "@angular/common": "^5.0.0", 14 | "@angular/compiler": "^5.0.0", 15 | 16 | "@angular/core": "^5.0.0", 17 | "@angular/forms": "^5.0.0", 18 | "@angular/http": "^5.0.0", 19 | "@angular/platform-browser": "^5.0.0", 20 | "@angular/platform-browser-dynamic": "^5.0.0", 21 | 22 | "@angular/router": "^5.0.0", 23 | "core-js": "^2.4.1", 24 | 25 | "rxjs": "^5.5.2", 26 | 27 | "zone.js": "^0.8.14" 28 | }, 29 | "devDependencies": { 30 | "@angular/cli": "^1.5.3", 31 | "@angular/compiler-cli": "^5.0.0", 32 | "@angular/language-service": "^5.0.0", 33 | "@types/node": "~6.0.60", 34 | "ts-node": "~3.2.0", 35 | "tslint": "~5.7.0", 36 | "typescript": "~2.4.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demos/browserify/README.md: -------------------------------------------------------------------------------- 1 | # Browserify 2 | 3 | The library is compatible with Browserify and should just work out of the box. 4 | 5 | This demo uses the `require` form to expose the whole library, enabling client 6 | code to access the library with `var XLSX = require('xlsx')`. The JS code from 7 | the root demo was moved to a separate `app.js` script. That script is bundled: 8 | 9 | ```bash 10 | browserify app.js > browserify.js 11 | uglifyjs browserify.js > browserify.min.js 12 | ``` 13 | 14 | ### Worker Scripts 15 | 16 | Browserify can also bundle worker scripts! Instead of using `importScripts`, 17 | the worker script should require the module: 18 | 19 | ```diff 20 | -importScripts('dist/xlsx.full.min.js'); 21 | +var XLSX = require('xlsx'); 22 | ``` 23 | 24 | The same process generates the worker script: 25 | 26 | ```bash 27 | browserify xlsxworker.js > worker.js 28 | uglifyjs worker.js > worker.min.js 29 | ``` 30 | 31 | [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) 32 | -------------------------------------------------------------------------------- /make.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM vim: set ts=2: 3 | 4 | if "%1" == "help" ( 5 | echo make init -- install deps and global modules 6 | echo make lint -- run eslint linter 7 | echo make test -- run mocha test suite 8 | echo remember to download the test_files release! 9 | echo make misc -- run smaller test suite 10 | echo make book -- rebuild README and summary 11 | echo make help -- display this message 12 | ) else if "%1" == "init" ( 13 | npm install 14 | npm install -g eslint eslint-plugin-html eslint-plugin-json 15 | npm install -g mocha markdown-toc 16 | ) else if "%1" == "lint" ( 17 | eslint --ext .js,.njs,.json,.html,.htm xlsx.js xlsx.flow.js bin\xlsx.njs package.json bower.json 18 | ) else if "%1" == "test" ( 19 | SET FMTS= 20 | mocha -R spec -t 30000 21 | ) else if "%1" == "misc" ( 22 | SET FMTS=misc 23 | mocha -R spec -t 30000 24 | ) else if "%1" == "book" ( 25 | type docbits\*.md > README.md 26 | markdown-toc -i README.md 27 | ) else ( 28 | type bits\*.js > xlsx.flow.js 29 | node misc\strip_flow.js > xlsx.js 30 | ) 31 | -------------------------------------------------------------------------------- /packages/s/dist/typings/s/names/WorkbookDefinedNameCollection.d.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /// 3 | import { DefinedNameCollection } from "./DefinedNameCollection"; 4 | import { DefinedName } from "./DefinedName"; 5 | export declare class WorkbookDefinedNameCollection implements DefinedNameCollection { 6 | private readonly _wb; 7 | constructor(wb: XLSX.WorkBook); 8 | /** 9 | * Get read-only array of global defined names 10 | */ 11 | readonly items: DefinedName[]; 12 | /** 13 | * Get defined name object 14 | */ 15 | getName(name: string): DefinedName; 16 | /** 17 | * Number of global defined names 18 | */ 19 | readonly count: number; 20 | /** 21 | * Add or update defined name 22 | * @param name String name 23 | * @param ref Range object or string range/formula 24 | * @param comment Optional comment 25 | */ 26 | add(name: string, ref: string, comment?: string): DefinedName; 27 | } 28 | -------------------------------------------------------------------------------- /docbits/10_install.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | In the browser, just add a script tag: 4 | 5 | ```html 6 | 7 | ``` 8 | 9 |
10 | CDN Availability (click to show) 11 | 12 | | CDN | URL | 13 | |-----------:|:-------------------------------------------| 14 | | `unpkg` | | 15 | | `jsDelivr` | | 16 | | `CDNjs` | | 17 | | `packd` | | 18 | 19 | `unpkg` makes the latest version available at: 20 | 21 | ```html 22 | 23 | ``` 24 | 25 |
26 | 27 | 28 | With [npm](https://www.npmjs.org/package/xlsx): 29 | 30 | ```bash 31 | $ npm install xlsx 32 | ``` 33 | 34 | With [bower](https://bower.io/search/?q=js-xlsx): 35 | 36 | ```bash 37 | $ bower install js-xlsx 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /packages/s/src/s/Workbook.ts: -------------------------------------------------------------------------------- 1 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 2 | /* vim: set ts=2: */ 3 | 4 | /// 5 | 6 | import { get_XLSX } from "./XLSXWrapper"; 7 | import { WorksheetCollection } from "./worksheet/WorksheetCollection"; 8 | import { DefinedNameCollection } from "./names/DefinedNameCollection"; 9 | import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection"; 10 | 11 | export class Workbook { 12 | private readonly _wb: XLSX.WorkBook; 13 | private readonly _ws: WorksheetCollection; 14 | private readonly _names: WorkbookDefinedNameCollection; 15 | 16 | constructor(wb?: XLSX.WorkBook) { 17 | this._wb = wb || get_XLSX().utils.book_new(); 18 | this._ws = new WorksheetCollection(this._wb); 19 | this._names = new WorkbookDefinedNameCollection(this._wb); 20 | }; 21 | 22 | get wb(): XLSX.WorkBook { return this._wb; }; 23 | 24 | get names(): DefinedNameCollection { return this._names; } 25 | 26 | get worksheets(): WorksheetCollection { return this._ws; }; 27 | 28 | }; -------------------------------------------------------------------------------- /demos/array/linest.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /*global module, require, XLSX:true */ 3 | if(typeof require !== 'undefined' && typeof XLSX === 'undefined') XLSX = require('xlsx'); 4 | 5 | function generate_random_file(n) { 6 | if(!n) n = 100; 7 | var aoo = []; 8 | var x_ = 0, y_ = 0, xx = 0, xy = 0; 9 | for(var i = 0; i < n; ++i) { 10 | var y = Math.fround(2 * i + Math.random()); 11 | aoo.push({x:i, y:y}); 12 | x_ += i / n; y_ += y / n; xx += i*i; xy += i * y; 13 | } 14 | var m = Math.fround((xy - n * x_ * y_)/(xx - n * x_ * x_)); 15 | console.log(m, Math.fround(y_ - m * x_), "JS Pre"); 16 | var ws = XLSX.utils.json_to_sheet(aoo); 17 | var wb = XLSX.utils.book_new(); 18 | XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); 19 | ws = XLSX.utils.aoa_to_sheet([[2, 0]]); 20 | XLSX.utils.sheet_set_array_formula(ws, "A1:B1", "LINEST(Sheet1!B2:B101,Sheet1!A2:A101)"); 21 | XLSX.utils.book_append_sheet(wb, ws, "Sheet2"); 22 | 23 | XLSX.writeFile(wb, "linreg.xlsx"); 24 | } 25 | if(typeof module !== 'undefined') module.exports = { 26 | generate_random_file: generate_random_file 27 | }; 28 | -------------------------------------------------------------------------------- /demos/database/SheetJSLowDB.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env node */ 3 | 4 | var XLSX = require('xlsx'); 5 | var ObjUtils = require('./ObjUtils'); 6 | 7 | function SheetJSAdapter() { this.defaultValue = {}; }; 8 | 9 | SheetJSAdapter.prototype.read = function() { return this.defaultValue; }; 10 | SheetJSAdapter.prototype.write = function(/*data*/) {}; 11 | 12 | SheetJSAdapter.prototype.dumpRaw = function() { return ObjUtils.object_to_workbook(this.defaultValue); }; 13 | SheetJSAdapter.prototype.dump = function(options) { XLSX.write(this.dumpRaw(), options); }; 14 | SheetJSAdapter.prototype.dumpFile = function(path, options) { XLSX.writeFile(this.dumpRaw(), path, options); }; 15 | 16 | SheetJSAdapter.prototype.loadRaw = function(wb) { ObjUtils.workbook_set_object(this.defaultValue, wb); }; 17 | SheetJSAdapter.prototype.load = function(data, options) { this.loadRaw(XLSX.read(data, options)); }; 18 | SheetJSAdapter.prototype.loadFile = function(path, options) { this.loadRaw(XLSX.readFile(path, options)); }; 19 | 20 | if(typeof module !== 'undefined') module.exports = SheetJSAdapter; 21 | -------------------------------------------------------------------------------- /bits/56_cmntcommon.js: -------------------------------------------------------------------------------- 1 | RELS.CMNT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"; 2 | 3 | function sheet_insert_comments(sheet, comments/*:Array*/) { 4 | var dense = Array.isArray(sheet); 5 | var cell/*:Cell*/; 6 | comments.forEach(function(comment) { 7 | var r = decode_cell(comment.ref); 8 | if(dense) { 9 | if(!sheet[r.r]) sheet[r.r] = []; 10 | cell = sheet[r.r][r.c]; 11 | } else cell = sheet[comment.ref]; 12 | if (!cell) { 13 | cell = ({t:"z"}/*:any*/); 14 | if(dense) sheet[r.r][r.c] = cell; 15 | else sheet[comment.ref] = cell; 16 | var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1"); 17 | if(range.s.r > r.r) range.s.r = r.r; 18 | if(range.e.r < r.r) range.e.r = r.r; 19 | if(range.s.c > r.c) range.s.c = r.c; 20 | if(range.e.c < r.c) range.e.c = r.c; 21 | var encoded = encode_range(range); 22 | if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded; 23 | } 24 | 25 | if (!cell.c) cell.c = []; 26 | var o/*:Comment*/ = ({a: comment.author, t: comment.t, r: comment.r}); 27 | if(comment.h) o.h = comment.h; 28 | cell.c.push(o); 29 | }); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /demos/altjs/nashorn.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env jjs 2 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 3 | 4 | /* load module */ 5 | var global = (function(){ return this; }).call(null); 6 | load('xlsx.full.min.js'); 7 | 8 | /* helper to convert byte array to plain JS array */ 9 | function b2a(b) { 10 | var out = new Array(b.length); 11 | for(var i = 0; i < out.length; i++) out[i] = (b[i] < 0 ? b[i] + 256 : b[i]); 12 | return out; 13 | } 14 | 15 | function process_file(path) { 16 | java.lang.System.out.println(path); 17 | 18 | /* read file */ 19 | var path = java.nio.file.Paths.get(path); 20 | var bytes = java.nio.file.Files.readAllBytes(path); 21 | var u8a = b2a(bytes); 22 | 23 | /* read data */ 24 | var wb = XLSX.read(u8a, {type:"array"}); 25 | 26 | /* get first worksheet as an array of arrays */ 27 | var ws = wb.Sheets[wb.SheetNames[0]]; 28 | var js = XLSX.utils.sheet_to_json(ws, {header:1}); 29 | 30 | /* print out every line */ 31 | js.forEach(function(l) { java.lang.System.out.println(JSON.stringify(l)); }); 32 | } 33 | 34 | process_file('sheetjs.xlsx'); 35 | process_file('sheetjs.xlsb'); 36 | process_file('sheetjs.biff8.xls'); 37 | -------------------------------------------------------------------------------- /packages/s/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "s", 3 | "version": "1.0.0", 4 | "author": "sheetjs", 5 | "description": "SheetJS Spreadsheet Helper Library", 6 | "keywords": [ 7 | "excel", 8 | "office", 9 | "spreadsheet" 10 | ], 11 | "bin": {}, 12 | "browser": { 13 | "buffer": false, 14 | "crypto": false, 15 | "stream": false, 16 | "process": false, 17 | "fs": false 18 | }, 19 | "main": "./index.js", 20 | "module": "./dist/esm/index.js", 21 | "types": "./dist/typings/index.d.ts", 22 | "dependencies": {}, 23 | "devDependencies": { 24 | "@types/mocha": "^5.2.7", 25 | "mocha": "^6.2.0", 26 | "ts-node": "^8.3.0" 27 | }, 28 | "repository": { 29 | "type": "git", 30 | "url": "git://github.com/SheetJS/js-xlsx.git" 31 | }, 32 | "scripts": {}, 33 | "config": { 34 | "blanket": { 35 | "pattern": "xlsx.js" 36 | } 37 | }, 38 | "alex": { 39 | "allow": [ 40 | "crash", 41 | "wtf", 42 | "holes" 43 | ] 44 | }, 45 | "homepage": "http://sheetjs.com/opensource", 46 | "bugs": { 47 | "url": "https://github.com/SheetJS/js-xlsx/issues" 48 | }, 49 | "license": "Apache-2.0", 50 | "engines": { 51 | "node": ">=0.8" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /demos/angular2/package.json-angular2: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@angular/animations": "^4.0.0", 13 | "@angular/common": "~2.4.1", 14 | "@angular/compiler": "~2.4.1", 15 | "@angular/compiler-cli": "^2.4.1", 16 | "@angular/core": "~2.4.1", 17 | "@angular/forms": "~2.4.1", 18 | "@angular/http": "~2.4.1", 19 | "@angular/platform-browser": "~2.4.1", 20 | "@angular/platform-browser-dynamic": "~2.4.1", 21 | "@angular/platform-server": "^2.4.1", 22 | "@angular/router": "~3.4.0", 23 | "core-js": "^2.4.1", 24 | "reflect-metadata": "^0.1.8", 25 | "rxjs": "^5.0.2", 26 | "systemjs": "0.19.40", 27 | "zone.js": "^0.7.4" 28 | }, 29 | "devDependencies": { 30 | "@angular/cli": "1.1.2", 31 | "@angular/compiler-cli": "^4.0.0", 32 | "@angular/language-service": "^4.0.0", 33 | "@types/node": "~6.0.60", 34 | "ts-node": "~3.0.4", 35 | "tslint": "~5.3.2", 36 | "typescript": "~2.3.3" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demos/meteor/server/main.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import { Meteor } from 'meteor/meteor'; 3 | import { check } from 'meteor/check'; 4 | import XLSX from 'xlsx'; 5 | 6 | Meteor.methods({ 7 | /* read the data and return the workbook object to the frontend */ 8 | uploadS: (bstr, name) => { 9 | check(bstr, String); 10 | check(name, String); 11 | return XLSX.read(bstr, { type: 'binary' }); 12 | }, 13 | uploadU: (ab, name) => { 14 | check(ab, Uint8Array); 15 | check(name, String); 16 | return XLSX.read(ab, { type: 'array' }); 17 | }, 18 | download: (html) => { 19 | check(html, String); 20 | let wb; 21 | if (html.length > 3) { 22 | /* parse workbook if html is available */ 23 | wb = XLSX.read(html, { type: 'binary' }); 24 | } else { 25 | /* generate a workbook object otherwise */ 26 | const data = [['a', 'b', 'c'], [1, 2, 3]]; 27 | const ws = XLSX.utils.aoa_to_sheet(data); 28 | wb = XLSX.utils.book_new(); 29 | XLSX.utils.book_append_sheet(wb, ws, 'SheetJS'); 30 | } 31 | return wb; 32 | }, 33 | }); 34 | 35 | Meteor.startup(() => { }); 36 | -------------------------------------------------------------------------------- /demos/xhr/server.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 3 | 4 | var fs = require('fs'), path = require('path'); 5 | var express = require('express'), app = express(); 6 | var sprintf = require('printj').sprintf; 7 | var logit = require('../server/_logit'); 8 | var cors = require('../server/_cors'); 9 | 10 | var port = +process.argv[2] || +process.env.PORT || 7262; 11 | var basepath = process.cwd(); 12 | 13 | var dir = path.join(__dirname, "files"); 14 | try { fs.mkdirSync(dir); } catch(e) {} 15 | 16 | app.use(logit.mw); 17 | app.use(cors.mw); 18 | app.use(require('express-formidable')({uploadDir: dir})); 19 | app.post('/upload', function(req, res) { 20 | console.log(req.files); 21 | var f = req.files[Object.keys(req.files)[0]]; 22 | var newpath = path.join(dir, f.name); 23 | fs.renameSync(f.path, newpath); 24 | console.log("moved " + f.path + " to " + newpath); 25 | res.end("wrote to " + f.name); 26 | }); 27 | app.use(express.static(path.resolve(basepath))); 28 | app.use(require('serve-index')(basepath, {'icons':true})); 29 | 30 | app.listen(port, function() { console.log('Serving HTTP on port ' + port); }); 31 | 32 | -------------------------------------------------------------------------------- /.github/workflows/node-iojs.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js (io.js)' 2 | 3 | on: [pull_request, push] 4 | 5 | jobs: 6 | matrix: 7 | runs-on: ubuntu-latest 8 | outputs: 9 | latest: ${{ steps.set-matrix.outputs.requireds }} 10 | steps: 11 | - uses: ljharb/actions/node/matrix@main 12 | id: set-matrix 13 | with: 14 | type: 'majors' 15 | preset: 'iojs' 16 | 17 | latest: 18 | needs: [matrix] 19 | name: 'latest majors' 20 | runs-on: ubuntu-latest 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: ${{ fromJson(needs.matrix.outputs.latest) }} 25 | 26 | steps: 27 | - uses: actions/checkout@v2 28 | - uses: ljharb/actions/node/install@main 29 | name: 'nvm install ${{ matrix.node-version }} && npm install' 30 | with: 31 | node-version: ${{ matrix.node-version }} 32 | skip-ls-check: true 33 | - run: make init 34 | - run: 'cd test_files; make all; cd -' 35 | - run: npm run tests-only 36 | 37 | node: 38 | name: 'io.js' 39 | needs: [latest] 40 | runs-on: ubuntu-latest 41 | steps: 42 | - run: 'echo tests completed' 43 | -------------------------------------------------------------------------------- /bits/82_sheeter.js: -------------------------------------------------------------------------------- 1 | function write_sheet_index(wb/*:Workbook*/, sheet/*:?string*/)/*:number*/ { 2 | if(!sheet) return 0; 3 | var idx = wb.SheetNames.indexOf(sheet); 4 | if(idx == -1) throw new Error("Sheet not found: " + sheet); 5 | return idx; 6 | } 7 | 8 | function write_obj_str(factory/*:WriteObjStrFactory*/) { 9 | return function write_str(wb/*:Workbook*/, o/*:WriteOpts*/)/*:string*/ { 10 | var idx = write_sheet_index(wb, o.sheet); 11 | return factory.from_sheet(wb.Sheets[wb.SheetNames[idx]], o, wb); 12 | }; 13 | } 14 | 15 | var write_htm_str = write_obj_str(HTML_); 16 | var write_csv_str = write_obj_str({from_sheet:sheet_to_csv}); 17 | var write_slk_str = write_obj_str(typeof SYLK !== "undefined" ? SYLK : {}); 18 | var write_dif_str = write_obj_str(typeof DIF !== "undefined" ? DIF : {}); 19 | var write_prn_str = write_obj_str(typeof PRN !== "undefined" ? PRN : {}); 20 | var write_rtf_str = write_obj_str(typeof RTF !== "undefined" ? RTF : {}); 21 | var write_txt_str = write_obj_str({from_sheet:sheet_to_txt}); 22 | var write_dbf_buf = write_obj_str(typeof DBF !== "undefined" ? DBF : {}); 23 | var write_eth_str = write_obj_str(typeof ETH !== "undefined" ? ETH : {}); 24 | 25 | -------------------------------------------------------------------------------- /demos/angular2/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SheetJS + Angular 2+ 7 | 8 | 9 | 10 | 11 | 12 |
13 | SheetJS + Angular 2+ demo
14 | 
15 | The core library can be used as-is in angular applications.
16 | The Community Edition README details some common use cases.
17 | We also have some more public demos
18 | 
19 | This demo shows `SheetJSComponent` which provides:
20 | - File input button with an event handler to parse the workbook
21 | - `data` property: array of arrays
22 | - Simple angular table which binds to the `data` property
23 | - `export` function that exports the `data` property to a new file.
24 | 
25 | Sample Spreadsheet
26 | 
27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /demos/electron/main.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* from the electron quick-start */ 3 | var electron = require('electron'); 4 | var XLSX = require('xlsx'); 5 | var app = electron.app; 6 | 7 | var win = null; 8 | 9 | function createWindow() { 10 | if (win) return; 11 | win = new electron.BrowserWindow({ 12 | width: 800, height: 600, 13 | webPreferences: { 14 | worldSafeExecuteJavaScript: true, // required for Electron 12+ 15 | contextIsolation: false, // required for Electron 12+ 16 | nodeIntegration: true, 17 | enableRemoteModule: true 18 | } 19 | }); 20 | win.loadURL("file://" + __dirname + "/index.html"); 21 | win.webContents.openDevTools(); 22 | win.on('closed', function () { win = null; }); 23 | } 24 | if (app.setAboutPanelOptions) app.setAboutPanelOptions({ applicationName: 'sheetjs-electron', applicationVersion: "XLSX " + XLSX.version, copyright: "(C) 2017-present SheetJS LLC" }); 25 | app.on('open-file', function () { console.log(arguments); }); 26 | app.on('ready', createWindow); 27 | app.on('activate', createWindow); 28 | app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit(); }); 29 | -------------------------------------------------------------------------------- /demos/fusebox/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | SheetJS FuseBox Test 8 | 11 | 12 | 13 |
14 | SheetJS FuseBox Demo
15 | 
16 | Source Code Repo
17 | Issues?  Something look weird?  Click here and report an issue
18 | 
19 | Original script: sheetjs.ts
20 | 
21 | Console Output:
22 | 
23 |

24 | 
25 | 
34 | 
35 | 
36 | 
37 | 


--------------------------------------------------------------------------------
/bits/26_crypto.js:
--------------------------------------------------------------------------------
 1 | var OFFCRYPTO = {};
 2 | 
 3 | var make_offcrypto = function(O, _crypto) {
 4 | 	var crypto;
 5 | 	if(typeof _crypto !== 'undefined') crypto = _crypto;
 6 | 	else if(typeof require !== 'undefined') {
 7 | 		try { crypto = require('crypto'); }
 8 | 		catch(e) { crypto = null; }
 9 | 	}
10 | 
11 | 	O.rc4 = function(key, data) {
12 | 		var S = new Array(256);
13 | 		var c = 0, i = 0, j = 0, t = 0;
14 | 		for(i = 0; i != 256; ++i) S[i] = i;
15 | 		for(i = 0; i != 256; ++i) {
16 | 			j = (j + S[i] + (key[i%key.length]).charCodeAt(0))&255;
17 | 			t = S[i]; S[i] = S[j]; S[j] = t;
18 | 		}
19 | 		// $FlowIgnore
20 | 		i = j = 0; var out = new_raw_buf(data.length);
21 | 		for(c = 0; c != data.length; ++c) {
22 | 			i = (i + 1)&255;
23 | 			j = (j + S[i])%256;
24 | 			t = S[i]; S[i] = S[j]; S[j] = t;
25 | 			out[c] = (data[c] ^ S[(S[i]+S[j])&255]);
26 | 		}
27 | 		return out;
28 | 	};
29 | 
30 | 	O.md5 = function(hex) {
31 | 		if(!crypto) throw new Error("Unsupported crypto");
32 | 		return crypto.createHash('md5').update(hex).digest('hex');
33 | 	};
34 | };
35 | /*:: declare var crypto:any; */
36 | /*global crypto:true */
37 | make_offcrypto(OFFCRYPTO, typeof crypto !== "undefined" ? crypto : undefined);
38 | 
39 | 


--------------------------------------------------------------------------------
/misc/legend.dot:
--------------------------------------------------------------------------------
 1 | digraph G {
 2 | 	graph [mindist=0];
 3 | 	labelloc=t;
 4 | 	label="Legend"
 5 | 
 6 | 	subgraph cluster_0 {
 7 | 		label="Supported Format Types"
 8 | 		color="white"
 9 | 		XL[label="Excel",style=filled,color=green];
10 | 		CSF[label="JS",shape=doublecircle];
11 | 		OLD[label="Other",style=filled,color=cyan];
12 | 		{ edge[style=invis] XL -> CSF -> OLD[constraint=false]}
13 | 	}
14 | 
15 | 	subgraph cluster_1 {
16 | 		label="Workbook Format Conversions (blue arrow)"
17 | 		color="white"
18 | 		x1i[label="XLSX"]
19 | 		c1[shape=doublecircle,label="JS"];
20 | 		x1o[label="XLSB"]
21 | 		{ edge[color=blue]
22 | 			x1i->c1[constraint=false,label="read"]
23 | 			c1->x1o[constraint=false,label="write"];
24 | 		}
25 | 	}
26 | 
27 | 	subgraph cluster_2 {
28 | 		label="Single-Worksheet Format Conversions (green arrow)"
29 | 		color="white"
30 | 		x2i[label="SYLK"]
31 | 		c2[shape=doublecircle,label="JS"];
32 | 		x2o[label="CSV"]
33 | 		{ edge[color=aquamarine4]
34 | 			x2i->c2[constraint=false,label="read"]
35 | 			c2->x2o[constraint=false,label="write"];
36 | 		}
37 | 	}
38 | 
39 | 	{ edge[style=invis] XL -> x1i -> x2i; }
40 | 	{ edge[style=invis] CSF -> c1 -> c2; }
41 | 	{ edge[style=invis] OLD -> x1o -> x2o; }
42 | }
43 | 


--------------------------------------------------------------------------------
/demos/altjs/com/sheetjs/SheetJSSheet.java:
--------------------------------------------------------------------------------
 1 | /* xlsx.js (C) 2013-present  SheetJS -- http://sheetjs.com */
 2 | /* vim: set ts=2: */
 3 | package com.sheetjs;
 4 | 
 5 | import org.mozilla.javascript.Function;
 6 | import org.mozilla.javascript.NativeObject;
 7 | 
 8 | public class SheetJSSheet {
 9 |   public NativeObject ws;
10 |   public SheetJSFile wb;
11 |   public SheetJSSheet(SheetJSFile wb, int idx) throws ObjectNotFoundException {
12 |     this.wb = wb;
13 |     this.ws = (NativeObject)JSHelper.get_object("Sheets." + wb.get_sheet_names()[idx],wb.wb);
14 |   }
15 |   public String get_range() throws ObjectNotFoundException {
16 |     return JSHelper.get_object("!ref",this.ws).toString();
17 |   }
18 |   public String get_string_value(String address) throws ObjectNotFoundException {
19 |     return JSHelper.get_object(address + ".v",this.ws).toString();
20 |   }
21 | 
22 |   public String get_csv() throws ObjectNotFoundException {
23 |     Function csvify = (Function)JSHelper.get_object("XLSX.utils.sheet_to_csv",this.wb.sheetjs.scope);
24 |     Object csvArgs[] = {this.ws};
25 |     Object csv = csvify.call(this.wb.sheetjs.cx, this.wb.sheetjs.scope, this.wb.sheetjs.scope, csvArgs);
26 |     return csv.toString();
27 |   }
28 | }
29 | 
30 | 


--------------------------------------------------------------------------------
/demos/server/koasub.js:
--------------------------------------------------------------------------------
 1 | /* xlsx.js (C) 2013-present  SheetJS -- http://sheetjs.com */
 2 | const XLSX = require('xlsx');
 3 | let data = "a,b,c\n1,2,3".split("\n").map(x => x.split(","));
 4 | process.on('message', ([m, data] = _) => {
 5 | 	switch(m) {
 6 | 		case 'load data': load_data(data); break;
 7 | 		case 'get data': get_data(data); break;
 8 | 		case 'get file': get_file(data); break;
 9 | 	}
10 | });
11 | 
12 | function load_data(file) {
13 | 	var wb = XLSX.readFile(file);
14 | 	/* generate array of arrays */
15 | 	data = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]], {header:1});
16 | 	console.log(data);
17 | 	process.send("done");
18 | }
19 | 
20 | /* helper to generate the workbook object */
21 | function make_book() {
22 | 	var ws = XLSX.utils.aoa_to_sheet(data);
23 | 	var wb = XLSX.utils.book_new();
24 | 	XLSX.utils.book_append_sheet(wb, ws, "SheetJS");
25 | 	return wb;
26 | }
27 | 
28 | function get_data(type) {
29 | 	var wb = make_book();
30 | 	/* send buffer back */
31 | 	process.send(XLSX.write(wb, {type:'buffer', bookType:type}));
32 | }
33 | 
34 | function get_file(file) {
35 | 	var wb = make_book();
36 | 	/* write using XLSX.writeFile */
37 | 	XLSX.writeFile(wb, file);
38 | 	process.send("wrote to " + file + "\n");
39 | }
40 | 


--------------------------------------------------------------------------------
/bits/65_fods.js:
--------------------------------------------------------------------------------
 1 | /* Part 3 TODO: actually parse formulae */
 2 | function ods_to_csf_formula(f/*:string*/)/*:string*/ {
 3 | 	if(f.slice(0,3) == "of:") f = f.slice(3);
 4 | 	/* 5.2 Basic Expressions */
 5 | 	if(f.charCodeAt(0) == 61) {
 6 | 		f = f.slice(1);
 7 | 		if(f.charCodeAt(0) == 61) f = f.slice(1);
 8 | 	}
 9 | 	f = f.replace(/COM\.MICROSOFT\./g, "");
10 | 	/* Part 3 Section 5.8 References */
11 | 	f = f.replace(/\[((?:\.[A-Z]+[0-9]+)(?::\.[A-Z]+[0-9]+)?)\]/g, function($$, $1) { return $1.replace(/\./g,""); });
12 | 	/* TODO: something other than this */
13 | 	f = f.replace(/\[.(#[A-Z]*[?!])\]/g, "$1");
14 | 	return f.replace(/[;~]/g,",").replace(/\|/g,";");
15 | }
16 | 
17 | function csf_to_ods_formula(f/*:string*/)/*:string*/ {
18 | 	var o = "of:=" + f.replace(crefregex, "$1[.$2$3$4$5]").replace(/\]:\[/g,":");
19 | 	/* TODO: something other than this */
20 | 	return o.replace(/;/g, "|").replace(/,/g,";");
21 | }
22 | 
23 | function ods_to_csf_3D(r/*:string*/)/*:[string, string]*/ {
24 | 	var a = r.split(":");
25 | 	var s = a[0].split(".")[0];
26 | 	return [s, a[0].split(".")[1] + (a.length > 1 ? (":" + (a[1].split(".")[1] || a[1].split(".")[0])) : "")];
27 | }
28 | 
29 | function csf_to_ods_3D(r/*:string*/)/*:string*/ {
30 | 	return r.replace(/\./,"!");
31 | }
32 | 
33 | 


--------------------------------------------------------------------------------
/demos/nwjs/index.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 
 5 | 
 6 | 
 7 | SheetJS NW.js Demo
 8 | 
20 | 
21 | 
22 | 
23 | SheetJS NW.js Demo
24 | 
25 | Source Code Repo
26 | Issues?  Something look weird?  Click here and report an issue
27 | 
28 |
Drop a spreadsheet file here to see sheet data
29 | ... or click here to select a file 30 | 31 |
32 |

33 |
34 |
35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /docbits/73_sheetprops.md: -------------------------------------------------------------------------------- 1 | #### Sheet Visibility 2 | 3 | Excel enables hiding sheets in the lower tab bar. The sheet data is stored in 4 | the file but the UI does not readily make it available. Standard hidden sheets 5 | are revealed in the "Unhide" menu. Excel also has "very hidden" sheets which 6 | cannot be revealed in the menu. It is only accessible in the VB Editor! 7 | 8 | The visibility setting is stored in the `Hidden` property of sheet props array. 9 | 10 |
11 | More details (click to show) 12 | 13 | | Value | Definition | 14 | |:-----:|:------------| 15 | | 0 | Visible | 16 | | 1 | Hidden | 17 | | 2 | Very Hidden | 18 | 19 | With : 20 | 21 | ```js 22 | > wb.Workbook.Sheets.map(function(x) { return [x.name, x.Hidden] }) 23 | [ [ 'Visible', 0 ], [ 'Hidden', 1 ], [ 'VeryHidden', 2 ] ] 24 | ``` 25 | 26 | Non-Excel formats do not support the Very Hidden state. The best way to test 27 | if a sheet is visible is to check if the `Hidden` property is logical truth: 28 | 29 | ```js 30 | > wb.Workbook.Sheets.map(function(x) { return [x.name, !x.Hidden] }) 31 | [ [ 'Visible', true ], [ 'Hidden', false ], [ 'VeryHidden', false ] ] 32 | ``` 33 |
34 | 35 | -------------------------------------------------------------------------------- /demos/function/Firebase/functions/index.js: -------------------------------------------------------------------------------- 1 | const functions = require('firebase-functions'); 2 | const Busboy = require('busboy'); 3 | const XLSX = require('xlsx'); 4 | 5 | // // Create and Deploy Your First Cloud Functions 6 | // // https://firebase.google.com/docs/functions/write-firebase-functions 7 | // 8 | exports.helloWorld = functions.https.onRequest((request, response) => { 9 | response.send("Hello from Firebase!"); 10 | }); 11 | 12 | exports.main = functions.https.onRequest((req, res) => { 13 | var bb = new Busboy({ 14 | headers: { 15 | 'content-type': req.headers['content-type'] 16 | } 17 | }); 18 | let fields = {}; 19 | let files = {}; 20 | bb.on('field', (fieldname, val) => { 21 | fields[fieldname] = val; 22 | }); 23 | bb.on('file', (fieldname, file, filename) => { 24 | var buffers = []; 25 | file.on('data', (data) => { 26 | buffers.push(data); 27 | }); 28 | file.on('end', () => { 29 | files[fieldname] = [Buffer.concat(buffers), filename]; 30 | }); 31 | }); 32 | bb.on('finish', () => { 33 | let f = files[Object.keys(files)[0]]; 34 | const wb = XLSX.read(f[0], { type: "buffer" }); 35 | // Convert to CSV 36 | res.send(XLSX.utils.sheet_to_csv(wb.Sheets[wb.SheetNames[0]])); 37 | }); 38 | bb.end(req.body) 39 | }); 40 | -------------------------------------------------------------------------------- /demos/chrome/popup.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env browser */ 3 | /* global XLSX, chrome */ 4 | document.getElementById('sjsversion').innerText = "SheetJS " + XLSX.version; 5 | 6 | document.getElementById('sjsversion').addEventListener('click', function() { 7 | chrome.tabs.create({url: "https://sheetjs.com/"}); return false; 8 | }); 9 | 10 | /* recursively walk the bookmark tree */ 11 | function recurse_bookmarks(data, tree, path) { 12 | if(tree.url) data.push({Name: tree.title, Location: tree.url, Path:path}); 13 | var T = path ? (path + "::" + tree.title) : tree.title; 14 | (tree.children||[]).forEach(function(C) { recurse_bookmarks(data, C, T); }); 15 | } 16 | 17 | /* export bookmark data */ 18 | document.getElementById('sjsdownload').addEventListener('click', function() { 19 | chrome.bookmarks.getTree(function(res) { 20 | var data = []; 21 | res.forEach(function(t) { recurse_bookmarks(data, t, ""); }); 22 | 23 | /* create worksheet */ 24 | var ws = XLSX.utils.json_to_sheet(data, { header: ['Name', 'Location', 'Path'] }); 25 | 26 | /* create workbook and export */ 27 | var wb = XLSX.utils.book_new(); 28 | XLSX.utils.book_append_sheet(wb, ws, 'Bookmarks'); 29 | XLSX.writeFile(wb, "bookmarks.xlsx"); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /mini.lst: -------------------------------------------------------------------------------- 1 | bits/00_header.js 2 | bits/01_version.js 3 | misc/02_codepage.js 4 | bits/03_consts.js 5 | bits/04_base64.js 6 | bits/05_buf.js 7 | bits/09_types.js 8 | bits/10_ssf.js 9 | bits/11_ssfutils.js 10 | bits/18_cfb.js 11 | bits/19_fsutils.js 12 | bits/20_jsutils.js 13 | misc/21_ziputils.js 14 | bits/22_xmlutils.js 15 | bits/23_binutils.js 16 | bits/24_hoppers.js 17 | bits/25_cellutils.js 18 | bits/27_csfutils.js 19 | bits/29_xlsenum.js 20 | bits/30_ctype.js 21 | bits/31_rels.js 22 | bits/33_coreprops.js 23 | bits/34_extprops.js 24 | bits/35_custprops.js 25 | bits/40_harb.js 26 | bits/42_sstxml.js 27 | bits/46_stycommon.js 28 | bits/47_styxml.js 29 | bits/49_theme.js 30 | bits/53_externlink.js 31 | bits/54_drawing.js 32 | bits/55_vml.js 33 | bits/56_cmntcommon.js 34 | bits/57_cmntxml.js 35 | bits/59_vba.js 36 | bits/60_macrovba.js 37 | bits/61_fcommon.js 38 | bits/66_wscommon.js 39 | bits/67_wsxml.js 40 | bits/69_chartxml.js 41 | bits/70_csheet.js 42 | bits/71_wbcommon.js 43 | bits/72_wbxml.js 44 | bits/74_xmlbin.js 45 | bits/79_html.js 46 | bits/80_parseods.js 47 | bits/81_writeods.js 48 | bits/82_sheeter.js 49 | bits/84_defaults.js 50 | bits/85_parsezip.js 51 | bits/86_writezip.js 52 | bits/87_read.js 53 | bits/88_write.js 54 | bits/90_utils.js 55 | bits/95_api.js 56 | bits/98_exports.js 57 | bits/99_footer.js 58 | -------------------------------------------------------------------------------- /demos/headless/README.md: -------------------------------------------------------------------------------- 1 | # Headless Browsers 2 | 3 | The library, eschewing unstable and nascent ECMAScript features, plays nicely 4 | with most headless browsers. This demo shows a few common headless scenarios. 5 | 6 | ## PhantomJS 7 | 8 | This was tested in PhantomJS 2.1.1, installed using the node module: 9 | 10 | ```bash 11 | $ npm install -g phantomjs 12 | $ phantomjs phantomjs.js 13 | ``` 14 | 15 | ## Chrome Automation 16 | 17 | This was tested in puppeteer 0.9.0 (Chromium revision 494755) and `chromeless`: 18 | 19 | ```bash 20 | $ npm install puppeteer 21 | $ node puppeteer.js 22 | 23 | $ npm install -g chromeless 24 | $ node chromeless.js 25 | ``` 26 | 27 | Since the main process is node, the read and write features should be placed in 28 | the webpage. The `dist` versions are suitable for web pages. 29 | 30 | 31 | ## wkhtmltopdf 32 | 33 | This was tested in wkhtmltopdf 0.12.4, installed using the official binaries: 34 | 35 | ```bash 36 | $ wkhtmltopdf --javascript-delay 20000 http://oss.sheetjs.com/sheetjs/tests/ test.pdf 37 | ``` 38 | 39 | ## SlimerJS 40 | 41 | This was tested in SlimerJS 0.10.3 and FF 52.0, installed using `brew` on OSX: 42 | 43 | ```bash 44 | $ brew install slimerjs 45 | $ slimerjs slimerjs.js 46 | ``` 47 | 48 | [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) 49 | -------------------------------------------------------------------------------- /demos/electron/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | SheetJS Electron Demo 9 | 21 | 22 | 23 |
24 | SheetJS Electron Demo
25 | 
26 | Source Code Repo
27 | Issues?  Something look weird?  Click here and report an issue
28 | 
29 |
30 |
Drop a spreadsheet file here to see sheet data
31 | ... or click here to select a file 32 | 33 |
34 |

35 |
36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/write.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SheetJS JS-XLSX In-Browser Export Demo 7 | 8 | 11 | 12 | 13 |
14 | 

SheetJS JS-XLSX In-Browser Export Demo

15 | Example Code 16 | 17 | /* Generate Workbook */ 18 | var wb = XLSX.utils.book_new(); 19 | var ws = XLSX.utils.aoa_to_sheet([["a","b"],[1,2,3]]); 20 | XLSX.utils.book_append_sheet(wb, ws, "SheetJS"); 21 | 22 | /* Trigger Download with `writeFile` */ 23 | XLSX.writeFile(wb, "SheetJS.xlsb", {compression:true}); 24 | 25 | Download Generation Methods: 26 | 27 | - IE6-9 require ActiveX and Windows Script support. 28 | The IE_SaveFile function from the included shim uses VBScript. 29 | 30 | - IE10-11 use msSaveBlob API. 31 | 32 | - When supported, `saveAs` will be used. 33 | 34 | - When available, modern browsers use `URL.createObjectURL`. 35 | 36 | Multiple Download Caveat 37 | 38 | Some browsers warn or block attempts to download multiple files. Chrome content 39 | settings support whitelisting domains for automatic multiple downloads. 40 |
41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /docbits/31_writestream.md: -------------------------------------------------------------------------------- 1 | ### Streaming Write 2 | 3 | The streaming write functions are available in the `XLSX.stream` object. They 4 | take the same arguments as the normal write functions but return a Readable 5 | Stream. They are only exposed in NodeJS. 6 | 7 | - `XLSX.stream.to_csv` is the streaming version of `XLSX.utils.sheet_to_csv`. 8 | - `XLSX.stream.to_html` is the streaming version of `XLSX.utils.sheet_to_html`. 9 | - `XLSX.stream.to_json` is the streaming version of `XLSX.utils.sheet_to_json`. 10 | 11 |
12 | nodejs convert to CSV and write file (click to show) 13 | 14 | ```js 15 | var output_file_name = "out.csv"; 16 | var stream = XLSX.stream.to_csv(worksheet); 17 | stream.pipe(fs.createWriteStream(output_file_name)); 18 | ``` 19 | 20 |
21 | 22 |
23 | nodejs write JSON stream to screen (click to show) 24 | 25 | ```js 26 | /* to_json returns an object-mode stream */ 27 | var stream = XLSX.stream.to_json(worksheet, {raw:true}); 28 | 29 | /* the following stream converts JS objects to text via JSON.stringify */ 30 | var conv = new Transform({writableObjectMode:true}); 31 | conv._transform = function(obj, e, cb){ cb(null, JSON.stringify(obj) + "\n"); }; 32 | 33 | stream.pipe(conv); conv.pipe(process.stdout); 34 | ``` 35 | 36 |
37 | 38 | pipes write streams to nodejs response. 39 | 40 | -------------------------------------------------------------------------------- /demos/extendscript/test.jsx: -------------------------------------------------------------------------------- 1 | var thisFile = new File($.fileName); 2 | var basePath = thisFile.path; 3 | 4 | #include "xlsx.extendscript.js"; 5 | 6 | var filename = "/sheetjs.xlsx"; 7 | 8 | /* Read file from disk */ 9 | var workbook = XLSX.readFile(basePath + filename, {cellDates:true}); 10 | 11 | /* Display first worksheet */ 12 | var first_sheet_name = workbook.SheetNames[0], first_worksheet = workbook.Sheets[first_sheet_name]; 13 | var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); 14 | alert(data); 15 | 16 | var outfmts = [ 17 | ["xlsb", "testw.xlsb"], 18 | ["biff8", "testw.xls"], 19 | ["xlml", "testw.xml"], 20 | ["fods", "testw.fods"], 21 | ["csv", "testw.csv"], 22 | ["txt", "testw.txt"], 23 | ["slk", "testw.slk"], 24 | ["eth", "testw.eth"], 25 | ["htm", "testw.htm"], 26 | ["dif", "testw.dif"], 27 | ["ods", "testw.ods"], 28 | ["xlsx", "testw.xlsx"] 29 | ]; 30 | for(var i = 0; i < outfmts.length; ++i) { 31 | alert(outfmts[i][0]); 32 | var fname = basePath + "/" + outfmts[i][1]; 33 | 34 | /* Write file to disk */ 35 | XLSX.writeFile(workbook, fname); 36 | 37 | /* Read new file */ 38 | var wb = XLSX.readFile(fname, {cellDates:true}); 39 | 40 | /* Display first worksheet */ 41 | var f_sheet_name = wb.SheetNames[0], f_worksheet = wb.Sheets[f_sheet_name]; 42 | var data = XLSX.utils.sheet_to_json(f_worksheet, {header:1, cellDates:true}); 43 | alert(data); 44 | } 45 | -------------------------------------------------------------------------------- /demos/chrome/table.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env browser */ 3 | /* global XLSX, chrome */ 4 | chrome.runtime.onInstalled.addListener(function() { 5 | chrome.contextMenus.create({ 6 | type: "normal", 7 | id: "sjsexport", 8 | title: "Export Table to XLSX", 9 | contexts: ["page", "selection"] 10 | }); 11 | chrome.contextMenus.create({ 12 | type: "normal", 13 | id: "sj5export", 14 | title: "Export All Tables in Page", 15 | contexts: ["page", "selection"] 16 | }); 17 | chrome.contextMenus.onClicked.addListener(function(info/*, tab*/) { 18 | var mode = ""; 19 | switch(info.menuItemId) { 20 | case 'sjsexport': mode = "JS"; break; 21 | case 'sj5export': mode = "J5"; break; 22 | default: return; 23 | } 24 | chrome.tabs.query({active: true, currentWindow: true}, function(tabs){ 25 | chrome.tabs.sendMessage(tabs[0].id, {Sheet:mode}, sjsexport_cb); 26 | }); 27 | }); 28 | 29 | chrome.contextMenus.create({ 30 | id: "sjsabout", 31 | title: "About", 32 | contexts: ["browser_action"] 33 | }); 34 | chrome.contextMenus.onClicked.addListener(function(info/*, tab*/) { 35 | if(info.menuItemId !== "sjsabout") return; 36 | chrome.tabs.create({url: "https://sheetjs.com/"}); 37 | }); 38 | }); 39 | 40 | function sjsexport_cb(wb) { 41 | if(!wb || !wb.SheetNames || !wb.Sheets) { return alert("Error in exporting table"); } 42 | XLSX.writeFile(wb, "export.xlsx"); 43 | } 44 | -------------------------------------------------------------------------------- /demos/react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | SheetJS React Demo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 |
24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /demos/function/Firebase/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | firebase-debug.log* 8 | 9 | # Firebase cache 10 | .firebase/ 11 | 12 | # Firebase config 13 | 14 | # Uncomment this if you'd like others to create their own Firebase project. 15 | # For a team working on the same Firebase project(s), it is recommended to leave 16 | # it commented so all members can deploy to the same project(s) in .firebaserc. 17 | .firebaserc 18 | 19 | # Runtime data 20 | pids 21 | *.pid 22 | *.seed 23 | *.pid.lock 24 | 25 | # Directory for instrumented libs generated by jscoverage/JSCover 26 | lib-cov 27 | 28 | # Coverage directory used by tools like istanbul 29 | coverage 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (http://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | 49 | # Optional npm cache directory 50 | .npm 51 | 52 | # Optional eslint cache 53 | .eslintcache 54 | 55 | # Optional REPL history 56 | .node_repl_history 57 | 58 | # Output of 'npm pack' 59 | *.tgz 60 | 61 | # Yarn Integrity file 62 | .yarn-integrity 63 | 64 | # dotenv environment variables file 65 | .env 66 | -------------------------------------------------------------------------------- /demos/extendscript/estoolkit.jsx: -------------------------------------------------------------------------------- 1 | #target estoolkit 2 | var thisFile = new File($.fileName); 3 | var basePath = thisFile.path; 4 | 5 | #include "xlsx.extendscript.js"; 6 | 7 | var filename = "/sheetjs.xlsx"; 8 | 9 | /* Read file from disk */ 10 | var workbook = XLSX.readFile(basePath + filename, {cellDates:true}); 11 | 12 | /* Display first worksheet */ 13 | var first_sheet_name = workbook.SheetNames[0], first_worksheet = workbook.Sheets[first_sheet_name]; 14 | var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); 15 | alert(data); 16 | 17 | var outfmts = [ 18 | ["xlsb", "testw.xlsb"], 19 | ["biff8", "testw.xls"], 20 | ["xlml", "testw.xml"], 21 | ["fods", "testw.fods"], 22 | ["csv", "testw.csv"], 23 | ["txt", "testw.txt"], 24 | ["slk", "testw.slk"], 25 | ["eth", "testw.eth"], 26 | ["htm", "testw.htm"], 27 | ["dif", "testw.dif"], 28 | ["ods", "testw.ods"], 29 | ["xlsx", "testw.xlsx"] 30 | ]; 31 | for(var i = 0; i < outfmts.length; ++i) { 32 | alert(outfmts[i][0]); 33 | var fname = basePath + "/" + outfmts[i][1]; 34 | 35 | /* Write file to disk */ 36 | XLSX.writeFile(workbook, fname); 37 | 38 | /* Read new file */ 39 | var wb = XLSX.readFile(fname, {cellDates:true}); 40 | 41 | /* Display first worksheet */ 42 | var f_sheet_name = wb.SheetNames[0], f_worksheet = wb.Sheets[f_sheet_name]; 43 | var data = XLSX.utils.sheet_to_json(f_worksheet, {header:1, cellDates:true}); 44 | alert(data); 45 | } 46 | -------------------------------------------------------------------------------- /demos/extendscript/indesign.jsx: -------------------------------------------------------------------------------- 1 | #target indesign 2 | var thisFile = new File($.fileName); 3 | var basePath = thisFile.path; 4 | 5 | #include "xlsx.extendscript.js"; 6 | 7 | var filename = "/sheetjs.xlsx"; 8 | 9 | /* Read file from disk */ 10 | var workbook = XLSX.readFile(basePath + filename, {cellDates:true}); 11 | 12 | /* Display first worksheet */ 13 | var first_sheet_name = workbook.SheetNames[0], first_worksheet = workbook.Sheets[first_sheet_name]; 14 | var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); 15 | alert(data); 16 | 17 | var outfmts = [ 18 | ["xlsb", "testw.xlsb"], 19 | ["biff8", "testw.xls"], 20 | ["xlml", "testw.xml"], 21 | ["fods", "testw.fods"], 22 | ["csv", "testw.csv"], 23 | ["txt", "testw.txt"], 24 | ["slk", "testw.slk"], 25 | ["eth", "testw.eth"], 26 | ["htm", "testw.htm"], 27 | ["dif", "testw.dif"], 28 | ["ods", "testw.ods"], 29 | ["xlsx", "testw.xlsx"] 30 | ]; 31 | for(var i = 0; i < outfmts.length; ++i) { 32 | alert(outfmts[i][0]); 33 | var fname = basePath + "/" + outfmts[i][1]; 34 | 35 | /* Write file to disk */ 36 | XLSX.writeFile(workbook, fname); 37 | 38 | /* Read new file */ 39 | var wb = XLSX.readFile(fname, {cellDates:true}); 40 | 41 | /* Display first worksheet */ 42 | var f_sheet_name = wb.SheetNames[0], f_worksheet = wb.Sheets[f_sheet_name]; 43 | var data = XLSX.utils.sheet_to_json(f_worksheet, {header:1, cellDates:true}); 44 | alert(data); 45 | } 46 | -------------------------------------------------------------------------------- /demos/extendscript/photoshop.jsx: -------------------------------------------------------------------------------- 1 | #target photoshop 2 | var thisFile = new File($.fileName); 3 | var basePath = thisFile.path; 4 | 5 | #include "xlsx.extendscript.js"; 6 | 7 | var filename = "/sheetjs.xlsx"; 8 | 9 | /* Read file from disk */ 10 | var workbook = XLSX.readFile(basePath + filename, {cellDates:true}); 11 | 12 | /* Display first worksheet */ 13 | var first_sheet_name = workbook.SheetNames[0], first_worksheet = workbook.Sheets[first_sheet_name]; 14 | var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); 15 | alert(data); 16 | 17 | var outfmts = [ 18 | ["xlsb", "testw.xlsb"], 19 | ["biff8", "testw.xls"], 20 | ["xlml", "testw.xml"], 21 | ["fods", "testw.fods"], 22 | ["csv", "testw.csv"], 23 | ["txt", "testw.txt"], 24 | ["slk", "testw.slk"], 25 | ["eth", "testw.eth"], 26 | ["htm", "testw.htm"], 27 | ["dif", "testw.dif"], 28 | ["ods", "testw.ods"], 29 | ["xlsx", "testw.xlsx"] 30 | ]; 31 | for(var i = 0; i < outfmts.length; ++i) { 32 | alert(outfmts[i][0]); 33 | var fname = basePath + "/" + outfmts[i][1]; 34 | 35 | /* Write file to disk */ 36 | XLSX.writeFile(workbook, fname); 37 | 38 | /* Read new file */ 39 | var wb = XLSX.readFile(fname, {cellDates:true}); 40 | 41 | /* Display first worksheet */ 42 | var f_sheet_name = wb.SheetNames[0], f_worksheet = wb.Sheets[f_sheet_name]; 43 | var data = XLSX.utils.sheet_to_json(f_worksheet, {header:1, cellDates:true}); 44 | alert(data); 45 | } 46 | -------------------------------------------------------------------------------- /demos/extendscript/illustrator.jsx: -------------------------------------------------------------------------------- 1 | #target illustrator 2 | var thisFile = new File($.fileName); 3 | var basePath = thisFile.path; 4 | 5 | #include "xlsx.extendscript.js"; 6 | 7 | var filename = "/sheetjs.xlsx"; 8 | 9 | /* Read file from disk */ 10 | var workbook = XLSX.readFile(basePath + filename, {cellDates:true}); 11 | 12 | /* Display first worksheet */ 13 | var first_sheet_name = workbook.SheetNames[0], first_worksheet = workbook.Sheets[first_sheet_name]; 14 | var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); 15 | alert(data); 16 | 17 | var outfmts = [ 18 | ["xlsb", "testw.xlsb"], 19 | ["biff8", "testw.xls"], 20 | ["xlml", "testw.xml"], 21 | ["fods", "testw.fods"], 22 | ["csv", "testw.csv"], 23 | ["txt", "testw.txt"], 24 | ["slk", "testw.slk"], 25 | ["eth", "testw.eth"], 26 | ["htm", "testw.htm"], 27 | ["dif", "testw.dif"], 28 | ["ods", "testw.ods"], 29 | ["xlsx", "testw.xlsx"] 30 | ]; 31 | for(var i = 0; i < outfmts.length; ++i) { 32 | alert(outfmts[i][0]); 33 | var fname = basePath + "/" + outfmts[i][1]; 34 | 35 | /* Write file to disk */ 36 | XLSX.writeFile(workbook, fname); 37 | 38 | /* Read new file */ 39 | var wb = XLSX.readFile(fname, {cellDates:true}); 40 | 41 | /* Display first worksheet */ 42 | var f_sheet_name = wb.SheetNames[0], f_worksheet = wb.Sheets[f_sheet_name]; 43 | var data = XLSX.utils.sheet_to_json(f_worksheet, {header:1, cellDates:true}); 44 | alert(data); 45 | } 46 | -------------------------------------------------------------------------------- /demos/extendscript/aftereffects.jsx: -------------------------------------------------------------------------------- 1 | #target aftereffects 2 | var thisFile = new File($.fileName); 3 | var basePath = thisFile.path; 4 | 5 | #include "xlsx.extendscript.js"; 6 | 7 | var filename = "/sheetjs.xlsx"; 8 | 9 | /* Read file from disk */ 10 | var workbook = XLSX.readFile(basePath + filename, {cellDates:true}); 11 | 12 | /* Display first worksheet */ 13 | var first_sheet_name = workbook.SheetNames[0], first_worksheet = workbook.Sheets[first_sheet_name]; 14 | var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1}); 15 | alert(data); 16 | 17 | var outfmts = [ 18 | ["xlsb", "testw.xlsb"], 19 | ["biff8", "testw.xls"], 20 | ["xlml", "testw.xml"], 21 | ["fods", "testw.fods"], 22 | ["csv", "testw.csv"], 23 | ["txt", "testw.txt"], 24 | ["slk", "testw.slk"], 25 | ["eth", "testw.eth"], 26 | ["htm", "testw.htm"], 27 | ["dif", "testw.dif"], 28 | ["ods", "testw.ods"], 29 | ["xlsx", "testw.xlsx"] 30 | ]; 31 | for(var i = 0; i < outfmts.length; ++i) { 32 | alert(outfmts[i][0]); 33 | var fname = basePath + "/" + outfmts[i][1]; 34 | 35 | /* Write file to disk */ 36 | XLSX.writeFile(workbook, fname); 37 | 38 | /* Read new file */ 39 | var wb = XLSX.readFile(fname, {cellDates:true}); 40 | 41 | /* Display first worksheet */ 42 | var f_sheet_name = wb.SheetNames[0], f_worksheet = wb.Sheets[f_sheet_name]; 43 | var data = XLSX.utils.sheet_to_json(f_worksheet, {header:1, cellDates:true}); 44 | alert(data); 45 | } 46 | -------------------------------------------------------------------------------- /demos/nwjs/README.md: -------------------------------------------------------------------------------- 1 | # NW.js 2 | 3 | This library is compatible with NW.js and should just work out of the box. 4 | The demonstration uses NW.js 0.24 with the dist script. 5 | 6 | ## Reading data 7 | 8 | The standard HTML5 `FileReader` techniques from the browser apply to NW.js! 9 | This demo includes a drag-and-drop box as well as a file input box, mirroring 10 | the [SheetJS Data Preview Live Demo](https://oss.sheetjs.com/sheetjs/). 11 | 12 | ## Writing data 13 | 14 | File input elements with the attribute `nwsaveas` show UI for saving a file. The 15 | standard trick is to generate a hidden file input DOM element and "click" it. 16 | Since NW.js does not present a `writeFileSync` in the `fs` package, a manual 17 | step is required: 18 | 19 | ```js 20 | /* from within the input change callback, `this.value` is the file name */ 21 | var filename = this.value, bookType = (filename.match(/[^\.]*$/)||["xlsx"])[0]; 22 | 23 | /* convert the TABLE element back to a workbook */ 24 | var wb = XLSX.utils.table_to_book(HTMLOUT); 25 | 26 | /* write to buffer */ 27 | var wbout = XLSX.write(wb, {type:'buffer', bookType:bookType}); 28 | 29 | /* use the async fs.writeFile to save the data */ 30 | fs.writeFile(filename, wbout, function(err) { 31 | if(!err) return alert("Saved to " + filename); 32 | alert("Error: " + (err.message || err)); 33 | }); 34 | ``` 35 | 36 | [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) 37 | -------------------------------------------------------------------------------- /misc/help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # make_help.sh -- process listing of targets and special items in Makefile 3 | # Copyright (C) 2016-present SheetJS 4 | # 5 | # usage in makefile: pipe the output of the following command: 6 | # @grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) 7 | # 8 | # lines starting with "## " are treated as subtitles 9 | # lines starting with "#* " are treated as plaintext comments 10 | # multiple targets with "## " after the ":" are rendered as separate targets 11 | # if the presumed default target is labeled, it will be assigned a unique color 12 | 13 | awk ' 14 | BEGIN{recipes=0;} 15 | !/#[#*] .*$/ {next;} 16 | {multi=0; isrecipe=0;} 17 | /^[^#]*:/ {isrecipe=1; ++recipes;} 18 | /^[^ :]* .*:/ {multi=1} 19 | multi==0 && isrecipe>0 { if(recipes > 1) print; else print $0, "[default]"; next} 20 | isrecipe == 0 {print; next} 21 | multi>0 { 22 | k=split($0, msg, "##"); m=split($0, a, ":"); n=split(a[1], b, " "); 23 | for(i=1; i<=n; ++i) print b[i] ":", "##" msg[2], (recipes==1 && i==1 ? "[default]" : "") 24 | } 25 | END {} 26 | ' | if [[ -t 1 ]]; then 27 | awk ' 28 | BEGIN {FS = ":.*?## "} 29 | {color=36} 30 | /\[default\]/ {color=35} 31 | NF==1 && /^##/ {color=34} 32 | NF==1 && /^#\*/ {color=20; $1 = substr($1, 4)} 33 | {printf "\033[" color "m%-20s\033[0m %s\n", $1, $2;} 34 | END{}' - 35 | else 36 | awk ' 37 | BEGIN {FS = ":.*?## "} 38 | /^#\* / {$1 = substr($1, 4)} 39 | {printf "%-20s %s\n", $1, $2;} 40 | END{}' - 41 | fi 42 | 43 | -------------------------------------------------------------------------------- /docbits/11_demos.md: -------------------------------------------------------------------------------- 1 | ### JS Ecosystem Demos 2 | 3 | The [`demos` directory](demos/) includes sample projects for: 4 | 5 | **Frameworks and APIs** 6 | - [`angularjs`](demos/angular/) 7 | - [`angular 2 / 4 / 5 / 6 and ionic`](demos/angular2/) 8 | - [`knockout`](demos/knockout/) 9 | - [`meteor`](demos/meteor/) 10 | - [`react and react-native`](demos/react/) 11 | - [`vue 2.x and weex`](demos/vue/) 12 | - [`XMLHttpRequest and fetch`](demos/xhr/) 13 | - [`nodejs server`](demos/server/) 14 | - [`databases and key/value stores`](demos/database/) 15 | - [`typed arrays and math`](demos/array/) 16 | 17 | **Bundlers and Tooling** 18 | - [`browserify`](demos/browserify/) 19 | - [`fusebox`](demos/fusebox/) 20 | - [`parcel`](demos/parcel/) 21 | - [`requirejs`](demos/requirejs/) 22 | - [`rollup`](demos/rollup/) 23 | - [`systemjs`](demos/systemjs/) 24 | - [`typescript`](demos/typescript/) 25 | - [`webpack 2.x`](demos/webpack/) 26 | 27 | **Platforms and Integrations** 28 | - [`electron application`](demos/electron/) 29 | - [`nw.js application`](demos/nwjs/) 30 | - [`Chrome / Chromium extensions`](demos/chrome/) 31 | - [`Adobe ExtendScript`](demos/extendscript/) 32 | - [`Headless Browsers`](demos/headless/) 33 | - [`canvas-datagrid`](demos/datagrid/) 34 | - [`x-spreadsheet`](demos/xspreadsheet/) 35 | - [`Swift JSC and other engines`](demos/altjs/) 36 | - [`"serverless" functions`](demos/function/) 37 | - [`internet explorer`](demos/oldie/) 38 | 39 | Other examples are included in the [showcase](demos/showcase/). 40 | 41 | -------------------------------------------------------------------------------- /docbits/56_wbprops.md: -------------------------------------------------------------------------------- 1 | #### Workbook File Properties 2 | 3 | The various file formats use different internal names for file properties. The 4 | workbook `Props` object normalizes the names: 5 | 6 |
7 | File Properties (click to show) 8 | 9 | | JS Name | Excel Description | 10 | |:--------------|:-------------------------------| 11 | | `Title` | Summary tab "Title" | 12 | | `Subject` | Summary tab "Subject" | 13 | | `Author` | Summary tab "Author" | 14 | | `Manager` | Summary tab "Manager" | 15 | | `Company` | Summary tab "Company" | 16 | | `Category` | Summary tab "Category" | 17 | | `Keywords` | Summary tab "Keywords" | 18 | | `Comments` | Summary tab "Comments" | 19 | | `LastAuthor` | Statistics tab "Last saved by" | 20 | | `CreatedDate` | Statistics tab "Created" | 21 | 22 |
23 | 24 | For example, to set the workbook title property: 25 | 26 | ```js 27 | if(!wb.Props) wb.Props = {}; 28 | wb.Props.Title = "Insert Title Here"; 29 | ``` 30 | 31 | Custom properties are added in the workbook `Custprops` object: 32 | 33 | ```js 34 | if(!wb.Custprops) wb.Custprops = {}; 35 | wb.Custprops["Custom Property"] = "Custom Value"; 36 | ``` 37 | 38 | Writers will process the `Props` key of the options object: 39 | 40 | ```js 41 | /* force the Author to be "SheetJS" */ 42 | XLSX.write(wb, {Props:{Author:"SheetJS"}}); 43 | ``` 44 | 45 | -------------------------------------------------------------------------------- /packages/s/dist/cjs/s/Workbook.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */ 3 | /* vim: set ts=2: */ 4 | Object.defineProperty(exports, "__esModule", { value: true }); 5 | /// 6 | var XLSXWrapper_1 = require("./XLSXWrapper"); 7 | var WorksheetCollection_1 = require("./worksheet/WorksheetCollection"); 8 | var WorkbookDefinedNameCollection_1 = require("./names/WorkbookDefinedNameCollection"); 9 | var Workbook = /** @class */ (function () { 10 | function Workbook(wb) { 11 | this._wb = wb || XLSXWrapper_1.get_XLSX().utils.book_new(); 12 | this._ws = new WorksheetCollection_1.WorksheetCollection(this._wb); 13 | this._names = new WorkbookDefinedNameCollection_1.WorkbookDefinedNameCollection(this._wb); 14 | } 15 | ; 16 | Object.defineProperty(Workbook.prototype, "wb", { 17 | get: function () { return this._wb; }, 18 | enumerable: true, 19 | configurable: true 20 | }); 21 | ; 22 | Object.defineProperty(Workbook.prototype, "names", { 23 | get: function () { return this._names; }, 24 | enumerable: true, 25 | configurable: true 26 | }); 27 | Object.defineProperty(Workbook.prototype, "worksheets", { 28 | get: function () { return this._ws; }, 29 | enumerable: true, 30 | configurable: true 31 | }); 32 | ; 33 | return Workbook; 34 | }()); 35 | exports.Workbook = Workbook; 36 | ; 37 | //# sourceMappingURL=Workbook.js.map -------------------------------------------------------------------------------- /bits/04_base64.js: -------------------------------------------------------------------------------- 1 | var Base64 = (function make_b64(){ 2 | var map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 3 | return { 4 | encode: function(input/*:string*/)/*:string*/ { 5 | var o = ""; 6 | var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0; 7 | for(var i = 0; i < input.length; ) { 8 | c1 = input.charCodeAt(i++); 9 | e1 = (c1 >> 2); 10 | 11 | c2 = input.charCodeAt(i++); 12 | e2 = ((c1 & 3) << 4) | (c2 >> 4); 13 | 14 | c3 = input.charCodeAt(i++); 15 | e3 = ((c2 & 15) << 2) | (c3 >> 6); 16 | e4 = (c3 & 63); 17 | if (isNaN(c2)) { e3 = e4 = 64; } 18 | else if (isNaN(c3)) { e4 = 64; } 19 | o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4); 20 | } 21 | return o; 22 | }, 23 | decode: function b64_decode(input/*:string*/)/*:string*/ { 24 | var o = ""; 25 | var c1=0, c2=0, c3=0, e1=0, e2=0, e3=0, e4=0; 26 | input = input.replace(/[^\w\+\/\=]/g, ""); 27 | for(var i = 0; i < input.length;) { 28 | e1 = map.indexOf(input.charAt(i++)); 29 | e2 = map.indexOf(input.charAt(i++)); 30 | c1 = (e1 << 2) | (e2 >> 4); 31 | o += String.fromCharCode(c1); 32 | 33 | e3 = map.indexOf(input.charAt(i++)); 34 | c2 = ((e2 & 15) << 4) | (e3 >> 2); 35 | if (e3 !== 64) { o += String.fromCharCode(c2); } 36 | 37 | e4 = map.indexOf(input.charAt(i++)); 38 | c3 = ((e3 & 3) << 6) | e4; 39 | if (e4 !== 64) { o += String.fromCharCode(c3); } 40 | } 41 | return o; 42 | } 43 | }; 44 | })(); 45 | -------------------------------------------------------------------------------- /demos/rollup/README.md: -------------------------------------------------------------------------------- 1 | # Rollup 2 | 3 | This library presents itself as a CommonJS library, so some configuration is 4 | required. The examples at can be followed pretty much in 5 | verbatim. This sample demonstrates a bundle for browser as well as for node. 6 | 7 | This demo uses the `import` form to expose the whole library, enabling client 8 | code to access the library with `import XLSX from 'xlsx'`. The JS code from 9 | the root demo was moved to a separate `app.js` script. 10 | 11 | ## Required Plugins 12 | 13 | The `rollup-plugin-node-resolve` and `rollup-plugin-commonjs` plugins are used: 14 | 15 | ```js 16 | import resolve from 'rollup-plugin-node-resolve'; 17 | import commonjs from 'rollup-plugin-commonjs'; 18 | export default { 19 | /* ... */ 20 | plugins: [ 21 | resolve({ 22 | module: false, // <-- this library is not an ES6 module 23 | browser: true, // <-- suppress node-specific features 24 | }), 25 | commonjs() 26 | ], 27 | /* ... */ 28 | }; 29 | ``` 30 | 31 | For the browser deployments, the output format is `'iife'`. For node, the 32 | output format is `'cjs'`. 33 | 34 | ### Worker Scripts 35 | 36 | Rollup can also bundle worker scripts! Instead of using `importScripts`, the 37 | worker script should import the module: 38 | 39 | ```diff 40 | -importScripts('dist/xlsx.full.min.js'); 41 | +import XLSX from 'xlsx'; 42 | ``` 43 | 44 | [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) 45 | -------------------------------------------------------------------------------- /demos/database/LocalStorage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | SheetJS Live Demo 8 | 11 | 12 | 13 |
14 | SheetJS LocalStorage Demo
15 | 
16 | Original Data:
17 | 
18 |
19 | Output:
20 | 
21 | 
22 | 23 | 24 | 25 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /bits/43_sstbin.js: -------------------------------------------------------------------------------- 1 | /* [MS-XLSB] 2.4.221 BrtBeginSst */ 2 | function parse_BrtBeginSst(data) { 3 | return [data.read_shift(4), data.read_shift(4)]; 4 | } 5 | 6 | /* [MS-XLSB] 2.1.7.45 Shared Strings */ 7 | function parse_sst_bin(data, opts)/*:SST*/ { 8 | var s/*:SST*/ = ([]/*:any*/); 9 | var pass = false; 10 | recordhopper(data, function hopper_sst(val, R_n, RT) { 11 | switch(RT) { 12 | case 0x009F: /* 'BrtBeginSst' */ 13 | s.Count = val[0]; s.Unique = val[1]; break; 14 | case 0x0013: /* 'BrtSSTItem' */ 15 | s.push(val); break; 16 | case 0x00A0: /* 'BrtEndSst' */ 17 | return true; 18 | 19 | case 0x0023: /* 'BrtFRTBegin' */ 20 | pass = true; break; 21 | case 0x0024: /* 'BrtFRTEnd' */ 22 | pass = false; break; 23 | 24 | default: 25 | if(R_n.indexOf("Begin") > 0){/* empty */} 26 | else if(R_n.indexOf("End") > 0){/* empty */} 27 | if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n); 28 | } 29 | }); 30 | return s; 31 | } 32 | 33 | function write_BrtBeginSst(sst, o) { 34 | if(!o) o = new_buf(8); 35 | o.write_shift(4, sst.Count); 36 | o.write_shift(4, sst.Unique); 37 | return o; 38 | } 39 | 40 | var write_BrtSSTItem = write_RichStr; 41 | 42 | function write_sst_bin(sst/*::, opts*/) { 43 | var ba = buf_array(); 44 | write_record(ba, "BrtBeginSst", write_BrtBeginSst(sst)); 45 | for(var i = 0; i < sst.length; ++i) write_record(ba, "BrtSSTItem", write_BrtSSTItem(sst[i])); 46 | /* FRTSST */ 47 | write_record(ba, "BrtEndSst"); 48 | return ba.end(); 49 | } 50 | -------------------------------------------------------------------------------- /demos/requirejs/README.md: -------------------------------------------------------------------------------- 1 | # RequireJS 2 | 3 | The module complies with the AMD `define` semantics, enabling use in RequireJS 4 | out of the box. 5 | 6 | The require config should set `xlsx` path to the appropriate dist file: 7 | 8 | ```js 9 | paths: { 10 | xlsx: "xlsx.full.min" 11 | }, 12 | ``` 13 | 14 | Once that is set, app code can freely require `"xlsx"`: 15 | 16 | ```js 17 | require(["xlsx"], function(XLSX) { 18 | /* use XLSX here */ 19 | }); 20 | ``` 21 | 22 | ## Deployments 23 | 24 | `browser.html` demonstrates a dynamic deployment, using the in-browser config: 25 | 26 | ```html 27 | 28 | 37 | 38 | ``` 39 | 40 | `optimizer.html` demonstrates an optimized deployment using `build.js` config: 41 | 42 | ```js 43 | /* build config */ 44 | ({ 45 | baseUrl: ".", 46 | name: "app", 47 | paths: { 48 | xlsx: "xlsx.full.min" 49 | }, 50 | out: "app-built.js" 51 | }) 52 | ``` 53 | 54 | The optimizer is invoked with: 55 | 56 | ```bash 57 | node r.js -o build.js paths.requireLib=./require include=requireLib 58 | ``` 59 | 60 | That step creates a file `app-built.js` that can be included in a page: 61 | 62 | ```html 63 | 64 | 65 | ``` 66 | 67 | [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx) 68 | -------------------------------------------------------------------------------- /demos/function/AzureHTTPTrigger/index.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | /* eslint-env node */ 3 | // base64 sheetjs.xlsb | curl -F "data=@-;filename=test.xlsb" http://localhost:7262/api/AzureHTTPTrigger 4 | 5 | const XLSX = require('xlsx'); 6 | const formidable = require('formidable'); 7 | const Readable = require('stream').Readable; 8 | var fs = require('fs'); 9 | 10 | /* formidable expects the request object to be a stream */ 11 | const streamify = (req) => { 12 | if(typeof req.on !== 'undefined') return req; 13 | const s = new Readable(); 14 | s._read = ()=>{}; 15 | s.push(new Buffer(req.body)); 16 | s.push(null); 17 | Object.assign(s, req); 18 | return s; 19 | }; 20 | 21 | module.exports = (context, req) => { 22 | const form = new formidable.IncomingForm(); 23 | form.parse(streamify(req), (err, fields, files) => { 24 | /* grab the first file */ 25 | var f = Object.values(files)[0]; 26 | if(!f) { 27 | context.res = { status: 400, body: "Must submit a file for processing!" }; 28 | } else { 29 | /* file is stored in a temp directory, so we can point to that and read it */ 30 | const wb = XLSX.read(f.path, {type:"file"}); 31 | 32 | /* convert to specified output type -- default CSV */ 33 | const ext = (fields.bookType || "csv").toLowerCase(); 34 | const out = XLSX.write(wb, {type:"string", bookType:ext}); 35 | 36 | context.res = { 37 | status: 200, 38 | headers: { "Content-Disposition": `attachment; filename="download.${ext}";` }, 39 | body: out 40 | }; 41 | } 42 | context.done(); 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /demos/meteor/client/main.js: -------------------------------------------------------------------------------- 1 | /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ 2 | import XLSX from 'xlsx'; 3 | 4 | import { Meteor } from 'meteor/meteor'; 5 | import { Template } from 'meteor/templating'; 6 | 7 | import './main.html'; 8 | 9 | Template.sheetjs.events({ 10 | 'change input' (event) { 11 | /* "Browser file upload form element" from SheetJS README */ 12 | const file = event.currentTarget.files[0]; 13 | const reader = new FileReader(); 14 | const rABS = !!reader.readAsBinaryString; 15 | reader.onload = function(e) { 16 | const data = e.target.result; 17 | const name = file.name; 18 | /* Meteor magic */ 19 | Meteor.call(rABS ? 'uploadS' : 'uploadU', rABS ? data : new Uint8Array(data), name, function(err, wb) { 20 | if (err) throw err; 21 | /* load the first worksheet */ 22 | const ws = wb.Sheets[wb.SheetNames[0]]; 23 | /* generate HTML table and enable export */ 24 | const html = XLSX.utils.sheet_to_html(ws, { editable: true }); 25 | document.getElementById('out').innerHTML = html; 26 | document.getElementById('dnload').disabled = false; 27 | }); 28 | }; 29 | if(rABS) reader.readAsBinaryString(file); else reader.readAsArrayBuffer(file); 30 | }, 31 | 'click button' () { 32 | const html = document.getElementById('out').innerHTML; 33 | Meteor.call('download', html, function(err, wb) { 34 | if (err) throw err; 35 | /* "Browser download file" from SheetJS README */ 36 | XLSX.writeFile(wb, 'sheetjs.xlsx'); 37 | }); 38 | }, 39 | }); 40 | 41 | --------------------------------------------------------------------------------