forked from sheetjs/sheetjs
version bump 0.13.1: SST optimization
- XLSX / XLSB avoid linear scan when emitting SST - minor nits
This commit is contained in:
parent
64798fd1f9
commit
9866dfc010
@ -1 +1 @@
|
||||
XLSX.version = '0.13.0';
|
||||
XLSX.version = '0.13.1';
|
||||
|
@ -6,9 +6,32 @@ RELS.WS = [
|
||||
"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"
|
||||
];
|
||||
|
||||
function get_sst_id(sst/*:SST*/, str/*:string*/)/*:number*/ {
|
||||
for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
|
||||
/*global Map */
|
||||
var browser_has_Map = typeof Map !== 'undefined';
|
||||
|
||||
function get_sst_id(sst/*:SST*/, str/*:string*/, rev)/*:number*/ {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
}
|
||||
}
|
||||
} else for(; i < len; ++i) {
|
||||
if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
}
|
||||
sst[len] = ({t:str}/*:any*/); sst.Count ++; sst.Unique ++;
|
||||
if(rev) {
|
||||
if(browser_has_Map) {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
function col_obj_w(C/*:number*/, col) {
|
||||
|
@ -245,7 +245,7 @@ function write_ws_xml_cell(cell/*:Cell*/, ref, ws, opts/*::, idx, wb*/)/*:string
|
||||
case 'e': o.t = "e"; break;
|
||||
default: if(cell.v == null) { delete cell.t; break; }
|
||||
if(opts.bookSST) {
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v));
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v, opts.revStrings));
|
||||
o.t = "s"; break;
|
||||
}
|
||||
o.t = "str"; break;
|
||||
|
@ -684,7 +684,7 @@ function write_ws_bin_cell(ba/*:BufArray*/, cell/*:Cell*/, R/*:number*/, C/*:num
|
||||
switch(cell.t) {
|
||||
case 's': case 'str':
|
||||
if(opts.bookSST) {
|
||||
vv = get_sst_id(opts.Strings, (cell.v/*:any*/));
|
||||
vv = get_sst_id(opts.Strings, (cell.v/*:any*/), opts.revStrings);
|
||||
o.t = "s"; o.v = vv;
|
||||
write_record(ba, "BrtCellIsst", write_BrtCellIsst(cell, o));
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ var HTML_ = (function() {
|
||||
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
|
||||
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
|
||||
CS = tag.colspan ? +tag.colspan : 1;
|
||||
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
if((RS = +tag.rowspan)>1 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
var _t/*:string*/ = tag.t || "";
|
||||
/* TODO: generate stub cells */
|
||||
if(!m.length) { C += CS; continue; }
|
||||
|
@ -17,22 +17,22 @@ function safe_parse_sheet(zip, path/*:string*/, relsPath/*:string*/, sheet, idx/
|
||||
try {
|
||||
sheetRels[sheet]=parse_rels(getzipstr(zip, relsPath, true), path);
|
||||
var data = getzipdata(zip, path);
|
||||
var _ws;
|
||||
switch(stype) {
|
||||
case 'sheet': sheets[sheet]=parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart':
|
||||
var cs = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
sheets[sheet] = cs;
|
||||
if(!cs || !cs['!chart']) break;
|
||||
var dfile = resolve_path(cs['!chart'].Target, path);
|
||||
case 'sheet': _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart': _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
if(!_ws || !_ws['!chart']) break;
|
||||
var dfile = resolve_path(_ws['!chart'].Target, path);
|
||||
var drelsp = get_rels_path(dfile);
|
||||
var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
|
||||
var chartp = resolve_path(draw, dfile);
|
||||
var crelsp = get_rels_path(chartp);
|
||||
cs = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, cs);
|
||||
_ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
|
||||
break;
|
||||
case 'macro': sheets[sheet]=parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': sheets[sheet]=parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'macro': _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
}
|
||||
sheets[sheet] = _ws;
|
||||
} catch(e) { if(opts.WTF) throw e; }
|
||||
}
|
||||
|
||||
@ -181,8 +181,10 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var f = 'Workbook', data = CFB.find(cfb, f);
|
||||
try {
|
||||
f = '/!DataSpaces/Version';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var version = */parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
@ -203,6 +205,7 @@ function parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var hdr = */parse_Primary(data.content);
|
||||
} catch(e) {}
|
||||
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
|
@ -12,6 +12,8 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
|
||||
}
|
||||
opts.rels = {}; opts.wbrels = {};
|
||||
opts.Strings = /*::((*/[]/*:: :any):SST)*/; opts.Strings.Count = 0; opts.Strings.Unique = 0;
|
||||
if(browser_has_Map) opts.revStrings = new Map();
|
||||
else { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }
|
||||
var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
|
||||
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
|
||||
var ct = new_ct();
|
||||
@ -52,11 +54,6 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
|
||||
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(f, write_wb(wb, f, opts));
|
||||
ct.workbooks.push(f);
|
||||
add_rels(opts.rels, 1, f, RELS.WB);
|
||||
|
||||
for(rId=1;rId <= wb.SheetNames.length; ++rId) {
|
||||
var wsrels = {'!id':{}};
|
||||
var ws = wb.Sheets[wb.SheetNames[rId-1]];
|
||||
@ -101,6 +98,11 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
|
||||
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(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";
|
||||
|
@ -1,24 +1,4 @@
|
||||
function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
|
||||
var out = z.generate(oopts);
|
||||
return o.type == "string" ? utf8read(out) : out;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var cfb/*:CFBContainer*/ = write_xlscfb(wb, o);
|
||||
function write_cfb_ctr(cfb/*:CFBContainer*/, o/*:WriteOpts*/)/*:any*/ {
|
||||
switch(o.type) {
|
||||
case "base64": case "binary": break;
|
||||
case "buffer": case "array": o.type = ""; break;
|
||||
@ -29,6 +9,34 @@ function write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
/*:: declare var encrypt_agile:any; */
|
||||
function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
|
||||
else switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = 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;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var cfb/*:CFBContainer*/ = write_xlscfb(wb, o);
|
||||
return write_cfb_ctr(cfb, o);
|
||||
}
|
||||
|
||||
function write_string_type(out/*:string*/, opts/*:WriteOpts*/, bom/*:?string*/)/*:any*/ {
|
||||
if(!bom) bom = "";
|
||||
var o = bom + out;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
||||
require(["xlsx"], function(XLSX) {
|
||||
console.log(XLSX);
|
||||
var X = XLSX;
|
||||
require(["xlsx"], function(XLSX2) {
|
||||
console.log(XLSX2);
|
||||
var X = XLSX2;
|
||||
|
||||
var global_wb;
|
||||
|
||||
|
26
dist/xlsx.core.min.js
generated
vendored
26
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
2
dist/xlsx.core.min.map
generated
vendored
File diff suppressed because one or more lines are too long
123
dist/xlsx.extendscript.js
generated
vendored
123
dist/xlsx.extendscript.js
generated
vendored
@ -9158,7 +9158,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.13.0';
|
||||
XLSX.version = '0.13.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
@ -21068,9 +21068,32 @@ RELS.WS = [
|
||||
"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"
|
||||
];
|
||||
|
||||
function get_sst_id(sst, str) {
|
||||
for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
|
||||
/*global Map */
|
||||
var browser_has_Map = typeof Map !== 'undefined';
|
||||
|
||||
function get_sst_id(sst, str, rev) {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
}
|
||||
}
|
||||
} else for(; i < len; ++i) {
|
||||
if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
}
|
||||
sst[len] = ({t:str}); sst.Count ++; sst.Unique ++;
|
||||
if(rev) {
|
||||
if(browser_has_Map) {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
function col_obj_w(C, col) {
|
||||
@ -21415,7 +21438,7 @@ function write_ws_xml_cell(cell, ref, ws, opts) {
|
||||
case 'e': o.t = "e"; break;
|
||||
default: if(cell.v == null) { delete cell.t; break; }
|
||||
if(opts.bookSST) {
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v));
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v, opts.revStrings));
|
||||
o.t = "s"; break;
|
||||
}
|
||||
o.t = "str"; break;
|
||||
@ -22439,7 +22462,7 @@ function write_ws_bin_cell(ba, cell, R, C, opts, ws) {
|
||||
switch(cell.t) {
|
||||
case 's': case 'str':
|
||||
if(opts.bookSST) {
|
||||
vv = get_sst_id(opts.Strings, (cell.v));
|
||||
vv = get_sst_id(opts.Strings, (cell.v), opts.revStrings);
|
||||
o.t = "s"; o.v = vv;
|
||||
write_record(ba, "BrtCellIsst", write_BrtCellIsst(cell, o));
|
||||
} else {
|
||||
@ -27229,7 +27252,7 @@ var HTML_ = (function() {
|
||||
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
|
||||
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
|
||||
CS = tag.colspan ? +tag.colspan : 1;
|
||||
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
if((RS = +tag.rowspan)>1 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
var _t = tag.t || "";
|
||||
/* TODO: generate stub cells */
|
||||
if(!m.length) { C += CS; continue; }
|
||||
@ -28260,22 +28283,22 @@ function safe_parse_sheet(zip, path, relsPath, sheet, idx, sheetRels, sheets, st
|
||||
try {
|
||||
sheetRels[sheet]=parse_rels(getzipstr(zip, relsPath, true), path);
|
||||
var data = getzipdata(zip, path);
|
||||
var _ws;
|
||||
switch(stype) {
|
||||
case 'sheet': sheets[sheet]=parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart':
|
||||
var cs = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
sheets[sheet] = cs;
|
||||
if(!cs || !cs['!chart']) break;
|
||||
var dfile = resolve_path(cs['!chart'].Target, path);
|
||||
case 'sheet': _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart': _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
if(!_ws || !_ws['!chart']) break;
|
||||
var dfile = resolve_path(_ws['!chart'].Target, path);
|
||||
var drelsp = get_rels_path(dfile);
|
||||
var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
|
||||
var chartp = resolve_path(draw, dfile);
|
||||
var crelsp = get_rels_path(chartp);
|
||||
cs = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, cs);
|
||||
_ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
|
||||
break;
|
||||
case 'macro': sheets[sheet]=parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': sheets[sheet]=parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'macro': _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
}
|
||||
sheets[sheet] = _ws;
|
||||
} catch(e) { if(opts.WTF) throw e; }
|
||||
}
|
||||
|
||||
@ -28424,8 +28447,10 @@ function parse_zip(zip, opts) {
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts) {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var f = 'Workbook', data = CFB.find(cfb, f);
|
||||
try {
|
||||
f = '/!DataSpaces/Version';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var version = */parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
@ -28446,6 +28471,7 @@ function parse_xlsxcfb(cfb, _opts) {
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var hdr = */parse_Primary(data.content);
|
||||
} catch(e) {}
|
||||
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
@ -28476,6 +28502,8 @@ function write_zip(wb, opts) {
|
||||
}
|
||||
opts.rels = {}; opts.wbrels = {};
|
||||
opts.Strings = []; opts.Strings.Count = 0; opts.Strings.Unique = 0;
|
||||
if(browser_has_Map) opts.revStrings = new Map();
|
||||
else { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }
|
||||
var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
|
||||
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
|
||||
var ct = new_ct();
|
||||
@ -28514,11 +28542,6 @@ f = "docProps/app.xml";
|
||||
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(f, write_wb(wb, f, opts));
|
||||
ct.workbooks.push(f);
|
||||
add_rels(opts.rels, 1, f, RELS.WB);
|
||||
|
||||
for(rId=1;rId <= wb.SheetNames.length; ++rId) {
|
||||
var wsrels = {'!id':{}};
|
||||
var ws = wb.Sheets[wb.SheetNames[rId-1]];
|
||||
@ -28563,6 +28586,11 @@ f = "docProps/app.xml";
|
||||
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(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";
|
||||
@ -28699,27 +28727,7 @@ function readFileSync(filename, opts) {
|
||||
var o = opts||{}; o.type = 'file';
|
||||
return readSync(filename, o);
|
||||
}
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
|
||||
var out = z.generate(oopts);
|
||||
return o.type == "string" ? utf8read(out) : out;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var cfb = write_xlscfb(wb, o);
|
||||
function write_cfb_ctr(cfb, o) {
|
||||
switch(o.type) {
|
||||
case "base64": case "binary": break;
|
||||
case "buffer": case "array": o.type = ""; break;
|
||||
@ -28730,6 +28738,33 @@ function write_cfb_type(wb, opts) {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
|
||||
else switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = 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;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var cfb = write_xlscfb(wb, o);
|
||||
return write_cfb_ctr(cfb, o);
|
||||
}
|
||||
|
||||
function write_string_type(out, opts, bom) {
|
||||
if(!bom) bom = "";
|
||||
var o = bom + out;
|
||||
|
32
dist/xlsx.full.min.js
generated
vendored
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
2
dist/xlsx.full.min.map
generated
vendored
File diff suppressed because one or more lines are too long
123
dist/xlsx.js
generated
vendored
123
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.13.0';
|
||||
XLSX.version = '0.13.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
@ -11914,9 +11914,32 @@ RELS.WS = [
|
||||
"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"
|
||||
];
|
||||
|
||||
function get_sst_id(sst, str) {
|
||||
for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
|
||||
/*global Map */
|
||||
var browser_has_Map = typeof Map !== 'undefined';
|
||||
|
||||
function get_sst_id(sst, str, rev) {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
}
|
||||
}
|
||||
} else for(; i < len; ++i) {
|
||||
if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
}
|
||||
sst[len] = ({t:str}); sst.Count ++; sst.Unique ++;
|
||||
if(rev) {
|
||||
if(browser_has_Map) {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
function col_obj_w(C, col) {
|
||||
@ -12261,7 +12284,7 @@ function write_ws_xml_cell(cell, ref, ws, opts) {
|
||||
case 'e': o.t = "e"; break;
|
||||
default: if(cell.v == null) { delete cell.t; break; }
|
||||
if(opts.bookSST) {
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v));
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v, opts.revStrings));
|
||||
o.t = "s"; break;
|
||||
}
|
||||
o.t = "str"; break;
|
||||
@ -13285,7 +13308,7 @@ function write_ws_bin_cell(ba, cell, R, C, opts, ws) {
|
||||
switch(cell.t) {
|
||||
case 's': case 'str':
|
||||
if(opts.bookSST) {
|
||||
vv = get_sst_id(opts.Strings, (cell.v));
|
||||
vv = get_sst_id(opts.Strings, (cell.v), opts.revStrings);
|
||||
o.t = "s"; o.v = vv;
|
||||
write_record(ba, "BrtCellIsst", write_BrtCellIsst(cell, o));
|
||||
} else {
|
||||
@ -18075,7 +18098,7 @@ var HTML_ = (function() {
|
||||
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
|
||||
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
|
||||
CS = tag.colspan ? +tag.colspan : 1;
|
||||
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
if((RS = +tag.rowspan)>1 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
var _t = tag.t || "";
|
||||
/* TODO: generate stub cells */
|
||||
if(!m.length) { C += CS; continue; }
|
||||
@ -19106,22 +19129,22 @@ function safe_parse_sheet(zip, path, relsPath, sheet, idx, sheetRels, sheets, st
|
||||
try {
|
||||
sheetRels[sheet]=parse_rels(getzipstr(zip, relsPath, true), path);
|
||||
var data = getzipdata(zip, path);
|
||||
var _ws;
|
||||
switch(stype) {
|
||||
case 'sheet': sheets[sheet]=parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart':
|
||||
var cs = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
sheets[sheet] = cs;
|
||||
if(!cs || !cs['!chart']) break;
|
||||
var dfile = resolve_path(cs['!chart'].Target, path);
|
||||
case 'sheet': _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart': _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
if(!_ws || !_ws['!chart']) break;
|
||||
var dfile = resolve_path(_ws['!chart'].Target, path);
|
||||
var drelsp = get_rels_path(dfile);
|
||||
var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
|
||||
var chartp = resolve_path(draw, dfile);
|
||||
var crelsp = get_rels_path(chartp);
|
||||
cs = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, cs);
|
||||
_ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
|
||||
break;
|
||||
case 'macro': sheets[sheet]=parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': sheets[sheet]=parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'macro': _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
}
|
||||
sheets[sheet] = _ws;
|
||||
} catch(e) { if(opts.WTF) throw e; }
|
||||
}
|
||||
|
||||
@ -19270,8 +19293,10 @@ function parse_zip(zip, opts) {
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts) {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var f = 'Workbook', data = CFB.find(cfb, f);
|
||||
try {
|
||||
f = '/!DataSpaces/Version';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var version = */parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
@ -19292,6 +19317,7 @@ function parse_xlsxcfb(cfb, _opts) {
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var hdr = */parse_Primary(data.content);
|
||||
} catch(e) {}
|
||||
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
@ -19322,6 +19348,8 @@ function write_zip(wb, opts) {
|
||||
}
|
||||
opts.rels = {}; opts.wbrels = {};
|
||||
opts.Strings = []; opts.Strings.Count = 0; opts.Strings.Unique = 0;
|
||||
if(browser_has_Map) opts.revStrings = new Map();
|
||||
else { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }
|
||||
var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
|
||||
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
|
||||
var ct = new_ct();
|
||||
@ -19360,11 +19388,6 @@ f = "docProps/app.xml";
|
||||
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(f, write_wb(wb, f, opts));
|
||||
ct.workbooks.push(f);
|
||||
add_rels(opts.rels, 1, f, RELS.WB);
|
||||
|
||||
for(rId=1;rId <= wb.SheetNames.length; ++rId) {
|
||||
var wsrels = {'!id':{}};
|
||||
var ws = wb.Sheets[wb.SheetNames[rId-1]];
|
||||
@ -19409,6 +19432,11 @@ f = "docProps/app.xml";
|
||||
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(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";
|
||||
@ -19545,27 +19573,7 @@ function readFileSync(filename, opts) {
|
||||
var o = opts||{}; o.type = 'file';
|
||||
return readSync(filename, o);
|
||||
}
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
|
||||
var out = z.generate(oopts);
|
||||
return o.type == "string" ? utf8read(out) : out;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var cfb = write_xlscfb(wb, o);
|
||||
function write_cfb_ctr(cfb, o) {
|
||||
switch(o.type) {
|
||||
case "base64": case "binary": break;
|
||||
case "buffer": case "array": o.type = ""; break;
|
||||
@ -19576,6 +19584,33 @@ function write_cfb_type(wb, opts) {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
|
||||
else switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = 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;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var cfb = write_xlscfb(wb, o);
|
||||
return write_cfb_ctr(cfb, o);
|
||||
}
|
||||
|
||||
function write_string_type(out, opts, bom) {
|
||||
if(!bom) bom = "";
|
||||
var o = bom + out;
|
||||
|
24
dist/xlsx.min.js
generated
vendored
24
dist/xlsx.min.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.min.map
generated
vendored
2
dist/xlsx.min.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xlsx",
|
||||
"version": "0.13.0",
|
||||
"version": "0.13.1",
|
||||
"author": "sheetjs",
|
||||
"description": "SheetJS Spreadsheet data parser and writer",
|
||||
"keywords": [
|
||||
|
124
xlsx.flow.js
124
xlsx.flow.js
@ -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.13.0';
|
||||
XLSX.version = '0.13.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*:: declare var cptable:any; */
|
||||
/*global cptable:true, window */
|
||||
@ -12012,9 +12012,32 @@ RELS.WS = [
|
||||
"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"
|
||||
];
|
||||
|
||||
function get_sst_id(sst/*:SST*/, str/*:string*/)/*:number*/ {
|
||||
for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
|
||||
/*global Map */
|
||||
var browser_has_Map = typeof Map !== 'undefined';
|
||||
|
||||
function get_sst_id(sst/*:SST*/, str/*:string*/, rev)/*:number*/ {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
}
|
||||
}
|
||||
} else for(; i < len; ++i) {
|
||||
if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
}
|
||||
sst[len] = ({t:str}/*:any*/); sst.Count ++; sst.Unique ++;
|
||||
if(rev) {
|
||||
if(browser_has_Map) {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
function col_obj_w(C/*:number*/, col) {
|
||||
@ -12359,7 +12382,7 @@ function write_ws_xml_cell(cell/*:Cell*/, ref, ws, opts/*::, idx, wb*/)/*:string
|
||||
case 'e': o.t = "e"; break;
|
||||
default: if(cell.v == null) { delete cell.t; break; }
|
||||
if(opts.bookSST) {
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v));
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v, opts.revStrings));
|
||||
o.t = "s"; break;
|
||||
}
|
||||
o.t = "str"; break;
|
||||
@ -13384,7 +13407,7 @@ function write_ws_bin_cell(ba/*:BufArray*/, cell/*:Cell*/, R/*:number*/, C/*:num
|
||||
switch(cell.t) {
|
||||
case 's': case 'str':
|
||||
if(opts.bookSST) {
|
||||
vv = get_sst_id(opts.Strings, (cell.v/*:any*/));
|
||||
vv = get_sst_id(opts.Strings, (cell.v/*:any*/), opts.revStrings);
|
||||
o.t = "s"; o.v = vv;
|
||||
write_record(ba, "BrtCellIsst", write_BrtCellIsst(cell, o));
|
||||
} else {
|
||||
@ -18188,7 +18211,7 @@ var HTML_ = (function() {
|
||||
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
|
||||
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
|
||||
CS = tag.colspan ? +tag.colspan : 1;
|
||||
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
if((RS = +tag.rowspan)>1 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
var _t/*:string*/ = tag.t || "";
|
||||
/* TODO: generate stub cells */
|
||||
if(!m.length) { C += CS; continue; }
|
||||
@ -19220,22 +19243,22 @@ function safe_parse_sheet(zip, path/*:string*/, relsPath/*:string*/, sheet, idx/
|
||||
try {
|
||||
sheetRels[sheet]=parse_rels(getzipstr(zip, relsPath, true), path);
|
||||
var data = getzipdata(zip, path);
|
||||
var _ws;
|
||||
switch(stype) {
|
||||
case 'sheet': sheets[sheet]=parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart':
|
||||
var cs = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
sheets[sheet] = cs;
|
||||
if(!cs || !cs['!chart']) break;
|
||||
var dfile = resolve_path(cs['!chart'].Target, path);
|
||||
case 'sheet': _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart': _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
if(!_ws || !_ws['!chart']) break;
|
||||
var dfile = resolve_path(_ws['!chart'].Target, path);
|
||||
var drelsp = get_rels_path(dfile);
|
||||
var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
|
||||
var chartp = resolve_path(draw, dfile);
|
||||
var crelsp = get_rels_path(chartp);
|
||||
cs = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, cs);
|
||||
_ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
|
||||
break;
|
||||
case 'macro': sheets[sheet]=parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': sheets[sheet]=parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'macro': _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
}
|
||||
sheets[sheet] = _ws;
|
||||
} catch(e) { if(opts.WTF) throw e; }
|
||||
}
|
||||
|
||||
@ -19384,8 +19407,10 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var f = 'Workbook', data = CFB.find(cfb, f);
|
||||
try {
|
||||
f = '/!DataSpaces/Version';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var version = */parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
@ -19406,6 +19431,7 @@ function parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var hdr = */parse_Primary(data.content);
|
||||
} catch(e) {}
|
||||
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
@ -19438,6 +19464,8 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
|
||||
}
|
||||
opts.rels = {}; opts.wbrels = {};
|
||||
opts.Strings = /*::((*/[]/*:: :any):SST)*/; opts.Strings.Count = 0; opts.Strings.Unique = 0;
|
||||
if(browser_has_Map) opts.revStrings = new Map();
|
||||
else { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }
|
||||
var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
|
||||
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
|
||||
var ct = new_ct();
|
||||
@ -19478,11 +19506,6 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
|
||||
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(f, write_wb(wb, f, opts));
|
||||
ct.workbooks.push(f);
|
||||
add_rels(opts.rels, 1, f, RELS.WB);
|
||||
|
||||
for(rId=1;rId <= wb.SheetNames.length; ++rId) {
|
||||
var wsrels = {'!id':{}};
|
||||
var ws = wb.Sheets[wb.SheetNames[rId-1]];
|
||||
@ -19527,6 +19550,11 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ {
|
||||
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(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";
|
||||
@ -19664,27 +19692,7 @@ function readFileSync(filename/*:string*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var o = opts||{}; o.type = 'file';
|
||||
return readSync(filename, o);
|
||||
}
|
||||
function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
|
||||
var out = z.generate(oopts);
|
||||
return o.type == "string" ? utf8read(out) : out;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var cfb/*:CFBContainer*/ = write_xlscfb(wb, o);
|
||||
function write_cfb_ctr(cfb/*:CFBContainer*/, o/*:WriteOpts*/)/*:any*/ {
|
||||
switch(o.type) {
|
||||
case "base64": case "binary": break;
|
||||
case "buffer": case "array": o.type = ""; break;
|
||||
@ -19695,6 +19703,34 @@ function write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
/*:: declare var encrypt_agile:any; */
|
||||
function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
|
||||
else switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = 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;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
var cfb/*:CFBContainer*/ = write_xlscfb(wb, o);
|
||||
return write_cfb_ctr(cfb, o);
|
||||
}
|
||||
|
||||
function write_string_type(out/*:string*/, opts/*:WriteOpts*/, bom/*:?string*/)/*:any*/ {
|
||||
if(!bom) bom = "";
|
||||
var o = bom + out;
|
||||
|
123
xlsx.js
generated
123
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.13.0';
|
||||
XLSX.version = '0.13.1';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
@ -11914,9 +11914,32 @@ RELS.WS = [
|
||||
"http://purl.oclc.org/ooxml/officeDocument/relationships/worksheet"
|
||||
];
|
||||
|
||||
function get_sst_id(sst, str) {
|
||||
for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
|
||||
/*global Map */
|
||||
var browser_has_Map = typeof Map !== 'undefined';
|
||||
|
||||
function get_sst_id(sst, str, rev) {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
}
|
||||
}
|
||||
} else for(; i < len; ++i) {
|
||||
if(sst[i].t === str) { sst.Count ++; return i; }
|
||||
}
|
||||
sst[len] = ({t:str}); sst.Count ++; sst.Unique ++;
|
||||
if(rev) {
|
||||
if(browser_has_Map) {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
function col_obj_w(C, col) {
|
||||
@ -12261,7 +12284,7 @@ function write_ws_xml_cell(cell, ref, ws, opts) {
|
||||
case 'e': o.t = "e"; break;
|
||||
default: if(cell.v == null) { delete cell.t; break; }
|
||||
if(opts.bookSST) {
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v));
|
||||
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v, opts.revStrings));
|
||||
o.t = "s"; break;
|
||||
}
|
||||
o.t = "str"; break;
|
||||
@ -13285,7 +13308,7 @@ function write_ws_bin_cell(ba, cell, R, C, opts, ws) {
|
||||
switch(cell.t) {
|
||||
case 's': case 'str':
|
||||
if(opts.bookSST) {
|
||||
vv = get_sst_id(opts.Strings, (cell.v));
|
||||
vv = get_sst_id(opts.Strings, (cell.v), opts.revStrings);
|
||||
o.t = "s"; o.v = vv;
|
||||
write_record(ba, "BrtCellIsst", write_BrtCellIsst(cell, o));
|
||||
} else {
|
||||
@ -18075,7 +18098,7 @@ var HTML_ = (function() {
|
||||
while(m.charAt(0) == "<" && (cc = m.indexOf(">")) > -1) m = m.slice(cc+1);
|
||||
var tag = parsexmltag(cell.slice(0, cell.indexOf(">")));
|
||||
CS = tag.colspan ? +tag.colspan : 1;
|
||||
if((RS = +tag.rowspan)>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
if((RS = +tag.rowspan)>1 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
|
||||
var _t = tag.t || "";
|
||||
/* TODO: generate stub cells */
|
||||
if(!m.length) { C += CS; continue; }
|
||||
@ -19106,22 +19129,22 @@ function safe_parse_sheet(zip, path, relsPath, sheet, idx, sheetRels, sheets, st
|
||||
try {
|
||||
sheetRels[sheet]=parse_rels(getzipstr(zip, relsPath, true), path);
|
||||
var data = getzipdata(zip, path);
|
||||
var _ws;
|
||||
switch(stype) {
|
||||
case 'sheet': sheets[sheet]=parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart':
|
||||
var cs = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
sheets[sheet] = cs;
|
||||
if(!cs || !cs['!chart']) break;
|
||||
var dfile = resolve_path(cs['!chart'].Target, path);
|
||||
case 'sheet': _ws = parse_ws(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'chart': _ws = parse_cs(data, path, idx, opts, sheetRels[sheet], wb, themes, styles);
|
||||
if(!_ws || !_ws['!chart']) break;
|
||||
var dfile = resolve_path(_ws['!chart'].Target, path);
|
||||
var drelsp = get_rels_path(dfile);
|
||||
var draw = parse_drawing(getzipstr(zip, dfile, true), parse_rels(getzipstr(zip, drelsp, true), dfile));
|
||||
var chartp = resolve_path(draw, dfile);
|
||||
var crelsp = get_rels_path(chartp);
|
||||
cs = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, cs);
|
||||
_ws = parse_chart(getzipstr(zip, chartp, true), chartp, opts, parse_rels(getzipstr(zip, crelsp, true), chartp), wb, _ws);
|
||||
break;
|
||||
case 'macro': sheets[sheet]=parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': sheets[sheet]=parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'macro': _ws = parse_ms(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
case 'dialog': _ws = parse_ds(data, path, idx, opts, sheetRels[sheet], wb, themes, styles); break;
|
||||
}
|
||||
sheets[sheet] = _ws;
|
||||
} catch(e) { if(opts.WTF) throw e; }
|
||||
}
|
||||
|
||||
@ -19270,8 +19293,10 @@ function parse_zip(zip, opts) {
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts) {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var f = 'Workbook', data = CFB.find(cfb, f);
|
||||
try {
|
||||
f = '/!DataSpaces/Version';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var version = */parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
@ -19292,6 +19317,7 @@ function parse_xlsxcfb(cfb, _opts) {
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/*var hdr = */parse_Primary(data.content);
|
||||
} catch(e) {}
|
||||
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
@ -19322,6 +19348,8 @@ function write_zip(wb, opts) {
|
||||
}
|
||||
opts.rels = {}; opts.wbrels = {};
|
||||
opts.Strings = []; opts.Strings.Count = 0; opts.Strings.Unique = 0;
|
||||
if(browser_has_Map) opts.revStrings = new Map();
|
||||
else { opts.revStrings = {}; opts.revStrings.foo = []; delete opts.revStrings.foo; }
|
||||
var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
|
||||
var vbafmt = VBAFMTS.indexOf(opts.bookType) > -1;
|
||||
var ct = new_ct();
|
||||
@ -19360,11 +19388,6 @@ f = "docProps/app.xml";
|
||||
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(f, write_wb(wb, f, opts));
|
||||
ct.workbooks.push(f);
|
||||
add_rels(opts.rels, 1, f, RELS.WB);
|
||||
|
||||
for(rId=1;rId <= wb.SheetNames.length; ++rId) {
|
||||
var wsrels = {'!id':{}};
|
||||
var ws = wb.Sheets[wb.SheetNames[rId-1]];
|
||||
@ -19409,6 +19432,11 @@ f = "docProps/app.xml";
|
||||
add_rels(opts.wbrels, -1, "sharedStrings." + wbext, RELS.SST);
|
||||
}
|
||||
|
||||
f = "xl/workbook." + wbext;
|
||||
zip.file(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";
|
||||
@ -19545,27 +19573,7 @@ function readFileSync(filename, opts) {
|
||||
var o = opts||{}; o.type = 'file';
|
||||
return readSync(filename, o);
|
||||
}
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
if(o.type === "file") return write_dl(o.file, z.generate(oopts));
|
||||
var out = z.generate(oopts);
|
||||
return o.type == "string" ? utf8read(out) : out;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var cfb = write_xlscfb(wb, o);
|
||||
function write_cfb_ctr(cfb, o) {
|
||||
switch(o.type) {
|
||||
case "base64": case "binary": break;
|
||||
case "buffer": case "array": o.type = ""; break;
|
||||
@ -19576,6 +19584,33 @@ function write_cfb_type(wb, opts) {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
var oopts = {};
|
||||
if(o.compression) oopts.compression = 'DEFLATE';
|
||||
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
|
||||
else switch(o.type) {
|
||||
case "base64": oopts.type = "base64"; break;
|
||||
case "binary": oopts.type = "string"; break;
|
||||
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
|
||||
case "buffer":
|
||||
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = 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;
|
||||
}
|
||||
|
||||
function write_cfb_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var cfb = write_xlscfb(wb, o);
|
||||
return write_cfb_ctr(cfb, o);
|
||||
}
|
||||
|
||||
function write_string_type(out, opts, bom) {
|
||||
if(!bom) bom = "";
|
||||
var o = bom + out;
|
||||
|
Loading…
Reference in New Issue
Block a user