forked from sheetjs/sheetjs
updating to 0.13.1
This commit is contained in:
parent
fd18a32ab7
commit
55e7ea76a4
26
xlsx.core.min.js
vendored
26
xlsx.core.min.js
vendored
File diff suppressed because one or more lines are too long
32
xlsx.full.min.js
vendored
32
xlsx.full.min.js
vendored
File diff suppressed because one or more lines are too long
123
xlsx.js
123
xlsx.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;
|
||||
/*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