updating to 0.15.5

This commit is contained in:
SheetJS 2020-01-27 20:21:34 -05:00
parent a19318458b
commit c310488be6
3 changed files with 62 additions and 45 deletions

30
xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

32
xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

45
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.15.2';
XLSX.version = '0.15.5';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -3114,8 +3114,8 @@ function write_w3cdtf(d, t) { try { return d.toISOString().replace(/\.\d*/,"");
function write_vt(s) {
switch(typeof s) {
case 'string': return writextag('vt:lpwstr', s);
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', String(s));
case 'string': return writextag('vt:lpwstr', escapexml(s));
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', escapexml(String(s)));
case 'boolean': return writextag('vt:bool',s?'true':'false');
}
if(s instanceof Date) return writextag('vt:filetime', write_w3cdtf(s));
@ -3663,9 +3663,11 @@ function sheet_add_aoa(_ws, data, opts) {
}
if(dense) {
if(!ws[__R]) ws[__R] = [];
if(ws[__R][__C] && ws[__R][__C].z) cell.z = ws[__R][__C].z;
ws[__R][__C] = cell;
} else {
var cell_ref = encode_cell(({c:__C,r:__R}));
if(ws[cell_ref] && ws[cell_ref].z) cell.z = ws[cell_ref].z;
ws[cell_ref] = cell;
}
}
@ -4719,7 +4721,7 @@ function parse_core_props(data) {
for(var i = 0; i < CORE_PROPS.length; ++i) {
var f = CORE_PROPS[i], cur = data.match(CORE_PROPS_REGEX[i]);
if(cur != null && cur.length > 0) p[f[1]] = cur[1];
if(cur != null && cur.length > 0) p[f[1]] = unescapexml(cur[1]);
if(f[2] === 'date' && p[f[1]]) p[f[1]] = parseDate(p[f[1]]);
}
@ -4738,6 +4740,7 @@ var CORE_PROPS_XML_ROOT = writextag('cp:coreProperties', null, {
function cp_doit(f, g, h, o, p) {
if(p[f] != null || g == null || g === "") return;
p[f] = g;
g = escapexml(g);
o[o.length] = (h ? writextag(f,g,h) : writetag(f,g));
}
@ -4838,9 +4841,10 @@ function parse_ext_props(data, p, opts) {
data = utf8read(data);
EXT_PROPS.forEach(function(f) {
var xml = (data.match(matchtag(f[0]))||[])[1];
switch(f[2]) {
case "string": p[f[1]] = (data.match(matchtag(f[0]))||[])[1]; break;
case "bool": p[f[1]] = (data.match(matchtag(f[0]))||[])[1] === "true"; break;
case "string": p[f[1]] = unescapexml(xml||""); break;
case "bool": p[f[1]] = xml === "true"; break;
case "raw":
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>([\\s\\S]*?)<\/" + f[0] + ">"));
if(cur && cur.length > 0) q[f[1]] = cur[1];
@ -4869,7 +4873,7 @@ function write_ext_props(cp) {
if(cp[f[1]] === undefined) return;
var v;
switch(f[2]) {
case 'string': v = String(cp[f[1]]); break;
case 'string': v = escapexml(String(cp[f[1]])); break;
case 'bool': v = cp[f[1]] ? 'true' : 'false'; break;
}
if(v !== undefined) o[o.length] = (W(f[0], v));
@ -4894,7 +4898,7 @@ function parse_cust_props(data, opts) {
switch(y[0]) {
case '<?xml': break;
case '<Properties': break;
case '<property': name = y.name; break;
case '<property': name = unescapexml(y.name); break;
case '</property>': name = null; break;
default: if (x.indexOf('<vt:') === 0) {
var toks = x.split('>');
@ -4943,7 +4947,7 @@ function write_cust_props(cp) {
o[o.length] = (writextag('property', write_vt(cp[k]), {
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
'pid': pid,
'name': k
'name': escapexml(k)
}));
});
if(o.length>2){ o[o.length] = '</Properties>'; o[1]=o[1].replace("/>",">"); }
@ -12939,11 +12943,11 @@ function get_cell_style(styles, cell, opts) {
}
function safe_format(p, fmtid, fillid, opts, themes, styles) {
if(p.t === 'z') return;
if(p.t === 'd' && typeof p.v === 'string') p.v = parseDate(p.v);
try {
if(opts.cellNF) p.z = SSF._table[fmtid];
} catch(e) { if(opts.WTF) throw e; }
if(p.t === 'z') return;
if(p.t === 'd' && typeof p.v === 'string') p.v = parseDate(p.v);
if(!opts || opts.cellText !== false) try {
if(SSF._table[fmtid] == null) SSF.load(SSFImplicit[fmtid] || "General", fmtid);
if(p.t === 'e') p.w = p.w || BErr[p.v];
@ -18426,6 +18430,7 @@ var XLSRecordEnum = {
0x001d: { n:"Selection" },
0x0022: { n:"Date1904", f:parsebool },
0x0023: { n:"ExternName", f:parse_ExternName },
0x0024: { n:"COLWIDTH" },
0x0026: { n:"LeftMargin", f:parse_Xnum },
0x0027: { n:"RightMargin", f:parse_Xnum },
0x0028: { n:"TopMargin", f:parse_Xnum },
@ -20384,7 +20389,7 @@ function parse_zip(zip, opts) {
/* Numbers iOS hack */
var nmode = (getzipdata(zip,"xl/worksheets/sheet.xml",true))?1:0;
for(i = 0; i != props.Worksheets; ++i) {
wsloop: for(i = 0; i != props.Worksheets; ++i) {
var stype = "sheet";
if(wbrels && wbrels[i]) {
path = 'xl/' + (wbrels[i][1]).replace(/[\/]?xl\//, "");
@ -20396,6 +20401,18 @@ function parse_zip(zip, opts) {
path = path.replace(/sheet0\./,"sheet.");
}
relsPath = path.replace(/^(.*)(\/)([^\/]*)$/, "$1/_rels/$3.rels");
if(opts && opts.sheets != null) switch(typeof opts.sheets) {
case "number": if(i != opts.sheets) continue wsloop; break;
case "string": if(props.SheetNames[i].toLowerCase() != opts.sheets.toLowerCase()) continue wsloop; break;
default: if(Array.isArray && Array.isArray(opts.sheets)) {
var snjseen = false;
for(var snj = 0; snj != opts.sheets.length; ++snj) {
if(typeof opts.sheets[snj] == "number" && opts.sheets[snj] == i) snjseen=1;
if(typeof opts.sheets[snj] == "string" && opts.sheets[snj].toLowerCase() == props.SheetNames[i].toLowerCase()) snjseen = 1;
}
if(!snjseen) continue wsloop;
}
}
safe_parse_sheet(zip, path, relsPath, props.SheetNames[i], i, sheetRels, sheets, stype, opts, wb, themes, styles);
}
@ -20412,11 +20429,11 @@ function parse_zip(zip, opts) {
Themes: themes,
SSF: SSF.get_table()
});
if(opts.bookFiles) {
if(opts && opts.bookFiles) {
out.keys = entries;
out.files = zip.files;
}
if(opts.bookVBA) {
if(opts && opts.bookVBA) {
if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,strip_front_slash(dir.vba[0]),true);
else if(dir.defaults && dir.defaults.bin === CT_VBA) out.vbaraw = getzipdata(zip, 'xl/vbaProject.bin',true);
}