updating to 0.16.5

This commit is contained in:
SheetJS 2020-07-30 23:40:07 -04:00
parent 9e4abfa5aa
commit 3e99af3174
4 changed files with 169 additions and 140 deletions

@ -2182,7 +2182,7 @@ describe('HTML', function() {
var html = "<table><tr style='display: none;'><td>1</td><td>2</td><td>3</td></tr><tr><td class='hidden'>Foo</td><td>Bar</td><td style='display: none;'>Baz</td></tr></table><style>.hidden {display: none}</style>";
var ws = X.utils.table_to_sheet(get_dom_element(html), {display: true});
assert.equal(ws['!ref'], "A1");
assert.equal(ws.hasOwnProperty('!rows'), false);
assert(ws.hasOwnProperty('!rows') == false || !ws["!rows"][0] || !ws["!rows"][0].hidden);
assert.equal(get_cell(ws, "A1").v, "Bar");
});
describe('type override', function() {
@ -2321,17 +2321,17 @@ describe('corner cases', function() {
});
it("should quote unicode sheet names in formulae", function() {
var wb = X.read(fs.readFileSync(dir + "cross-sheet_formula_names.xlsb"), {WTF:1, type:TYPE});
assert.equal(wb.Sheets["Sheet1"]["A1"].f, "'a-b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A2"].f, "'a#b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A3"].f, "'a^b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A4"].f, "'a%b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A5"].f, "'a\u066ab'!A1");
assert.equal(wb.Sheets["Sheet1"]["A6"].f, "'☃️'!A1");
assert.equal(wb.Sheets["Sheet1"]["A7"].f, "'\ud83c\udf63'!A1");
assert.equal(wb.Sheets["Sheet1"]["A8"].f, "'a!!b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A9"].f, "'a$b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A10"].f, "'a!b'!A1");
assert.equal(wb.Sheets["Sheet1"]["A11"].f, "'a b'!A1");
assert.equal(wb.Sheets.Sheet1.A1.f, "'a-b'!A1");
assert.equal(wb.Sheets.Sheet1.A2.f, "'a#b'!A1");
assert.equal(wb.Sheets.Sheet1.A3.f, "'a^b'!A1");
assert.equal(wb.Sheets.Sheet1.A4.f, "'a%b'!A1");
assert.equal(wb.Sheets.Sheet1.A5.f, "'a\u066ab'!A1");
assert.equal(wb.Sheets.Sheet1.A6.f, "'☃️'!A1");
assert.equal(wb.Sheets.Sheet1.A7.f, "'\ud83c\udf63'!A1");
assert.equal(wb.Sheets.Sheet1.A8.f, "'a!!b'!A1");
assert.equal(wb.Sheets.Sheet1.A9.f, "'a$b'!A1");
assert.equal(wb.Sheets.Sheet1.A10.f, "'a!b'!A1");
assert.equal(wb.Sheets.Sheet1.A11.f, "'a b'!A1");
});
});

26
xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

28
xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

231
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.16.4';
XLSX.version = '0.16.5';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -3680,7 +3680,11 @@ function encode_cell(cell) {
for(; col; col=((col-1)/26)|0) s = String.fromCharCode(((col-1)%26) + 65) + s;
return s + (cell.r + 1);
}
function decode_range(range) { var x =range.split(":"); return {s:decode_cell(x[0]),e:decode_cell(x[x.length-1])}; }
function decode_range(range) {
var idx = range.indexOf(":");
if(idx == -1) return { s: decode_cell(range), e: decode_cell(range) };
return { s: decode_cell(range.slice(0, idx)), e: decode_cell(range.slice(idx + 1)) };
}
function encode_range(cs,ce) {
if(typeof ce === 'undefined' || typeof ce === 'number') {
return encode_range(cs.s, cs.e);
@ -3754,6 +3758,7 @@ function sheet_add_aoa(_ws, data, opts) {
var _origin = typeof o.origin == "string" ? decode_cell(o.origin) : o.origin;
_R = _origin.r; _C = _origin.c;
}
if(!ws["!ref"]) ws["!ref"] = "A1:A1";
}
var range = ({s: {c:10000000, r:10000000}, e: {c:0, r:0}});
if(ws['!ref']) {
@ -3805,7 +3810,7 @@ function sheet_add_aoa(_ws, data, opts) {
function aoa_to_sheet(data, opts) { return sheet_add_aoa(null, data, opts); }
function write_UInt32LE(x, o) {
if(!o) o = new_buf(4);
if (!o) o = new_buf(4);
o.write_shift(4, x);
return o;
}
@ -3816,9 +3821,9 @@ function parse_XLWideString(data) {
return cchCharacters === 0 ? "" : data.read_shift(cchCharacters, 'dbcs');
}
function write_XLWideString(data, o) {
var _null = false; if(o == null) { _null = true; o = new_buf(4+2*data.length); }
var _null = false; if (o == null) { _null = true; o = new_buf(4 + 2 * data.length); }
o.write_shift(4, data.length);
if(data.length > 0) o.write_shift(0, data, 'dbcs');
if (data.length > 0) o.write_shift(0, data, 'dbcs');
return _null ? o.slice(0, o.l) : o;
}
@ -3833,7 +3838,7 @@ function parse_StrRun(data) {
return { ich: data.read_shift(2), ifnt: data.read_shift(2) };
}
function write_StrRun(run, o) {
if(!o) o = new_buf(4);
if (!o) o = new_buf(4);
o.write_shift(2, run.ich || 0);
o.write_shift(2, run.ifnt || 0);
return o;
@ -3846,13 +3851,13 @@ function parse_RichStr(data, length) {
var str = parse_XLWideString(data);
var rgsStrRun = [];
var z = ({ t: str, h: str });
if((flags & 1) !== 0) { /* fRichStr */
if ((flags & 1) !== 0) { /* fRichStr */
/* TODO: formatted string */
var dwSizeStrRun = data.read_shift(4);
for(var i = 0; i != dwSizeStrRun; ++i) rgsStrRun.push(parse_StrRun(data));
for (var i = 0; i != dwSizeStrRun; ++i) rgsStrRun.push(parse_StrRun(data));
z.r = rgsStrRun;
}
else z.r = [{ich:0, ifnt:0}];
else z.r = [{ ich: 0, ifnt: 0 }];
//if((flags & 2) !== 0) { /* fExtStr */
// /* TODO: phonetic string */
//}
@ -3861,8 +3866,8 @@ function parse_RichStr(data, length) {
}
function write_RichStr(str, o) {
/* TODO: formatted string */
var _null = false; if(o == null) { _null = true; o = new_buf(15+4*str.t.length); }
o.write_shift(1,0);
var _null = false; if (o == null) { _null = true; o = new_buf(15 + 4 * str.t.length); }
o.write_shift(1, 0);
write_XLWideString(str.t, o);
return _null ? o.slice(0, o.l) : o;
}
@ -3870,11 +3875,11 @@ function write_RichStr(str, o) {
var parse_BrtCommentText = parse_RichStr;
function write_BrtCommentText(str, o) {
/* TODO: formatted string */
var _null = false; if(o == null) { _null = true; o = new_buf(23+4*str.t.length); }
o.write_shift(1,1);
var _null = false; if (o == null) { _null = true; o = new_buf(23 + 4 * str.t.length); }
o.write_shift(1, 1);
write_XLWideString(str.t, o);
o.write_shift(4,1);
write_StrRun({ich:0,ifnt:0}, o);
o.write_shift(4, 1);
write_StrRun({ ich: 0, ifnt: 0 }, o);
return _null ? o.slice(0, o.l) : o;
}
@ -3882,12 +3887,12 @@ function write_BrtCommentText(str, o) {
function parse_XLSBCell(data) {
var col = data.read_shift(4);
var iStyleRef = data.read_shift(2);
iStyleRef += data.read_shift(1) <<16;
iStyleRef += data.read_shift(1) << 16;
data.l++; //var fPhShow = data.read_shift(1);
return { c:col, iStyleRef: iStyleRef };
return { c: col, iStyleRef: iStyleRef };
}
function write_XLSBCell(cell, o) {
if(o == null) o = new_buf(8);
if (o == null) o = new_buf(8);
o.write_shift(-4, cell.c);
o.write_shift(3, cell.iStyleRef || cell.s);
o.write_shift(1, 0); /* fPhShow */
@ -3905,9 +3910,9 @@ function parse_XLNullableWideString(data) {
return cchCharacters === 0 || cchCharacters === 0xFFFFFFFF ? "" : data.read_shift(cchCharacters, 'dbcs');
}
function write_XLNullableWideString(data, o) {
var _null = false; if(o == null) { _null = true; o = new_buf(127); }
var _null = false; if (o == null) { _null = true; o = new_buf(127); }
o.write_shift(4, data.length > 0 ? data.length : 0xFFFFFFFF);
if(data.length > 0) o.write_shift(0, data, 'dbcs');
if (data.length > 0) o.write_shift(0, data, 'dbcs');
return _null ? o.slice(0, o.l) : o;
}
@ -3922,26 +3927,26 @@ var write_RelID = write_XLNullableWideString;
/* [MS-XLS] 2.5.217 ; [MS-XLSB] 2.5.122 */
function parse_RkNumber(data) {
var b = data.slice(data.l, data.l+4);
var b = data.slice(data.l, data.l + 4);
var fX100 = (b[0] & 1), fInt = (b[0] & 2);
data.l+=4;
data.l += 4;
b[0] &= 0xFC; // b[0] &= ~3;
var RK = fInt === 0 ? __double([0,0,0,0,b[0],b[1],b[2],b[3]],0) : __readInt32LE(b,0)>>2;
return fX100 ? (RK/100) : RK;
var RK = fInt === 0 ? __double([0, 0, 0, 0, b[0], b[1], b[2], b[3]], 0) : __readInt32LE(b, 0) >> 2;
return fX100 ? (RK / 100) : RK;
}
function write_RkNumber(data, o) {
if(o == null) o = new_buf(4);
if (o == null) o = new_buf(4);
var fX100 = 0, fInt = 0, d100 = data * 100;
if((data == (data | 0)) && (data >= -(1<<29)) && (data < (1 << 29))) { fInt = 1; }
else if((d100 == (d100 | 0)) && (d100 >= -(1<<29)) && (d100 < (1 << 29))) { fInt = 1; fX100 = 1; }
if(fInt) o.write_shift(-4, ((fX100 ? d100 : data) << 2) + (fX100 + 2));
if ((data == (data | 0)) && (data >= -(1 << 29)) && (data < (1 << 29))) { fInt = 1; }
else if ((d100 == (d100 | 0)) && (d100 >= -(1 << 29)) && (d100 < (1 << 29))) { fInt = 1; fX100 = 1; }
if (fInt) o.write_shift(-4, ((fX100 ? d100 : data) << 2) + (fX100 + 2));
else throw new Error("unsupported RkNumber " + data); // TODO
}
/* [MS-XLSB] 2.5.117 RfX */
function parse_RfX(data ) {
var cell = ({s: {}, e: {}});
var cell = ({ s: {}, e: {} });
cell.s.r = data.read_shift(4);
cell.e.r = data.read_shift(4);
cell.s.c = data.read_shift(4);
@ -3949,7 +3954,7 @@ function parse_RfX(data ) {
return cell;
}
function write_RfX(r, o) {
if(!o) o = new_buf(16);
if (!o) o = new_buf(16);
o.write_shift(4, r.s.r);
o.write_shift(4, r.e.r);
o.write_shift(4, r.s.c);
@ -3986,20 +3991,6 @@ var write_UncheckedRfX = write_RfX;
function parse_Xnum(data) { return data.read_shift(8, 'f'); }
function write_Xnum(data, o) { return (o || new_buf(8)).write_shift(8, data, 'f'); }
/* [MS-XLSB] 2.5.97.2 */
var BErr = {
0x00: "#NULL!",
0x07: "#DIV/0!",
0x0F: "#VALUE!",
0x17: "#REF!",
0x1D: "#NAME?",
0x24: "#NUM!",
0x2A: "#N/A",
0x2B: "#GETTING_DATA",
0xFF: "#WTF?"
};
var RBErr = evert_num(BErr);
/* [MS-XLSB] 2.4.324 BrtColor */
function parse_BrtColor(data) {
var out = {};
@ -4015,13 +4006,13 @@ function parse_BrtColor(data) {
var bB = data.read_shift(1);
data.l++; //var bAlpha = data.read_shift(1);
switch(xColorType) {
switch (xColorType) {
case 0: out.auto = 1; break;
case 1:
out.index = index;
var icv = XLSIcv[index];
/* automatic pseudo index 81 */
if(icv) out.rgb = rgb2Hex(icv);
if (icv) out.rgb = rgb2Hex(icv);
break;
case 2:
/* if(!fValidRGB) throw new Error("invalid"); */
@ -4029,17 +4020,17 @@ function parse_BrtColor(data) {
break;
case 3: out.theme = index; break;
}
if(nTS != 0) out.tint = nTS > 0 ? nTS / 32767 : nTS / 32768;
if (nTS != 0) out.tint = nTS > 0 ? nTS / 32767 : nTS / 32768;
return out;
}
function write_BrtColor(color, o) {
if(!o) o = new_buf(8);
if(!color||color.auto) { o.write_shift(4, 0); o.write_shift(4, 0); return o; }
if(color.index != null) {
if (!o) o = new_buf(8);
if (!color || color.auto) { o.write_shift(4, 0); o.write_shift(4, 0); return o; }
if (color.index != null) {
o.write_shift(1, 0x02);
o.write_shift(1, color.index);
} else if(color.theme != null) {
} else if (color.theme != null) {
o.write_shift(1, 0x06);
o.write_shift(1, color.theme);
} else {
@ -4047,19 +4038,19 @@ function write_BrtColor(color, o) {
o.write_shift(1, 0);
}
var nTS = color.tint || 0;
if(nTS > 0) nTS *= 32767;
else if(nTS < 0) nTS *= 32768;
if (nTS > 0) nTS *= 32767;
else if (nTS < 0) nTS *= 32768;
o.write_shift(2, nTS);
if(!color.rgb || color.theme != null) {
if (!color.rgb || color.theme != null) {
o.write_shift(2, 0);
o.write_shift(1, 0);
o.write_shift(1, 0);
} else {
var rgb = (color.rgb || 'FFFFFF');
if(typeof rgb == 'number') rgb = ("000000" + rgb.toString(16)).slice(-6);
o.write_shift(1, parseInt(rgb.slice(0,2),16));
o.write_shift(1, parseInt(rgb.slice(2,4),16));
o.write_shift(1, parseInt(rgb.slice(4,6),16));
if (typeof rgb == 'number') rgb = ("000000" + rgb.toString(16)).slice(-6);
o.write_shift(1, parseInt(rgb.slice(0, 2), 16));
o.write_shift(1, parseInt(rgb.slice(2, 4), 16));
o.write_shift(1, parseInt(rgb.slice(4, 6), 16));
o.write_shift(1, 0xFF);
}
return o;
@ -4082,14 +4073,14 @@ function parse_FontFlags(data) {
return out;
}
function write_FontFlags(font, o) {
if(!o) o = new_buf(2);
if (!o) o = new_buf(2);
var grbit =
(font.italic ? 0x02 : 0) |
(font.strike ? 0x08 : 0) |
(font.outline ? 0x10 : 0) |
(font.shadow ? 0x20 : 0) |
(font.italic ? 0x02 : 0) |
(font.strike ? 0x08 : 0) |
(font.outline ? 0x10 : 0) |
(font.shadow ? 0x20 : 0) |
(font.condense ? 0x40 : 0) |
(font.extend ? 0x80 : 0);
(font.extend ? 0x80 : 0);
o.write_shift(1, grbit);
o.write_shift(1, 0);
return o;
@ -4098,13 +4089,13 @@ function write_FontFlags(font, o) {
/* [MS-OLEDS] 2.3.1 and 2.3.2 */
function parse_ClipboardFormatOrString(o, w) {
// $FlowIgnore
var ClipFmt = {2:"BITMAP",3:"METAFILEPICT",8:"DIB",14:"ENHMETAFILE"};
var ClipFmt = { 2: "BITMAP", 3: "METAFILEPICT", 8: "DIB", 14: "ENHMETAFILE" };
var m = o.read_shift(4);
switch(m) {
switch (m) {
case 0x00000000: return "";
case 0xffffffff: case 0xfffffffe: return ClipFmt[o.read_shift(4)]||"";
case 0xffffffff: case 0xfffffffe: return ClipFmt[o.read_shift(4)] || "";
}
if(m > 0x190) throw new Error("Unsupported Clipboard: " + m.toString(16));
if (m > 0x190) throw new Error("Unsupported Clipboard: " + m.toString(16));
o.l -= 4;
return o.read_shift(0, w == 1 ? "lpstr" : "lpwstr");
}
@ -4114,43 +4105,43 @@ function parse_ClipboardFormatOrUnicodeString(o) { return parse_ClipboardFormatO
/* [MS-OLEPS] 2.2 PropertyType */
//var VT_EMPTY = 0x0000;
//var VT_NULL = 0x0001;
var VT_I2 = 0x0002;
var VT_I4 = 0x0003;
var VT_I2 = 0x0002;
var VT_I4 = 0x0003;
//var VT_R4 = 0x0004;
//var VT_R8 = 0x0005;
//var VT_CY = 0x0006;
//var VT_DATE = 0x0007;
//var VT_BSTR = 0x0008;
//var VT_ERROR = 0x000A;
var VT_BOOL = 0x000B;
var VT_VARIANT = 0x000C;
var VT_BOOL = 0x000B;
var VT_VARIANT = 0x000C;
//var VT_DECIMAL = 0x000E;
//var VT_I1 = 0x0010;
//var VT_UI1 = 0x0011;
//var VT_UI2 = 0x0012;
var VT_UI4 = 0x0013;
var VT_UI4 = 0x0013;
//var VT_I8 = 0x0014;
//var VT_UI8 = 0x0015;
//var VT_INT = 0x0016;
//var VT_UINT = 0x0017;
var VT_LPSTR = 0x001E;
var VT_LPSTR = 0x001E;
//var VT_LPWSTR = 0x001F;
var VT_FILETIME = 0x0040;
var VT_BLOB = 0x0041;
var VT_BLOB = 0x0041;
//var VT_STREAM = 0x0042;
//var VT_STORAGE = 0x0043;
//var VT_STREAMED_Object = 0x0044;
//var VT_STORED_Object = 0x0045;
//var VT_BLOB_Object = 0x0046;
var VT_CF = 0x0047;
var VT_CF = 0x0047;
//var VT_CLSID = 0x0048;
//var VT_VERSIONED_STREAM = 0x0049;
var VT_VECTOR = 0x1000;
var VT_VECTOR = 0x1000;
//var VT_ARRAY = 0x2000;
var VT_STRING = 0x0050; // 2.3.3.1.11 VtString
var VT_USTR = 0x0051; // 2.3.3.1.12 VtUnalignedString
var VT_CUSTOM = [VT_STRING, VT_USTR];
var VT_STRING = 0x0050; // 2.3.3.1.11 VtString
var VT_USTR = 0x0051; // 2.3.3.1.12 VtUnalignedString
var VT_CUSTOM = [VT_STRING, VT_USTR];
/* [MS-OSHARED] 2.3.3.2.2.1 Document Summary Information PIDDSI */
var DocSummaryPIDDSI = {
@ -4213,9 +4204,9 @@ var SpecialProperties = {
0x72627262: {}
};
(function() {
for(var y in SpecialProperties) if(Object.prototype.hasOwnProperty.call(SpecialProperties, y))
DocSummaryPIDDSI[y] = SummaryPIDSI[y] = SpecialProperties[y];
(function () {
for (var y in SpecialProperties) if (Object.prototype.hasOwnProperty.call(SpecialProperties, y))
DocSummaryPIDDSI[y] = SummaryPIDSI[y] = SpecialProperties[y];
})();
var DocSummaryRE = evert_key(DocSummaryPIDDSI, "n");
@ -4298,7 +4289,7 @@ var XLSFillPattern = [
'gray0625'
];
function rgbify(arr) { return arr.map(function(x) { return [(x>>16)&255,(x>>8)&255,x&255]; }); }
function rgbify(arr) { return arr.map(function (x) { return [(x >> 16) & 255, (x >> 8) & 255, x & 255]; }); }
/* [MS-XLS] 2.5.161 */
/* [MS-XLSB] 2.5.75 Icv */
@ -4395,7 +4386,20 @@ var _XLSIcv = rgbify([
0x000000 /* 0x51 icvInfoText ?? */
]);
var XLSIcv = dup(_XLSIcv);
/* Parts enumerated in OPC spec, MS-XLSB and MS-XLSX */
/* [MS-XLSB] 2.5.97.2 */
var BErr = {
0x00: "#NULL!",
0x07: "#DIV/0!",
0x0F: "#VALUE!",
0x17: "#REF!",
0x1D: "#NAME?",
0x24: "#NUM!",
0x2A: "#N/A",
0x2B: "#GETTING_DATA",
0xFF: "#WTF?"
};
var RBErr = evert_num(BErr);/* Parts enumerated in OPC spec, MS-XLSB and MS-XLSX */
/* 12.3 Part Summary <SpreadsheetML> */
/* 14.2 Part Summary <DrawingML> */
/* [MS-XLSX] 2.1 Part Enumerations ; [MS-XLSB] 2.1.7 Part Enumeration */
@ -11280,7 +11284,7 @@ var PtgBinOp = {
};
// List of invalid characters needs to be tested further
var quoteCharacters = new RegExp(/[^\w\u4E00-\u9FFF\u3040-\u30FF]/)
var quoteCharacters = new RegExp(/[^\w\u4E00-\u9FFF\u3040-\u30FF]/);
function formula_quote_sheet_name(sname, opts) {
if(!sname && !(opts && opts.biff <= 5 && opts.biff >= 2)) throw new Error("empty sheet name");
if (quoteCharacters.test(sname)) return "'" + sname + "'";
@ -15037,7 +15041,7 @@ function parse_wb_xml(data, opts) {
default: wb.WBProps[w[0]] = y[w[0]];
}
});
if(y.codeName) wb.WBProps.CodeName = y.codeName;
if(y.codeName) wb.WBProps.CodeName = utf8read(y.codeName);
break;
case '</workbookPr>': break;
@ -19555,16 +19559,32 @@ var HTML_ = (function() {
};
})();
function parse_dom_table(table, _opts) {
function sheet_add_dom(ws, table, _opts) {
var opts = _opts || {};
if(DENSE != null) opts.dense = DENSE;
var ws = opts.dense ? ([]) : ({});
var or_R = 0, or_C = 0;
if(opts.origin != null) {
if(typeof opts.origin == 'number') or_R = opts.origin;
else {
var _origin = typeof opts.origin == "string" ? decode_cell(opts.origin) : opts.origin;
or_R = _origin.r; or_C = _origin.c;
}
}
var rows = table.getElementsByTagName('tr');
var sheetRows = opts.sheetRows || 10000000;
var range = {s:{r:0,c:0},e:{r:0,c:0}};
var sheetRows = Math.min(opts.sheetRows||10000000, rows.length);
var range = {s:{r:0,c:0},e:{r:or_R,c:or_C}};
if(ws["!ref"]) {
var _range = decode_range(ws["!ref"]);
range.s.r = Math.min(range.s.r, _range.s.r);
range.s.c = Math.min(range.s.c, _range.s.c);
range.e.r = Math.max(range.e.r, _range.e.r);
range.e.c = Math.max(range.e.c, _range.e.c);
if(or_R == -1) range.e.r = or_R = _range.e.r + 1;
}
var merges = [], midx = 0;
var rowinfo = [];
var rowinfo = ws["!rows"] || (ws["!rows"] = []);
var _R = 0, R = 0, _C = 0, C = 0, RS = 0, CS = 0;
if(!ws["!cols"]) ws['!cols'] = [];
for(; _R < rows.length && R < sheetRows; ++_R) {
var row = rows[_R];
if (is_dom_element_hidden(row)) {
@ -19579,11 +19599,11 @@ function parse_dom_table(table, _opts) {
var z = elt.getAttribute('z');
for(midx = 0; midx < merges.length; ++midx) {
var m = merges[midx];
if(m.s.c == C && m.s.r <= R && R <= m.e.r) { C = m.e.c+1; midx = -1; }
if(m.s.c == C + or_C && m.s.r < R + or_R && R + or_R <= m.e.r) { C = m.e.c+1 - or_C; midx = -1; }
}
/* TODO: figure out how to extract nonstandard mso- style */
CS = +elt.getAttribute("colspan") || 1;
if((RS = +elt.getAttribute("rowspan"))>0 || CS>1) merges.push({s:{r:R,c:C},e:{r:R + (RS||1) - 1, c:C + CS - 1}});
if( ((RS = (+elt.getAttribute("rowspan") || 1)))>1 || CS>1) merges.push({s:{r:R + or_R,c:C + or_C},e:{r:R + or_R + (RS||1) - 1, c:C + or_C + (CS||1) - 1}});
var o = {t:'s', v:v};
var _t = elt.getAttribute("t") || "";
if(v != null) {
@ -19599,21 +19619,26 @@ function parse_dom_table(table, _opts) {
}
}
if(o.z === undefined && z != null) o.z = z;
if(opts.dense) { if(!ws[R]) ws[R] = []; ws[R][C] = o;}
else ws[encode_cell({c:C, r:R})] = o;
if(range.e.c < C) range.e.c = C;
if(opts.dense) { if(!ws[R + or_R]) ws[R + or_R] = []; ws[R + or_R][C + or_C] = o; }
else ws[encode_cell({c:C + or_C, r:R + or_R})] = o;
if(range.e.c < C + or_C) range.e.c = C + or_C;
C += CS;
}
++R;
}
if(merges.length) ws['!merges'] = merges;
if(rowinfo.length) ws['!rows'] = rowinfo;
range.e.r = R - 1;
if(merges.length) ws['!merges'] = (ws["!merges"] || []).concat(merges);
range.e.r = Math.max(range.e.r, R - 1 + or_R);
ws['!ref'] = encode_range(range);
if(R >= sheetRows) ws['!fullref'] = encode_range((range.e.r = rows.length-_R+R-1,range)); // We can count the real number of rows to parse but we don't to improve the performance
if(R >= sheetRows) ws['!fullref'] = encode_range((range.e.r = rows.length-_R+R-1 + or_R,range)); // We can count the real number of rows to parse but we don't to improve the performance
return ws;
}
function parse_dom_table(table, _opts) {
var opts = _opts || {};
var ws = opts.dense ? ([]) : ({});
return sheet_add_dom(ws, table, _opts);
}
function table_to_book(table, opts) {
return sheet_to_workbook(parse_dom_table(table, opts), opts);
}
@ -21302,6 +21327,7 @@ function sheet_to_formulae(sheet) {
}
function sheet_add_json(_ws, js, opts) {
if(!js.length) return _ws;
var o = opts || {};
var offset = +!o.skipHeader;
var ws = _ws || ({});
@ -21320,6 +21346,8 @@ function sheet_add_json(_ws, js, opts) {
range.e.c = Math.max(range.e.c, _range.e.c);
range.e.r = Math.max(range.e.r, _range.e.r);
if(_R == -1) { _R = _range.e.r + 1; range.e.r = _R + js.length - 1 + offset; }
} else {
if(_R == -1) { _R = 0; range.e.r = js.length - 1 + offset; }
}
var hdr = o.header || [], C = 0;
@ -21377,6 +21405,7 @@ var utils = {
make_formulae: sheet_to_formulae,
sheet_add_aoa: sheet_add_aoa,
sheet_add_json: sheet_add_json,
sheet_add_dom: sheet_add_dom,
aoa_to_sheet: aoa_to_sheet,
json_to_sheet: json_to_sheet,
table_to_sheet: parse_dom_table,