version bump 0.15.0: mini build

- new xlsx.mini build that strips XLS/XLSB/niche formats
- updated CFB to 1.1.3
- removed niche sheet_to_{dif,slk,eth} utilities
- removed exported ODS parse/write funcs, read/write still supports ODS
This commit is contained in:
SheetJS 2019-08-04 15:50:49 -04:00
parent 442c4342df
commit 4aeb0a786a
34 changed files with 17513 additions and 318 deletions

@ -1,6 +1,8 @@
language: node_js
dist: xenial
node_js:
- "12"
- "11"
- "10"
- "9"
- "8"

@ -7,20 +7,24 @@ AUXTARGETS=
CMDS=bin/xlsx.njs
HTMLLINT=index.html
MINITGT=xlsx.mini.js
MINIFLOW=xlsx.mini.flow.js
MINIDEPS=$(shell cat mini.lst)
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
DEPS=$(sort $(wildcard bits/*.js))
TARGET=$(LIB).js
FLOWTARGET=$(LIB).flow.js
FLOWAUX=$(patsubst %.js,%.flow.js,$(AUXTARGETS))
AUXSCPTS=xlsxworker.js
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS)
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS) $(MINITGT)
UGLIFYOPTS=--support-ie8 -m
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
## Main Targets
.PHONY: all
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) ## Build library and auxiliary scripts
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) $(MINITGT) ## Build library and auxiliary scripts
$(FLOWTGTS): %.js : %.flow.js
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
@ -28,6 +32,9 @@ $(FLOWTGTS): %.js : %.flow.js
$(FLOWTARGET): $(DEPS)
cat $^ | tr -d '\15\32' > $@
$(MINIFLOW): $(MINIDEPS)
cat $^ | tr -d '\15\32' > $@
bits/01_version.js: package.json
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
@ -62,7 +69,9 @@ dist: dist-deps $(TARGET) bower.json ## Prepare JS files for distribution
uglifyjs $(DISTHDR) $(REQS) dist/$(TARGET) $(UGLIFYOPTS) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
uglifyjs $(DISTHDR) $(REQS) $(ADDONS) dist/$(TARGET) $(AUXTARGETS) $(UGLIFYOPTS) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
uglifyjs $(DISTHDR) $(MINITGT) $(UGLIFYOPTS) -o dist/$(LIB).mini.min.js --source-map dist/$(LIB).mini.min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).full.min.js
misc/strip_sourcemap.sh dist/$(LIB).mini.min.js
cat <(head -n 1 bits/00_header.js) shim.js $(DISTHDR) $(REQS) dist/$(TARGET) > dist/$(LIB).extendscript.js
.PHONY: dist-deps
@ -74,7 +83,7 @@ dist-deps: ## Copy dependencies for distribution
.PHONY: aux
aux: $(AUXTARGETS)
BYTEFILE=dist/xlsx.min.js dist/xlsx.{core,full}.min.js dist/xlsx.extendscript.js
BYTEFILE=dist/xlsx.min.js dist/xlsx.{core,full,mini}.min.js dist/xlsx.extendscript.js
.PHONY: bytes
bytes: ## Display minified and gzipped file sizes
for i in $(BYTEFILE); do printj "%-30s %7d %10d" $$i $$(wc -c < $$i) $$(gzip --best --stdout $$i | wc -c); done

@ -238,6 +238,8 @@ An appropriate version for each dependency is included in the dist/ directory.
The complete single-file version is generated at `dist/xlsx.full.min.js`
A slimmer build with XLSX / HTML support is generated at `dist/xlsx.mini.min.js`
Webpack and Browserify builds include optional modules by default. Webpack can
be configured to remove support with `resolve.alias`:

@ -1 +1 @@
XLSX.version = '0.14.5';
XLSX.version = '0.15.0';

@ -38,8 +38,8 @@ function s2ab(s/*:string*/)/*:any*/ {
}
function a2s(data/*:any*/)/*:string*/ {
if(Array.isArray(data)) return data.map(_chr).join("");
var o/*:Array<string>*/ = []; for(var i = 0; i < data.length; ++i) o[i] = _chr(data[i]); return o.join("");
if(Array.isArray(data)) return data.map(function(c) { return String.fromCharCode(c); }).join("");
var o/*:Array<string>*/ = []; for(var i = 0; i < data.length; ++i) o[i] = String.fromCharCode(data[i]); return o.join("");
}
function a2u(data/*:Array<number>*/)/*:Uint8Array*/ {

@ -142,7 +142,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
exports.version = '1.1.2';
exports.version = '1.1.3';
/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
@ -1291,7 +1291,7 @@ function parse_local_file(blob/*:CFBlob*/, csz/*:number*/, usz/*:number*/, o/*:C
if(_csz != csz) warn_or_throw(wrn, "Bad compressed size: " + csz + " != " + _csz);
if(_usz != usz) warn_or_throw(wrn, "Bad uncompressed size: " + usz + " != " + _usz);
var _crc32 = CRC32.buf(data, 0);
if(crc32 != _crc32) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
if((crc32>>0) != (_crc32>>0)) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
cfb_add(o, name, data, {unsafe: true, mt: date});
}
function write_zip(cfb/*:CFBContainer*/, options/*:CFBWriteOpts*/)/*:RawBytes*/ {

@ -4,6 +4,7 @@ function getdatastr(data)/*:?string*/ {
if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));
if(data.asBinary) return debom(data.asBinary());
if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
if(data.content && data.type) return debom(cc2str(data.content));
return null;
}
@ -16,6 +17,7 @@ function getdatabin(data) {
if(typeof o == "string") return char_codes(o);
return Array.prototype.slice.call(o);
}
if(data.content && data.type) return data.content;
return null;
}
@ -24,7 +26,7 @@ function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getda
/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */
/* OASIS does not comment on filename case sensitivity */
function safegetzipfile(zip, file/*:string*/) {
var k = keys(zip.files);
var k = zip.FullPaths || keys(zip.files);
var f = file.toLowerCase(), g = f.replace(/\//g,'\\');
for(var i=0; i<k.length; ++i) {
var n = k[i].toLowerCase();
@ -52,11 +54,27 @@ function getzipstr(zip, file/*:string*/, safe/*:?boolean*/)/*:?string*/ {
}
function zipentries(zip) {
var k = keys(zip.files), o = [];
var k = zip.FullPaths || keys(zip.files), o = [];
for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]);
return o.sort();
}
function zip_add_file(zip, path, content) {
if(zip.FullPaths) CFB.utils.cfb_add(zip, path, content);
else zip.file(path, content);
}
function zip_read(d, o) {
var zip;
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
return zip;
}
var jszip;
/*:: declare var JSZipSync:any; */
/*global JSZipSync:true */
@ -67,6 +85,10 @@ if(typeof exports !== 'undefined') {
}
}
function zip_new() {
return new jszip();
}
function resolve_path(path/*:string*/, base/*:string*/)/*:string*/ {
var result = base.split('/');
if(base.slice(-1) != "/") result.pop(); // folder path

@ -1,6 +1,5 @@
var attregexg2=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;
var attregex2=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;
var _chr = function(c) { return String.fromCharCode(c); };
function xlml_parsexmltag(tag/*:string*/, skip_root/*:?boolean*/) {
var words = tag.split(/\s+/);
var z/*:any*/ = ([]/*:any*/); if(!skip_root) z[0] = words[0];

@ -182,7 +182,7 @@ function write_ods(wb/*:any*/, opts/*:any*/) {
if(opts.bookType == "fods") return write_content_ods(wb, opts);
/*:: if(!jszip) throw new Error("JSZip is not available"); */
var zip = new jszip();
var zip = zip_new();
var f = "";
var manifest/*:Array<Array<string> >*/ = [];
@ -190,34 +190,34 @@ function write_ods(wb/*:any*/, opts/*:any*/) {
/* Part 3 Section 3.3 MIME Media Type */
f = "mimetype";
zip.file(f, "application/vnd.oasis.opendocument.spreadsheet");
zip_add_file(zip, f, "application/vnd.oasis.opendocument.spreadsheet");
/* Part 1 Section 2.2 Documents */
f = "content.xml";
zip.file(f, write_content_ods(wb, opts));
zip_add_file(zip, f, write_content_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "ContentFile"]);
/* TODO: these are hard-coded styles to satiate excel */
f = "styles.xml";
zip.file(f, write_styles_ods(wb, opts));
zip_add_file(zip, f, write_styles_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "StylesFile"]);
/* TODO: this is hard-coded to satiate excel */
f = "meta.xml";
zip.file(f, write_meta_ods(/*::wb, opts*/));
zip_add_file(zip, f, write_meta_ods(/*::wb, opts*/));
manifest.push([f, "text/xml"]);
rdf.push([f, "MetadataFile"]);
/* Part 3 Section 6 Metadata Manifest File */
f = "manifest.rdf";
zip.file(f, write_rdf(rdf/*, opts*/));
zip_add_file(zip, f, write_rdf(rdf/*, opts*/));
manifest.push([f, "application/rdf+xml"]);
/* Part 3 Section 4 Manifest File */
f = "META-INF/manifest.xml";
zip.file(f, write_manifest(manifest/*, opts*/));
zip_add_file(zip, f, write_manifest(manifest/*, opts*/));
return zip;
}

@ -14,11 +14,11 @@ function write_obj_str(factory/*:WriteObjStrFactory*/) {
var write_htm_str = write_obj_str(HTML_);
var write_csv_str = write_obj_str({from_sheet:sheet_to_csv});
var write_slk_str = write_obj_str(SYLK);
var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_slk_str = write_obj_str(typeof SYLK !== "undefined" ? SYLK : {});
var write_dif_str = write_obj_str(typeof DIF !== "undefined" ? DIF : {});
var write_prn_str = write_obj_str(typeof PRN !== "undefined" ? PRN : {});
var write_rtf_str = write_obj_str(typeof RTF !== "undefined" ? RTF : {});
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
var write_dbf_buf = write_obj_str(typeof DBF !== "undefined" ? DBF : {});
var write_eth_str = write_obj_str(typeof ETH !== "undefined" ? ETH : {});

@ -19,7 +19,7 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
var ct = new_ct();
fix_write_opts(opts = opts || {});
/*:: if(!jszip) throw new Error("JSZip is not available"); */
var zip = new jszip();
var zip = zip_new();
var f = "", rId = 0;
opts.cellXfs = [];
@ -28,7 +28,7 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
if(!wb.Props) wb.Props = {};
f = "docProps/core.xml";
zip.file(f, write_core_props(wb.Props, opts));
zip_add_file(zip, f, write_core_props(wb.Props, opts));
ct.coreprops.push(f);
add_rels(opts.rels, 2, f, RELS.CORE_PROPS);
@ -43,13 +43,13 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
wb.Props.SheetNames = _sn;
}
wb.Props.Worksheets = wb.Props.SheetNames.length;
zip.file(f, write_ext_props(wb.Props, opts));
zip_add_file(zip, f, write_ext_props(wb.Props, opts));
ct.extprops.push(f);
add_rels(opts.rels, 3, f, RELS.EXT_PROPS);
if(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {
f = "docProps/custom.xml";
zip.file(f, write_cust_props(wb.Custprops, opts));
zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));
ct.custprops.push(f);
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
}
@ -61,14 +61,14 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
switch(_type) {
case "chart": /*
f = "xl/chartsheets/sheet" + rId + "." + wbext;
zip.file(f, write_cs(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_cs(rId-1, f, opts, wb, wsrels));
ct.charts.push(f);
add_rels(wsrels, -1, "chartsheets/sheet" + rId + "." + wbext, RELS.CS);
break; */
/* falls through */
default:
f = "xl/worksheets/sheet" + rId + "." + wbext;
zip.file(f, write_ws(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_ws(rId-1, f, opts, wb, wsrels));
ct.sheets.push(f);
add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
}
@ -78,57 +78,57 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
zip_add_file(zip, cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip_add_file(zip, "xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];
}
if(wsrels['!id'].rId1) zip.file(get_rels_path(f), write_rels(wsrels));
if(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));
}
if(opts.Strings != null && opts.Strings.length > 0) {
f = "xl/sharedStrings." + wbext;
zip.file(f, write_sst(opts.Strings, f, opts));
zip_add_file(zip, f, write_sst(opts.Strings, f, opts));
ct.strs.push(f);
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
}
f = "xl/workbook." + wbext;
zip.file(f, write_wb(wb, f, opts));
zip_add_file(zip, f, write_wb(wb, f, opts));
ct.workbooks.push(f);
add_rels(opts.rels, 1, f, RELS.WB);
/* TODO: something more intelligent with themes */
f = "xl/theme/theme1.xml";
zip.file(f, write_theme(wb.Themes, opts));
zip_add_file(zip, f, write_theme(wb.Themes, opts));
ct.themes.push(f);
add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
/* TODO: something more intelligent with styles */
f = "xl/styles." + wbext;
zip.file(f, write_sty(wb, f, opts));
zip_add_file(zip, f, write_sty(wb, f, opts));
ct.styles.push(f);
add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
if(wb.vbaraw && vbafmt) {
f = "xl/vbaProject.bin";
zip.file(f, wb.vbaraw);
zip_add_file(zip, f, wb.vbaraw);
ct.vba.push(f);
add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
}
zip.file("[Content_Types].xml", write_ct(ct, opts));
zip.file('_rels/.rels', write_rels(opts.rels));
zip.file('xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
zip_add_file(zip, "[Content_Types].xml", write_ct(ct, opts));
zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));
zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
delete opts.revssf; delete opts.ssf;
return zip;

@ -20,12 +20,7 @@ function read_zip(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
var zip, d = data;
var o = opts||{};
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
zip = zip_read(d, o);
return parse_zip(zip, o);
}

@ -25,7 +25,7 @@ function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: {"nodebuffer": "buffer", "string": "binary"}[oopts.type] || oopts.type}) : z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;

@ -254,9 +254,6 @@ var utils/*:any*/ = {
sheet_to_txt: sheet_to_txt,
sheet_to_json: sheet_to_json,
sheet_to_html: HTML_.from_sheet,
sheet_to_dif: DIF.from_sheet,
sheet_to_slk: SYLK.from_sheet,
sheet_to_eth: ETH.from_sheet,
sheet_to_formulae: sheet_to_formulae,
sheet_to_row_object_array: sheet_to_json
};

@ -1,7 +1,4 @@
XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_ods = parse_ods;
XLSX.parse_fods = parse_fods;
XLSX.write_ods = write_ods;
if(typeof parse_xlscfb !== "undefined") XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_zip = parse_zip;
XLSX.read = readSync; //xlsread
XLSX.readFile = readFileSync; //readFile
@ -12,4 +9,4 @@ XLSX.writeFileSync = writeFileSync;
XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
if(typeof CFB !== "undefined") XLSX.CFB = CFB;

32
dist/xlsx.core.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.core.min.map generated vendored

File diff suppressed because one or more lines are too long

116
dist/xlsx.extendscript.js generated vendored

@ -9160,7 +9160,7 @@ module.exports = ZStream;
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.5';
XLSX.version = '0.15.0';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -9325,8 +9325,8 @@ function s2ab(s) {
}
function a2s(data) {
if(Array.isArray(data)) return data.map(_chr).join("");
var o = []; for(var i = 0; i < data.length; ++i) o[i] = _chr(data[i]); return o.join("");
if(Array.isArray(data)) return data.map(function(c) { return String.fromCharCode(c); }).join("");
var o = []; for(var i = 0; i < data.length; ++i) o[i] = String.fromCharCode(data[i]); return o.join("");
}
function a2u(data) {
@ -10406,7 +10406,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.1.2';
exports.version = '1.1.3';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -11549,7 +11549,7 @@ function parse_local_file(blob, csz, usz, o, EF) {
if(_csz != csz) warn_or_throw(wrn, "Bad compressed size: " + csz + " != " + _csz);
if(_usz != usz) warn_or_throw(wrn, "Bad uncompressed size: " + usz + " != " + _usz);
var _crc32 = CRC32.buf(data, 0);
if(crc32 != _crc32) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
if((crc32>>0) != (_crc32>>0)) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
cfb_add(o, name, data, {unsafe: true, mt: date});
}
function write_zip(cfb, options) {
@ -11939,6 +11939,7 @@ function getdatastr(data) {
if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));
if(data.asBinary) return debom(data.asBinary());
if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
if(data.content && data.type) return debom(cc2str(data.content));
return null;
}
@ -11951,6 +11952,7 @@ function getdatabin(data) {
if(typeof o == "string") return char_codes(o);
return Array.prototype.slice.call(o);
}
if(data.content && data.type) return data.content;
return null;
}
@ -11959,7 +11961,7 @@ function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getda
/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */
/* OASIS does not comment on filename case sensitivity */
function safegetzipfile(zip, file) {
var k = keys(zip.files);
var k = zip.FullPaths || keys(zip.files);
var f = file.toLowerCase(), g = f.replace(/\//g,'\\');
for(var i=0; i<k.length; ++i) {
var n = k[i].toLowerCase();
@ -11987,11 +11989,27 @@ function getzipstr(zip, file, safe) {
}
function zipentries(zip) {
var k = keys(zip.files), o = [];
var k = zip.FullPaths || keys(zip.files), o = [];
for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]);
return o.sort();
}
function zip_add_file(zip, path, content) {
if(zip.FullPaths) CFB.utils.cfb_add(zip, path, content);
else zip.file(path, content);
}
function zip_read(d, o) {
var zip;
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
return zip;
}
var jszip;
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
@ -12001,6 +12019,10 @@ if(typeof exports !== 'undefined') {
}
}
function zip_new() {
return new jszip();
}
function resolve_path(path, base) {
var result = base.split('/');
if(base.slice(-1) != "/") result.pop(); // folder path
@ -24347,7 +24369,6 @@ function write_cc(data, name:string, opts) {
*/
var attregexg2=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;
var attregex2=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;
var _chr = function(c) { return String.fromCharCode(c); };
function xlml_parsexmltag(tag, skip_root) {
var words = tag.split(/\s+/);
var z = ([]); if(!skip_root) z[0] = words[0];
@ -28992,7 +29013,7 @@ var write_content_ods = (function() {
function write_ods(wb, opts) {
if(opts.bookType == "fods") return write_content_ods(wb, opts);
var zip = new jszip();
var zip = zip_new();
var f = "";
var manifest = [];
@ -29000,34 +29021,34 @@ var zip = new jszip();
/* Part 3 Section 3.3 MIME Media Type */
f = "mimetype";
zip.file(f, "application/vnd.oasis.opendocument.spreadsheet");
zip_add_file(zip, f, "application/vnd.oasis.opendocument.spreadsheet");
/* Part 1 Section 2.2 Documents */
f = "content.xml";
zip.file(f, write_content_ods(wb, opts));
zip_add_file(zip, f, write_content_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "ContentFile"]);
/* TODO: these are hard-coded styles to satiate excel */
f = "styles.xml";
zip.file(f, write_styles_ods(wb, opts));
zip_add_file(zip, f, write_styles_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "StylesFile"]);
/* TODO: this is hard-coded to satiate excel */
f = "meta.xml";
zip.file(f, write_meta_ods());
zip_add_file(zip, f, write_meta_ods());
manifest.push([f, "text/xml"]);
rdf.push([f, "MetadataFile"]);
/* Part 3 Section 6 Metadata Manifest File */
f = "manifest.rdf";
zip.file(f, write_rdf(rdf/*, opts*/));
zip_add_file(zip, f, write_rdf(rdf/*, opts*/));
manifest.push([f, "application/rdf+xml"]);
/* Part 3 Section 4 Manifest File */
f = "META-INF/manifest.xml";
zip.file(f, write_manifest(manifest/*, opts*/));
zip_add_file(zip, f, write_manifest(manifest/*, opts*/));
return zip;
}
@ -29048,13 +29069,13 @@ function write_obj_str(factory) {
var write_htm_str = write_obj_str(HTML_);
var write_csv_str = write_obj_str({from_sheet:sheet_to_csv});
var write_slk_str = write_obj_str(SYLK);
var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_slk_str = write_obj_str(typeof SYLK !== "undefined" ? SYLK : {});
var write_dif_str = write_obj_str(typeof DIF !== "undefined" ? DIF : {});
var write_prn_str = write_obj_str(typeof PRN !== "undefined" ? PRN : {});
var write_rtf_str = write_obj_str(typeof RTF !== "undefined" ? RTF : {});
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
var write_dbf_buf = write_obj_str(typeof DBF !== "undefined" ? DBF : {});
var write_eth_str = write_obj_str(typeof ETH !== "undefined" ? ETH : {});
function fix_opts_func(defaults) {
return function fix_opts(opts) {
@ -29343,7 +29364,7 @@ function write_zip(wb, opts) {
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
var ct = new_ct();
fix_write_opts(opts = opts || {});
var zip = new jszip();
var zip = zip_new();
var f = "", rId = 0;
opts.cellXfs = [];
@ -29352,7 +29373,7 @@ var zip = new jszip();
if(!wb.Props) wb.Props = {};
f = "docProps/core.xml";
zip.file(f, write_core_props(wb.Props, opts));
zip_add_file(zip, f, write_core_props(wb.Props, opts));
ct.coreprops.push(f);
add_rels(opts.rels, 2, f, RELS.CORE_PROPS);
@ -29366,13 +29387,13 @@ f = "docProps/app.xml";
wb.Props.SheetNames = _sn;
}
wb.Props.Worksheets = wb.Props.SheetNames.length;
zip.file(f, write_ext_props(wb.Props, opts));
zip_add_file(zip, f, write_ext_props(wb.Props, opts));
ct.extprops.push(f);
add_rels(opts.rels, 3, f, RELS.EXT_PROPS);
if(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {
f = "docProps/custom.xml";
zip.file(f, write_cust_props(wb.Custprops, opts));
zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));
ct.custprops.push(f);
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
}
@ -29384,14 +29405,14 @@ f = "docProps/app.xml";
switch(_type) {
case "chart": /*
f = "xl/chartsheets/sheet" + rId + "." + wbext;
zip.file(f, write_cs(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_cs(rId-1, f, opts, wb, wsrels));
ct.charts.push(f);
add_rels(wsrels, -1, "chartsheets/sheet" + rId + "." + wbext, RELS.CS);
break; */
/* falls through */
default:
f = "xl/worksheets/sheet" + rId + "." + wbext;
zip.file(f, write_ws(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_ws(rId-1, f, opts, wb, wsrels));
ct.sheets.push(f);
add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
}
@ -29401,57 +29422,57 @@ f = "docProps/app.xml";
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
zip_add_file(zip, cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip_add_file(zip, "xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];
}
if(wsrels['!id'].rId1) zip.file(get_rels_path(f), write_rels(wsrels));
if(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));
}
if(opts.Strings != null && opts.Strings.length > 0) {
f = "xl/sharedStrings." + wbext;
zip.file(f, write_sst(opts.Strings, f, opts));
zip_add_file(zip, f, write_sst(opts.Strings, f, opts));
ct.strs.push(f);
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
}
f = "xl/workbook." + wbext;
zip.file(f, write_wb(wb, f, opts));
zip_add_file(zip, f, write_wb(wb, f, opts));
ct.workbooks.push(f);
add_rels(opts.rels, 1, f, RELS.WB);
/* TODO: something more intelligent with themes */
f = "xl/theme/theme1.xml";
zip.file(f, write_theme(wb.Themes, opts));
zip_add_file(zip, f, write_theme(wb.Themes, opts));
ct.themes.push(f);
add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
/* TODO: something more intelligent with styles */
f = "xl/styles." + wbext;
zip.file(f, write_sty(wb, f, opts));
zip_add_file(zip, f, write_sty(wb, f, opts));
ct.styles.push(f);
add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
if(wb.vbaraw && vbafmt) {
f = "xl/vbaProject.bin";
zip.file(f, wb.vbaraw);
zip_add_file(zip, f, wb.vbaraw);
ct.vba.push(f);
add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
}
zip.file("[Content_Types].xml", write_ct(ct, opts));
zip.file('_rels/.rels', write_rels(opts.rels));
zip.file('xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
zip_add_file(zip, "[Content_Types].xml", write_ct(ct, opts));
zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));
zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
delete opts.revssf; delete opts.ssf;
return zip;
@ -29477,12 +29498,7 @@ function read_zip(data, opts) {
var zip, d = data;
var o = opts||{};
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
zip = zip_read(d, o);
return parse_zip(zip, o);
}
@ -29590,7 +29606,7 @@ function write_zip_type(wb, opts) {
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: {"nodebuffer": "buffer", "string": "binary"}[oopts.type] || oopts.type}) : z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
@ -29964,9 +29980,6 @@ var utils = {
sheet_to_txt: sheet_to_txt,
sheet_to_json: sheet_to_json,
sheet_to_html: HTML_.from_sheet,
sheet_to_dif: DIF.from_sheet,
sheet_to_slk: SYLK.from_sheet,
sheet_to_eth: ETH.from_sheet,
sheet_to_formulae: sheet_to_formulae,
sheet_to_row_object_array: sheet_to_json
};
@ -30200,10 +30213,7 @@ if(has_buf && typeof require != 'undefined') (function() {
};
})();
XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_ods = parse_ods;
XLSX.parse_fods = parse_fods;
XLSX.write_ods = write_ods;
if(typeof parse_xlscfb !== "undefined") XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_zip = parse_zip;
XLSX.read = readSync; //xlsread
XLSX.readFile = readFileSync; //readFile
@ -30214,7 +30224,7 @@ XLSX.writeFileSync = writeFileSync;
XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
if(typeof CFB !== "undefined") XLSX.CFB = CFB;
}
/*global define */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);

32
dist/xlsx.full.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.full.min.map generated vendored

File diff suppressed because one or more lines are too long

116
dist/xlsx.js generated vendored

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.5';
XLSX.version = '0.15.0';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -169,8 +169,8 @@ function s2ab(s) {
}
function a2s(data) {
if(Array.isArray(data)) return data.map(_chr).join("");
var o = []; for(var i = 0; i < data.length; ++i) o[i] = _chr(data[i]); return o.join("");
if(Array.isArray(data)) return data.map(function(c) { return String.fromCharCode(c); }).join("");
var o = []; for(var i = 0; i < data.length; ++i) o[i] = String.fromCharCode(data[i]); return o.join("");
}
function a2u(data) {
@ -1250,7 +1250,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.1.2';
exports.version = '1.1.3';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -2393,7 +2393,7 @@ function parse_local_file(blob, csz, usz, o, EF) {
if(_csz != csz) warn_or_throw(wrn, "Bad compressed size: " + csz + " != " + _csz);
if(_usz != usz) warn_or_throw(wrn, "Bad uncompressed size: " + usz + " != " + _usz);
var _crc32 = CRC32.buf(data, 0);
if(crc32 != _crc32) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
if((crc32>>0) != (_crc32>>0)) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
cfb_add(o, name, data, {unsafe: true, mt: date});
}
function write_zip(cfb, options) {
@ -2783,6 +2783,7 @@ function getdatastr(data) {
if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));
if(data.asBinary) return debom(data.asBinary());
if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
if(data.content && data.type) return debom(cc2str(data.content));
return null;
}
@ -2795,6 +2796,7 @@ function getdatabin(data) {
if(typeof o == "string") return char_codes(o);
return Array.prototype.slice.call(o);
}
if(data.content && data.type) return data.content;
return null;
}
@ -2803,7 +2805,7 @@ function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getda
/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */
/* OASIS does not comment on filename case sensitivity */
function safegetzipfile(zip, file) {
var k = keys(zip.files);
var k = zip.FullPaths || keys(zip.files);
var f = file.toLowerCase(), g = f.replace(/\//g,'\\');
for(var i=0; i<k.length; ++i) {
var n = k[i].toLowerCase();
@ -2831,11 +2833,27 @@ function getzipstr(zip, file, safe) {
}
function zipentries(zip) {
var k = keys(zip.files), o = [];
var k = zip.FullPaths || keys(zip.files), o = [];
for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]);
return o.sort();
}
function zip_add_file(zip, path, content) {
if(zip.FullPaths) CFB.utils.cfb_add(zip, path, content);
else zip.file(path, content);
}
function zip_read(d, o) {
var zip;
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
return zip;
}
var jszip;
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
@ -2845,6 +2863,10 @@ if(typeof exports !== 'undefined') {
}
}
function zip_new() {
return new jszip();
}
function resolve_path(path, base) {
var result = base.split('/');
if(base.slice(-1) != "/") result.pop(); // folder path
@ -15191,7 +15213,6 @@ function write_cc(data, name:string, opts) {
*/
var attregexg2=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;
var attregex2=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;
var _chr = function(c) { return String.fromCharCode(c); };
function xlml_parsexmltag(tag, skip_root) {
var words = tag.split(/\s+/);
var z = ([]); if(!skip_root) z[0] = words[0];
@ -19836,7 +19857,7 @@ var write_content_ods = (function() {
function write_ods(wb, opts) {
if(opts.bookType == "fods") return write_content_ods(wb, opts);
var zip = new jszip();
var zip = zip_new();
var f = "";
var manifest = [];
@ -19844,34 +19865,34 @@ var zip = new jszip();
/* Part 3 Section 3.3 MIME Media Type */
f = "mimetype";
zip.file(f, "application/vnd.oasis.opendocument.spreadsheet");
zip_add_file(zip, f, "application/vnd.oasis.opendocument.spreadsheet");
/* Part 1 Section 2.2 Documents */
f = "content.xml";
zip.file(f, write_content_ods(wb, opts));
zip_add_file(zip, f, write_content_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "ContentFile"]);
/* TODO: these are hard-coded styles to satiate excel */
f = "styles.xml";
zip.file(f, write_styles_ods(wb, opts));
zip_add_file(zip, f, write_styles_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "StylesFile"]);
/* TODO: this is hard-coded to satiate excel */
f = "meta.xml";
zip.file(f, write_meta_ods());
zip_add_file(zip, f, write_meta_ods());
manifest.push([f, "text/xml"]);
rdf.push([f, "MetadataFile"]);
/* Part 3 Section 6 Metadata Manifest File */
f = "manifest.rdf";
zip.file(f, write_rdf(rdf/*, opts*/));
zip_add_file(zip, f, write_rdf(rdf/*, opts*/));
manifest.push([f, "application/rdf+xml"]);
/* Part 3 Section 4 Manifest File */
f = "META-INF/manifest.xml";
zip.file(f, write_manifest(manifest/*, opts*/));
zip_add_file(zip, f, write_manifest(manifest/*, opts*/));
return zip;
}
@ -19892,13 +19913,13 @@ function write_obj_str(factory) {
var write_htm_str = write_obj_str(HTML_);
var write_csv_str = write_obj_str({from_sheet:sheet_to_csv});
var write_slk_str = write_obj_str(SYLK);
var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_slk_str = write_obj_str(typeof SYLK !== "undefined" ? SYLK : {});
var write_dif_str = write_obj_str(typeof DIF !== "undefined" ? DIF : {});
var write_prn_str = write_obj_str(typeof PRN !== "undefined" ? PRN : {});
var write_rtf_str = write_obj_str(typeof RTF !== "undefined" ? RTF : {});
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
var write_dbf_buf = write_obj_str(typeof DBF !== "undefined" ? DBF : {});
var write_eth_str = write_obj_str(typeof ETH !== "undefined" ? ETH : {});
function fix_opts_func(defaults) {
return function fix_opts(opts) {
@ -20187,7 +20208,7 @@ function write_zip(wb, opts) {
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
var ct = new_ct();
fix_write_opts(opts = opts || {});
var zip = new jszip();
var zip = zip_new();
var f = "", rId = 0;
opts.cellXfs = [];
@ -20196,7 +20217,7 @@ var zip = new jszip();
if(!wb.Props) wb.Props = {};
f = "docProps/core.xml";
zip.file(f, write_core_props(wb.Props, opts));
zip_add_file(zip, f, write_core_props(wb.Props, opts));
ct.coreprops.push(f);
add_rels(opts.rels, 2, f, RELS.CORE_PROPS);
@ -20210,13 +20231,13 @@ f = "docProps/app.xml";
wb.Props.SheetNames = _sn;
}
wb.Props.Worksheets = wb.Props.SheetNames.length;
zip.file(f, write_ext_props(wb.Props, opts));
zip_add_file(zip, f, write_ext_props(wb.Props, opts));
ct.extprops.push(f);
add_rels(opts.rels, 3, f, RELS.EXT_PROPS);
if(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {
f = "docProps/custom.xml";
zip.file(f, write_cust_props(wb.Custprops, opts));
zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));
ct.custprops.push(f);
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
}
@ -20228,14 +20249,14 @@ f = "docProps/app.xml";
switch(_type) {
case "chart": /*
f = "xl/chartsheets/sheet" + rId + "." + wbext;
zip.file(f, write_cs(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_cs(rId-1, f, opts, wb, wsrels));
ct.charts.push(f);
add_rels(wsrels, -1, "chartsheets/sheet" + rId + "." + wbext, RELS.CS);
break; */
/* falls through */
default:
f = "xl/worksheets/sheet" + rId + "." + wbext;
zip.file(f, write_ws(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_ws(rId-1, f, opts, wb, wsrels));
ct.sheets.push(f);
add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
}
@ -20245,57 +20266,57 @@ f = "docProps/app.xml";
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
zip_add_file(zip, cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip_add_file(zip, "xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];
}
if(wsrels['!id'].rId1) zip.file(get_rels_path(f), write_rels(wsrels));
if(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));
}
if(opts.Strings != null && opts.Strings.length > 0) {
f = "xl/sharedStrings." + wbext;
zip.file(f, write_sst(opts.Strings, f, opts));
zip_add_file(zip, f, write_sst(opts.Strings, f, opts));
ct.strs.push(f);
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
}
f = "xl/workbook." + wbext;
zip.file(f, write_wb(wb, f, opts));
zip_add_file(zip, f, write_wb(wb, f, opts));
ct.workbooks.push(f);
add_rels(opts.rels, 1, f, RELS.WB);
/* TODO: something more intelligent with themes */
f = "xl/theme/theme1.xml";
zip.file(f, write_theme(wb.Themes, opts));
zip_add_file(zip, f, write_theme(wb.Themes, opts));
ct.themes.push(f);
add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
/* TODO: something more intelligent with styles */
f = "xl/styles." + wbext;
zip.file(f, write_sty(wb, f, opts));
zip_add_file(zip, f, write_sty(wb, f, opts));
ct.styles.push(f);
add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
if(wb.vbaraw && vbafmt) {
f = "xl/vbaProject.bin";
zip.file(f, wb.vbaraw);
zip_add_file(zip, f, wb.vbaraw);
ct.vba.push(f);
add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
}
zip.file("[Content_Types].xml", write_ct(ct, opts));
zip.file('_rels/.rels', write_rels(opts.rels));
zip.file('xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
zip_add_file(zip, "[Content_Types].xml", write_ct(ct, opts));
zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));
zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
delete opts.revssf; delete opts.ssf;
return zip;
@ -20321,12 +20342,7 @@ function read_zip(data, opts) {
var zip, d = data;
var o = opts||{};
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
zip = zip_read(d, o);
return parse_zip(zip, o);
}
@ -20434,7 +20450,7 @@ function write_zip_type(wb, opts) {
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: {"nodebuffer": "buffer", "string": "binary"}[oopts.type] || oopts.type}) : z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
@ -20808,9 +20824,6 @@ var utils = {
sheet_to_txt: sheet_to_txt,
sheet_to_json: sheet_to_json,
sheet_to_html: HTML_.from_sheet,
sheet_to_dif: DIF.from_sheet,
sheet_to_slk: SYLK.from_sheet,
sheet_to_eth: ETH.from_sheet,
sheet_to_formulae: sheet_to_formulae,
sheet_to_row_object_array: sheet_to_json
};
@ -21044,10 +21057,7 @@ if(has_buf && typeof require != 'undefined') (function() {
};
})();
XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_ods = parse_ods;
XLSX.parse_fods = parse_fods;
XLSX.write_ods = write_ods;
if(typeof parse_xlscfb !== "undefined") XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_zip = parse_zip;
XLSX.read = readSync; //xlsread
XLSX.readFile = readFileSync; //readFile
@ -21058,7 +21068,7 @@ XLSX.writeFileSync = writeFileSync;
XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
if(typeof CFB !== "undefined") XLSX.CFB = CFB;
}
/*global define */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);

26
dist/xlsx.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.min.map generated vendored

File diff suppressed because one or more lines are too long

7
dist/xlsx.mini.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/xlsx.mini.min.map generated vendored Normal file

File diff suppressed because one or more lines are too long

@ -17,6 +17,8 @@ An appropriate version for each dependency is included in the dist/ directory.
The complete single-file version is generated at `dist/xlsx.full.min.js`
A slimmer build with XLSX / HTML support is generated at `dist/xlsx.mini.min.js`
Webpack and Browserify builds include optional modules by default. Webpack can
be configured to remove support with `resolve.alias`:

54
mini.lst Normal file

@ -0,0 +1,54 @@
bits/00_header.js
bits/01_version.js
bits/02_codepage.js
bits/03_consts.js
bits/04_base64.js
bits/05_buf.js
bits/09_types.js
bits/10_ssf.js
bits/11_ssfutils.js
bits/18_cfb.js
bits/19_fsutils.js
bits/20_jsutils.js
misc/21_ziputils.js
bits/22_xmlutils.js
bits/23_binutils.js
bits/24_hoppers.js
bits/25_cellutils.js
bits/27_csfutils.js
bits/29_xlsenum.js
bits/30_ctype.js
bits/31_rels.js
bits/33_coreprops.js
bits/34_extprops.js
bits/35_custprops.js
bits/42_sstxml.js
bits/46_stycommon.js
bits/47_styxml.js
bits/49_theme.js
bits/53_externlink.js
bits/54_drawing.js
bits/55_vml.js
bits/56_cmntcommon.js
bits/57_cmntxml.js
bits/59_vba.js
bits/60_macrovba.js
bits/61_fcommon.js
bits/66_wscommon.js
bits/67_wsxml.js
bits/69_chartxml.js
bits/70_csheet.js
bits/71_wbcommon.js
bits/72_wbxml.js
bits/74_xmlbin.js
bits/79_html.js
bits/82_sheeter.js
bits/84_defaults.js
bits/85_parsezip.js
bits/86_writezip.js
bits/87_read.js
bits/88_write.js
bits/90_utils.js
bits/95_api.js
bits/98_exports.js
bits/99_footer.js

93
misc/21_ziputils.js Normal file

@ -0,0 +1,93 @@
function getdatastr(data)/*:?string*/ {
if(!data) return null;
if(data.data) return debom(data.data);
if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));
if(data.asBinary) return debom(data.asBinary());
if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
if(data.content && data.type) return debom(cc2str(data.content));
return null;
}
function getdatabin(data) {
if(!data) return null;
if(data.data) return char_codes(data.data);
if(data.asNodeBuffer && has_buf) return data.asNodeBuffer();
if(data._data && data._data.getContent) {
var o = data._data.getContent();
if(typeof o == "string") return char_codes(o);
return Array.prototype.slice.call(o);
}
if(data.content && data.type) return data.content;
return null;
}
function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getdatabin(data) : getdatastr(data); }
/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */
/* OASIS does not comment on filename case sensitivity */
function safegetzipfile(zip, file/*:string*/) {
var k = zip.FullPaths || keys(zip.files);
var f = file.toLowerCase(), g = f.replace(/\\/g,'\/');
for(var i=0; i<k.length; ++i) {
var n = k[i].replace(/^Root Entry[\/]/,"").toLowerCase();
if(f == n || g == n) return zip.FileIndex[i];
}
return null;
}
function getzipfile(zip, file/*:string*/) {
var o = safegetzipfile(zip, file);
if(o == null) throw new Error("Cannot find file " + file + " in zip");
return o;
}
function getzipdata(zip, file/*:string*/, safe/*:?boolean*/)/*:any*/ {
if(!safe) return getdata(getzipfile(zip, file));
if(!file) return null;
try { return getzipdata(zip, file); } catch(e) { return null; }
}
function getzipstr(zip, file/*:string*/, safe/*:?boolean*/)/*:?string*/ {
if(!safe) return getdatastr(getzipfile(zip, file));
if(!file) return null;
try { return getzipstr(zip, file); } catch(e) { return null; }
}
function zipentries(zip) {
var k = zip.FullPaths || keys(zip.files), o = [];
for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i].replace(/^Root Entry[\/]/, ""));
return o.sort();
}
function zip_add_file(zip, path, content) {
if(zip.FullPaths) CFB.utils.cfb_add(zip, path, typeof content == "string" ? (has_buf ? Buffer_from(content) : s2a(utf8write(content))) : content);
else zip.file(path, content);
}
function zip_read(d, o) {
var zip;
switch(o.type) {
case "base64": zip = CFB.read(d, { type: "base64" }); break;
case "binary": zip = CFB.read(d, { type: "binary" }); break;
case "buffer": case "array": zip = CFB.read(d, { type: "buffer" }); break;
default: throw new Error("Unrecognized type " + o.type);
}
return zip;
}
function zip_new() {
return CFB.utils.cfb_new();
}
function resolve_path(path/*:string*/, base/*:string*/)/*:string*/ {
var result = base.split('/');
if(base.slice(-1) != "/") result.pop(); // folder path
var target = path.split('/');
while (target.length !== 0) {
var step = target.shift();
if (step === '..') result.pop();
else if (step !== '.') result.push(step);
}
return result.join('/');
}

@ -227,6 +227,8 @@ An appropriate version for each dependency is included in the dist/ directory.
The complete single-file version is generated at `dist/xlsx.full.min.js`
A slimmer build with XLSX / HTML support is generated at `dist/xlsx.mini.min.js`
Webpack and Browserify builds include optional modules by default. Webpack can
be configured to remove support with `resolve.alias`:

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.14.5",
"version": "0.15.0",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [
@ -31,7 +31,7 @@
},
"dependencies": {
"adler-32": "~1.2.0",
"cfb": "^1.1.2",
"cfb": "^1.1.3",
"codepage": "~1.14.0",
"commander": "~2.17.1",
"crc-32": "~1.2.0",

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.5';
XLSX.version = '0.15.0';
var current_codepage = 1200, current_ansi = 1252;
/*:: declare var cptable:any; */
/*global cptable:true, window */
@ -170,8 +170,8 @@ function s2ab(s/*:string*/)/*:any*/ {
}
function a2s(data/*:any*/)/*:string*/ {
if(Array.isArray(data)) return data.map(_chr).join("");
var o/*:Array<string>*/ = []; for(var i = 0; i < data.length; ++i) o[i] = _chr(data[i]); return o.join("");
if(Array.isArray(data)) return data.map(function(c) { return String.fromCharCode(c); }).join("");
var o/*:Array<string>*/ = []; for(var i = 0; i < data.length; ++i) o[i] = String.fromCharCode(data[i]); return o.join("");
}
function a2u(data/*:Array<number>*/)/*:Uint8Array*/ {
@ -1317,7 +1317,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
exports.version = '1.1.2';
exports.version = '1.1.3';
/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
@ -2466,7 +2466,7 @@ function parse_local_file(blob/*:CFBlob*/, csz/*:number*/, usz/*:number*/, o/*:C
if(_csz != csz) warn_or_throw(wrn, "Bad compressed size: " + csz + " != " + _csz);
if(_usz != usz) warn_or_throw(wrn, "Bad uncompressed size: " + usz + " != " + _usz);
var _crc32 = CRC32.buf(data, 0);
if(crc32 != _crc32) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
if((crc32>>0) != (_crc32>>0)) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
cfb_add(o, name, data, {unsafe: true, mt: date});
}
function write_zip(cfb/*:CFBContainer*/, options/*:CFBWriteOpts*/)/*:RawBytes*/ {
@ -2863,6 +2863,7 @@ function getdatastr(data)/*:?string*/ {
if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));
if(data.asBinary) return debom(data.asBinary());
if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
if(data.content && data.type) return debom(cc2str(data.content));
return null;
}
@ -2875,6 +2876,7 @@ function getdatabin(data) {
if(typeof o == "string") return char_codes(o);
return Array.prototype.slice.call(o);
}
if(data.content && data.type) return data.content;
return null;
}
@ -2883,7 +2885,7 @@ function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getda
/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */
/* OASIS does not comment on filename case sensitivity */
function safegetzipfile(zip, file/*:string*/) {
var k = keys(zip.files);
var k = zip.FullPaths || keys(zip.files);
var f = file.toLowerCase(), g = f.replace(/\//g,'\\');
for(var i=0; i<k.length; ++i) {
var n = k[i].toLowerCase();
@ -2911,11 +2913,27 @@ function getzipstr(zip, file/*:string*/, safe/*:?boolean*/)/*:?string*/ {
}
function zipentries(zip) {
var k = keys(zip.files), o = [];
var k = zip.FullPaths || keys(zip.files), o = [];
for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]);
return o.sort();
}
function zip_add_file(zip, path, content) {
if(zip.FullPaths) CFB.utils.cfb_add(zip, path, content);
else zip.file(path, content);
}
function zip_read(d, o) {
var zip;
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
return zip;
}
var jszip;
/*:: declare var JSZipSync:any; */
/*global JSZipSync:true */
@ -2926,6 +2944,10 @@ if(typeof exports !== 'undefined') {
}
}
function zip_new() {
return new jszip();
}
function resolve_path(path/*:string*/, base/*:string*/)/*:string*/ {
var result = base.split('/');
if(base.slice(-1) != "/") result.pop(); // folder path
@ -15295,7 +15317,6 @@ function write_cc(data, name:string, opts) {
*/
var attregexg2=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;
var attregex2=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;
var _chr = function(c) { return String.fromCharCode(c); };
function xlml_parsexmltag(tag/*:string*/, skip_root/*:?boolean*/) {
var words = tag.split(/\s+/);
var z/*:any*/ = ([]/*:any*/); if(!skip_root) z[0] = words[0];
@ -19953,7 +19974,7 @@ function write_ods(wb/*:any*/, opts/*:any*/) {
if(opts.bookType == "fods") return write_content_ods(wb, opts);
/*:: if(!jszip) throw new Error("JSZip is not available"); */
var zip = new jszip();
var zip = zip_new();
var f = "";
var manifest/*:Array<Array<string> >*/ = [];
@ -19961,34 +19982,34 @@ function write_ods(wb/*:any*/, opts/*:any*/) {
/* Part 3 Section 3.3 MIME Media Type */
f = "mimetype";
zip.file(f, "application/vnd.oasis.opendocument.spreadsheet");
zip_add_file(zip, f, "application/vnd.oasis.opendocument.spreadsheet");
/* Part 1 Section 2.2 Documents */
f = "content.xml";
zip.file(f, write_content_ods(wb, opts));
zip_add_file(zip, f, write_content_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "ContentFile"]);
/* TODO: these are hard-coded styles to satiate excel */
f = "styles.xml";
zip.file(f, write_styles_ods(wb, opts));
zip_add_file(zip, f, write_styles_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "StylesFile"]);
/* TODO: this is hard-coded to satiate excel */
f = "meta.xml";
zip.file(f, write_meta_ods(/*::wb, opts*/));
zip_add_file(zip, f, write_meta_ods(/*::wb, opts*/));
manifest.push([f, "text/xml"]);
rdf.push([f, "MetadataFile"]);
/* Part 3 Section 6 Metadata Manifest File */
f = "manifest.rdf";
zip.file(f, write_rdf(rdf/*, opts*/));
zip_add_file(zip, f, write_rdf(rdf/*, opts*/));
manifest.push([f, "application/rdf+xml"]);
/* Part 3 Section 4 Manifest File */
f = "META-INF/manifest.xml";
zip.file(f, write_manifest(manifest/*, opts*/));
zip_add_file(zip, f, write_manifest(manifest/*, opts*/));
return zip;
}
@ -20009,13 +20030,13 @@ function write_obj_str(factory/*:WriteObjStrFactory*/) {
var write_htm_str = write_obj_str(HTML_);
var write_csv_str = write_obj_str({from_sheet:sheet_to_csv});
var write_slk_str = write_obj_str(SYLK);
var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_slk_str = write_obj_str(typeof SYLK !== "undefined" ? SYLK : {});
var write_dif_str = write_obj_str(typeof DIF !== "undefined" ? DIF : {});
var write_prn_str = write_obj_str(typeof PRN !== "undefined" ? PRN : {});
var write_rtf_str = write_obj_str(typeof RTF !== "undefined" ? RTF : {});
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
var write_dbf_buf = write_obj_str(typeof DBF !== "undefined" ? DBF : {});
var write_eth_str = write_obj_str(typeof ETH !== "undefined" ? ETH : {});
function fix_opts_func(defaults/*:Array<Array<any> >*/)/*:{(o:any):void}*/ {
return function fix_opts(opts) {
@ -20307,7 +20328,7 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
var ct = new_ct();
fix_write_opts(opts = opts || {});
/*:: if(!jszip) throw new Error("JSZip is not available"); */
var zip = new jszip();
var zip = zip_new();
var f = "", rId = 0;
opts.cellXfs = [];
@ -20316,7 +20337,7 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
if(!wb.Props) wb.Props = {};
f = "docProps/core.xml";
zip.file(f, write_core_props(wb.Props, opts));
zip_add_file(zip, f, write_core_props(wb.Props, opts));
ct.coreprops.push(f);
add_rels(opts.rels, 2, f, RELS.CORE_PROPS);
@ -20331,13 +20352,13 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
wb.Props.SheetNames = _sn;
}
wb.Props.Worksheets = wb.Props.SheetNames.length;
zip.file(f, write_ext_props(wb.Props, opts));
zip_add_file(zip, f, write_ext_props(wb.Props, opts));
ct.extprops.push(f);
add_rels(opts.rels, 3, f, RELS.EXT_PROPS);
if(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {
f = "docProps/custom.xml";
zip.file(f, write_cust_props(wb.Custprops, opts));
zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));
ct.custprops.push(f);
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
}
@ -20349,14 +20370,14 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
switch(_type) {
case "chart": /*
f = "xl/chartsheets/sheet" + rId + "." + wbext;
zip.file(f, write_cs(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_cs(rId-1, f, opts, wb, wsrels));
ct.charts.push(f);
add_rels(wsrels, -1, "chartsheets/sheet" + rId + "." + wbext, RELS.CS);
break; */
/* falls through */
default:
f = "xl/worksheets/sheet" + rId + "." + wbext;
zip.file(f, write_ws(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_ws(rId-1, f, opts, wb, wsrels));
ct.sheets.push(f);
add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
}
@ -20366,57 +20387,57 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
zip_add_file(zip, cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip_add_file(zip, "xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];
}
if(wsrels['!id'].rId1) zip.file(get_rels_path(f), write_rels(wsrels));
if(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));
}
if(opts.Strings != null && opts.Strings.length > 0) {
f = "xl/sharedStrings." + wbext;
zip.file(f, write_sst(opts.Strings, f, opts));
zip_add_file(zip, f, write_sst(opts.Strings, f, opts));
ct.strs.push(f);
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
}
f = "xl/workbook." + wbext;
zip.file(f, write_wb(wb, f, opts));
zip_add_file(zip, f, write_wb(wb, f, opts));
ct.workbooks.push(f);
add_rels(opts.rels, 1, f, RELS.WB);
/* TODO: something more intelligent with themes */
f = "xl/theme/theme1.xml";
zip.file(f, write_theme(wb.Themes, opts));
zip_add_file(zip, f, write_theme(wb.Themes, opts));
ct.themes.push(f);
add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
/* TODO: something more intelligent with styles */
f = "xl/styles." + wbext;
zip.file(f, write_sty(wb, f, opts));
zip_add_file(zip, f, write_sty(wb, f, opts));
ct.styles.push(f);
add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
if(wb.vbaraw && vbafmt) {
f = "xl/vbaProject.bin";
zip.file(f, wb.vbaraw);
zip_add_file(zip, f, wb.vbaraw);
ct.vba.push(f);
add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
}
zip.file("[Content_Types].xml", write_ct(ct, opts));
zip.file('_rels/.rels', write_rels(opts.rels));
zip.file('xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
zip_add_file(zip, "[Content_Types].xml", write_ct(ct, opts));
zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));
zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
delete opts.revssf; delete opts.ssf;
return zip;
@ -20443,12 +20464,7 @@ function read_zip(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
var zip, d = data;
var o = opts||{};
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
zip = zip_read(d, o);
return parse_zip(zip, o);
}
@ -20557,7 +20573,7 @@ function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: {"nodebuffer": "buffer", "string": "binary"}[oopts.type] || oopts.type}) : z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
@ -20937,9 +20953,6 @@ var utils/*:any*/ = {
sheet_to_txt: sheet_to_txt,
sheet_to_json: sheet_to_json,
sheet_to_html: HTML_.from_sheet,
sheet_to_dif: DIF.from_sheet,
sheet_to_slk: SYLK.from_sheet,
sheet_to_eth: ETH.from_sheet,
sheet_to_formulae: sheet_to_formulae,
sheet_to_row_object_array: sheet_to_json
};
@ -21173,10 +21186,7 @@ if(has_buf && typeof require != 'undefined') (function() {
};
})();
XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_ods = parse_ods;
XLSX.parse_fods = parse_fods;
XLSX.write_ods = write_ods;
if(typeof parse_xlscfb !== "undefined") XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_zip = parse_zip;
XLSX.read = readSync; //xlsread
XLSX.readFile = readFileSync; //readFile
@ -21187,7 +21197,7 @@ XLSX.writeFileSync = writeFileSync;
XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
if(typeof CFB !== "undefined") XLSX.CFB = CFB;
}
/*global define */
/*:: declare var define:any; */

116
xlsx.js generated

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.5';
XLSX.version = '0.15.0';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -169,8 +169,8 @@ function s2ab(s) {
}
function a2s(data) {
if(Array.isArray(data)) return data.map(_chr).join("");
var o = []; for(var i = 0; i < data.length; ++i) o[i] = _chr(data[i]); return o.join("");
if(Array.isArray(data)) return data.map(function(c) { return String.fromCharCode(c); }).join("");
var o = []; for(var i = 0; i < data.length; ++i) o[i] = String.fromCharCode(data[i]); return o.join("");
}
function a2u(data) {
@ -1250,7 +1250,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.1.2';
exports.version = '1.1.3';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -2393,7 +2393,7 @@ function parse_local_file(blob, csz, usz, o, EF) {
if(_csz != csz) warn_or_throw(wrn, "Bad compressed size: " + csz + " != " + _csz);
if(_usz != usz) warn_or_throw(wrn, "Bad uncompressed size: " + usz + " != " + _usz);
var _crc32 = CRC32.buf(data, 0);
if(crc32 != _crc32) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
if((crc32>>0) != (_crc32>>0)) warn_or_throw(wrn, "Bad CRC32 checksum: " + crc32 + " != " + _crc32);
cfb_add(o, name, data, {unsafe: true, mt: date});
}
function write_zip(cfb, options) {
@ -2783,6 +2783,7 @@ function getdatastr(data) {
if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary'));
if(data.asBinary) return debom(data.asBinary());
if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
if(data.content && data.type) return debom(cc2str(data.content));
return null;
}
@ -2795,6 +2796,7 @@ function getdatabin(data) {
if(typeof o == "string") return char_codes(o);
return Array.prototype.slice.call(o);
}
if(data.content && data.type) return data.content;
return null;
}
@ -2803,7 +2805,7 @@ function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getda
/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */
/* OASIS does not comment on filename case sensitivity */
function safegetzipfile(zip, file) {
var k = keys(zip.files);
var k = zip.FullPaths || keys(zip.files);
var f = file.toLowerCase(), g = f.replace(/\//g,'\\');
for(var i=0; i<k.length; ++i) {
var n = k[i].toLowerCase();
@ -2831,11 +2833,27 @@ function getzipstr(zip, file, safe) {
}
function zipentries(zip) {
var k = keys(zip.files), o = [];
var k = zip.FullPaths || keys(zip.files), o = [];
for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]);
return o.sort();
}
function zip_add_file(zip, path, content) {
if(zip.FullPaths) CFB.utils.cfb_add(zip, path, content);
else zip.file(path, content);
}
function zip_read(d, o) {
var zip;
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
return zip;
}
var jszip;
/*global JSZipSync:true */
if(typeof JSZipSync !== 'undefined') jszip = JSZipSync;
@ -2845,6 +2863,10 @@ if(typeof exports !== 'undefined') {
}
}
function zip_new() {
return new jszip();
}
function resolve_path(path, base) {
var result = base.split('/');
if(base.slice(-1) != "/") result.pop(); // folder path
@ -15191,7 +15213,6 @@ function write_cc(data, name:string, opts) {
*/
var attregexg2=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;
var attregex2=/([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/;
var _chr = function(c) { return String.fromCharCode(c); };
function xlml_parsexmltag(tag, skip_root) {
var words = tag.split(/\s+/);
var z = ([]); if(!skip_root) z[0] = words[0];
@ -19836,7 +19857,7 @@ var write_content_ods = (function() {
function write_ods(wb, opts) {
if(opts.bookType == "fods") return write_content_ods(wb, opts);
var zip = new jszip();
var zip = zip_new();
var f = "";
var manifest = [];
@ -19844,34 +19865,34 @@ var zip = new jszip();
/* Part 3 Section 3.3 MIME Media Type */
f = "mimetype";
zip.file(f, "application/vnd.oasis.opendocument.spreadsheet");
zip_add_file(zip, f, "application/vnd.oasis.opendocument.spreadsheet");
/* Part 1 Section 2.2 Documents */
f = "content.xml";
zip.file(f, write_content_ods(wb, opts));
zip_add_file(zip, f, write_content_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "ContentFile"]);
/* TODO: these are hard-coded styles to satiate excel */
f = "styles.xml";
zip.file(f, write_styles_ods(wb, opts));
zip_add_file(zip, f, write_styles_ods(wb, opts));
manifest.push([f, "text/xml"]);
rdf.push([f, "StylesFile"]);
/* TODO: this is hard-coded to satiate excel */
f = "meta.xml";
zip.file(f, write_meta_ods());
zip_add_file(zip, f, write_meta_ods());
manifest.push([f, "text/xml"]);
rdf.push([f, "MetadataFile"]);
/* Part 3 Section 6 Metadata Manifest File */
f = "manifest.rdf";
zip.file(f, write_rdf(rdf/*, opts*/));
zip_add_file(zip, f, write_rdf(rdf/*, opts*/));
manifest.push([f, "application/rdf+xml"]);
/* Part 3 Section 4 Manifest File */
f = "META-INF/manifest.xml";
zip.file(f, write_manifest(manifest/*, opts*/));
zip_add_file(zip, f, write_manifest(manifest/*, opts*/));
return zip;
}
@ -19892,13 +19913,13 @@ function write_obj_str(factory) {
var write_htm_str = write_obj_str(HTML_);
var write_csv_str = write_obj_str({from_sheet:sheet_to_csv});
var write_slk_str = write_obj_str(SYLK);
var write_dif_str = write_obj_str(DIF);
var write_prn_str = write_obj_str(PRN);
var write_rtf_str = write_obj_str(RTF);
var write_slk_str = write_obj_str(typeof SYLK !== "undefined" ? SYLK : {});
var write_dif_str = write_obj_str(typeof DIF !== "undefined" ? DIF : {});
var write_prn_str = write_obj_str(typeof PRN !== "undefined" ? PRN : {});
var write_rtf_str = write_obj_str(typeof RTF !== "undefined" ? RTF : {});
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
var write_dbf_buf = write_obj_str(typeof DBF !== "undefined" ? DBF : {});
var write_eth_str = write_obj_str(typeof ETH !== "undefined" ? ETH : {});
function fix_opts_func(defaults) {
return function fix_opts(opts) {
@ -20187,7 +20208,7 @@ function write_zip(wb, opts) {
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
var ct = new_ct();
fix_write_opts(opts = opts || {});
var zip = new jszip();
var zip = zip_new();
var f = "", rId = 0;
opts.cellXfs = [];
@ -20196,7 +20217,7 @@ var zip = new jszip();
if(!wb.Props) wb.Props = {};
f = "docProps/core.xml";
zip.file(f, write_core_props(wb.Props, opts));
zip_add_file(zip, f, write_core_props(wb.Props, opts));
ct.coreprops.push(f);
add_rels(opts.rels, 2, f, RELS.CORE_PROPS);
@ -20210,13 +20231,13 @@ f = "docProps/app.xml";
wb.Props.SheetNames = _sn;
}
wb.Props.Worksheets = wb.Props.SheetNames.length;
zip.file(f, write_ext_props(wb.Props, opts));
zip_add_file(zip, f, write_ext_props(wb.Props, opts));
ct.extprops.push(f);
add_rels(opts.rels, 3, f, RELS.EXT_PROPS);
if(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {
f = "docProps/custom.xml";
zip.file(f, write_cust_props(wb.Custprops, opts));
zip_add_file(zip, f, write_cust_props(wb.Custprops, opts));
ct.custprops.push(f);
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
}
@ -20228,14 +20249,14 @@ f = "docProps/app.xml";
switch(_type) {
case "chart": /*
f = "xl/chartsheets/sheet" + rId + "." + wbext;
zip.file(f, write_cs(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_cs(rId-1, f, opts, wb, wsrels));
ct.charts.push(f);
add_rels(wsrels, -1, "chartsheets/sheet" + rId + "." + wbext, RELS.CS);
break; */
/* falls through */
default:
f = "xl/worksheets/sheet" + rId + "." + wbext;
zip.file(f, write_ws(rId-1, f, opts, wb, wsrels));
zip_add_file(zip, f, write_ws(rId-1, f, opts, wb, wsrels));
ct.sheets.push(f);
add_rels(opts.wbrels, -1, "worksheets/sheet" + rId + "." + wbext, RELS.WS[0]);
}
@ -20245,57 +20266,57 @@ f = "docProps/app.xml";
var need_vml = false;
if(comments && comments.length > 0) {
var cf = "xl/comments" + rId + "." + wbext;
zip.file(cf, write_cmnt(comments, cf, opts));
zip_add_file(zip, cf, write_cmnt(comments, cf, opts));
ct.comments.push(cf);
add_rels(wsrels, -1, "../comments" + rId + "." + wbext, RELS.CMNT);
need_vml = true;
}
if(ws['!legacy']) {
if(need_vml) zip.file("xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
if(need_vml) zip_add_file(zip, "xl/drawings/vmlDrawing" + (rId) + ".vml", write_comments_vml(rId, ws['!comments']));
}
delete ws['!comments'];
delete ws['!legacy'];
}
if(wsrels['!id'].rId1) zip.file(get_rels_path(f), write_rels(wsrels));
if(wsrels['!id'].rId1) zip_add_file(zip, get_rels_path(f), write_rels(wsrels));
}
if(opts.Strings != null && opts.Strings.length > 0) {
f = "xl/sharedStrings." + wbext;
zip.file(f, write_sst(opts.Strings, f, opts));
zip_add_file(zip, f, write_sst(opts.Strings, f, opts));
ct.strs.push(f);
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
}
f = "xl/workbook." + wbext;
zip.file(f, write_wb(wb, f, opts));
zip_add_file(zip, f, write_wb(wb, f, opts));
ct.workbooks.push(f);
add_rels(opts.rels, 1, f, RELS.WB);
/* TODO: something more intelligent with themes */
f = "xl/theme/theme1.xml";
zip.file(f, write_theme(wb.Themes, opts));
zip_add_file(zip, f, write_theme(wb.Themes, opts));
ct.themes.push(f);
add_rels(opts.wbrels, -1, "theme/theme1.xml", RELS.THEME);
/* TODO: something more intelligent with styles */
f = "xl/styles." + wbext;
zip.file(f, write_sty(wb, f, opts));
zip_add_file(zip, f, write_sty(wb, f, opts));
ct.styles.push(f);
add_rels(opts.wbrels, -1, "styles." + wbext, RELS.STY);
if(wb.vbaraw && vbafmt) {
f = "xl/vbaProject.bin";
zip.file(f, wb.vbaraw);
zip_add_file(zip, f, wb.vbaraw);
ct.vba.push(f);
add_rels(opts.wbrels, -1, "vbaProject.bin", RELS.VBA);
}
zip.file("[Content_Types].xml", write_ct(ct, opts));
zip.file('_rels/.rels', write_rels(opts.rels));
zip.file('xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
zip_add_file(zip, "[Content_Types].xml", write_ct(ct, opts));
zip_add_file(zip, '_rels/.rels', write_rels(opts.rels));
zip_add_file(zip, 'xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
delete opts.revssf; delete opts.ssf;
return zip;
@ -20321,12 +20342,7 @@ function read_zip(data, opts) {
var zip, d = data;
var o = opts||{};
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": case "array": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
default: throw new Error("Unrecognized type " + o.type);
}
zip = zip_read(d, o);
return parse_zip(zip, o);
}
@ -20434,7 +20450,7 @@ function write_zip_type(wb, opts) {
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: {"nodebuffer": "buffer", "string": "binary"}[oopts.type] || oopts.type}) : z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
@ -20808,9 +20824,6 @@ var utils = {
sheet_to_txt: sheet_to_txt,
sheet_to_json: sheet_to_json,
sheet_to_html: HTML_.from_sheet,
sheet_to_dif: DIF.from_sheet,
sheet_to_slk: SYLK.from_sheet,
sheet_to_eth: ETH.from_sheet,
sheet_to_formulae: sheet_to_formulae,
sheet_to_row_object_array: sheet_to_json
};
@ -21044,10 +21057,7 @@ if(has_buf && typeof require != 'undefined') (function() {
};
})();
XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_ods = parse_ods;
XLSX.parse_fods = parse_fods;
XLSX.write_ods = write_ods;
if(typeof parse_xlscfb !== "undefined") XLSX.parse_xlscfb = parse_xlscfb;
XLSX.parse_zip = parse_zip;
XLSX.read = readSync; //xlsread
XLSX.readFile = readFileSync; //readFile
@ -21058,7 +21068,7 @@ XLSX.writeFileSync = writeFileSync;
XLSX.writeFileAsync = writeFileAsync;
XLSX.utils = utils;
XLSX.SSF = SSF;
XLSX.CFB = CFB;
if(typeof CFB !== "undefined") XLSX.CFB = CFB;
}
/*global define */
if(typeof exports !== 'undefined') make_xlsx_lib(exports);

8539
xlsx.mini.flow.js Normal file

File diff suppressed because it is too large Load Diff

8434
xlsx.mini.js Normal file

File diff suppressed because it is too large Load Diff