2014-02-13 06:22:42 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.726 BrtRowHdr */
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_BrtRowHdr(data, length) {
|
2017-04-28 07:28:03 +00:00
|
|
|
var z = ({}/*:any*/);
|
|
|
|
var tgt = data.l + length;
|
2014-01-28 16:38:02 +00:00
|
|
|
z.r = data.read_shift(4);
|
2017-04-28 07:28:03 +00:00
|
|
|
data.l += 4; // TODO: ixfe
|
|
|
|
var miyRw = data.read_shift(2);
|
|
|
|
data.l += 1; // TODO: top/bot padding
|
|
|
|
var flags = data.read_shift(1);
|
|
|
|
data.l = tgt;
|
2017-07-09 17:37:45 +00:00
|
|
|
if(flags & 0x07) z.level = flags & 0x07;
|
2017-04-28 07:28:03 +00:00
|
|
|
if(flags & 0x10) z.hidden = true;
|
|
|
|
if(flags & 0x20) z.hpt = miyRw / 20;
|
2014-01-28 16:38:02 +00:00
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtRowHdr(R/*:number*/, range, ws) {
|
|
|
|
var o = new_buf(17+8*16);
|
2017-04-28 07:28:03 +00:00
|
|
|
var row = (ws['!rows']||[])[R]||{};
|
2017-02-03 20:50:45 +00:00
|
|
|
o.write_shift(4, R);
|
|
|
|
|
2017-04-28 07:28:03 +00:00
|
|
|
o.write_shift(4, 0); /* TODO: ixfe */
|
|
|
|
|
|
|
|
var miyRw = 0x0140;
|
|
|
|
if(row.hpx) miyRw = px2pt(row.hpx) * 20;
|
|
|
|
else if(row.hpt) miyRw = row.hpt * 20;
|
|
|
|
o.write_shift(2, miyRw);
|
|
|
|
|
|
|
|
o.write_shift(1, 0); /* top/bot padding */
|
|
|
|
|
|
|
|
var flags = 0x0;
|
2017-07-09 17:37:45 +00:00
|
|
|
if(row.level) flags |= row.level;
|
2017-04-28 07:28:03 +00:00
|
|
|
if(row.hidden) flags |= 0x10;
|
|
|
|
if(row.hpx || row.hpt) flags |= 0x20;
|
|
|
|
o.write_shift(1, flags);
|
|
|
|
|
|
|
|
o.write_shift(1, 0); /* phonetic guide */
|
2017-02-03 20:50:45 +00:00
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.8 BrtColSpan explains the mechanism */
|
|
|
|
var ncolspan = 0, lcs = o.l;
|
|
|
|
o.l += 4;
|
|
|
|
|
|
|
|
var caddr = {r:R, c:0};
|
|
|
|
for(var i = 0; i < 16; ++i) {
|
2018-02-08 18:21:39 +00:00
|
|
|
if((range.s.c > ((i+1) << 10)) || (range.e.c < (i << 10))) continue;
|
2017-02-03 20:50:45 +00:00
|
|
|
var first = -1, last = -1;
|
|
|
|
for(var j = (i<<10); j < ((i+1)<<10); ++j) {
|
|
|
|
caddr.c = j;
|
2017-04-08 06:55:35 +00:00
|
|
|
var cell = Array.isArray(ws) ? (ws[caddr.r]||[])[caddr.c] : ws[encode_cell(caddr)];
|
|
|
|
if(cell) { if(first < 0) first = j; last = j; }
|
2017-02-03 20:50:45 +00:00
|
|
|
}
|
|
|
|
if(first < 0) continue;
|
|
|
|
++ncolspan;
|
|
|
|
o.write_shift(4, first);
|
|
|
|
o.write_shift(4, last);
|
|
|
|
}
|
|
|
|
|
|
|
|
var l = o.l;
|
|
|
|
o.l = lcs;
|
|
|
|
o.write_shift(4, ncolspan);
|
|
|
|
o.l = l;
|
|
|
|
|
|
|
|
return o.length > o.l ? o.slice(0, o.l) : o;
|
|
|
|
}
|
|
|
|
function write_row_header(ba, ws, range, R) {
|
|
|
|
var o = write_BrtRowHdr(R, range, ws);
|
2018-02-08 18:21:39 +00:00
|
|
|
if((o.length > 17) || (ws['!rows']||[])[R]) write_record(ba, 'BrtRowHdr', o);
|
2017-02-03 20:50:45 +00:00
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.820 BrtWsDim */
|
2014-01-28 16:38:02 +00:00
|
|
|
var parse_BrtWsDim = parse_UncheckedRfX;
|
2014-05-29 22:30:03 +00:00
|
|
|
var write_BrtWsDim = write_UncheckedRfX;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.821 BrtWsFmtInfo */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtWsFmtInfo(/*::data, length*/) {
|
2017-07-27 20:07:51 +00:00
|
|
|
}
|
2017-05-09 18:07:57 +00:00
|
|
|
//function write_BrtWsFmtInfo(ws, o) { }
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.823 BrtWsProp */
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_BrtWsProp(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
var z = {};
|
|
|
|
/* TODO: pull flags */
|
|
|
|
data.l += 19;
|
2015-04-02 20:32:22 +00:00
|
|
|
z.name = parse_XLSBCodeName(data, length - 19);
|
2014-01-28 16:38:02 +00:00
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-03-31 00:47:35 +00:00
|
|
|
function write_BrtWsProp(str, o) {
|
2017-05-09 18:07:57 +00:00
|
|
|
if(o == null) o = new_buf(84+4*str.length);
|
|
|
|
for(var i = 0; i < 3; ++i) o.write_shift(1,0);
|
|
|
|
write_BrtColor({auto:1}, o);
|
2017-03-31 00:47:35 +00:00
|
|
|
o.write_shift(-4,-1);
|
|
|
|
o.write_shift(-4,-1);
|
|
|
|
write_XLSBCodeName(str, o);
|
|
|
|
return o.slice(0, o.l);
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.306 BrtCellBlank */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellBlank(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2014-03-29 22:53:15 +00:00
|
|
|
return [cell];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtCellBlank(cell, ncell, o) {
|
2014-07-28 13:22:32 +00:00
|
|
|
if(o == null) o = new_buf(8);
|
2017-02-03 20:50:45 +00:00
|
|
|
return write_XLSBCell(ncell, o);
|
2014-07-28 13:22:32 +00:00
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function parse_BrtShortBlank(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
return [cell];
|
|
|
|
}
|
|
|
|
function write_BrtShortBlank(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(4);
|
|
|
|
return write_XLSBShortCell(ncell, o);
|
|
|
|
}
|
2014-02-13 06:22:42 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.307 BrtCellBool */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellBool(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2014-01-28 16:38:02 +00:00
|
|
|
var fBool = data.read_shift(1);
|
|
|
|
return [cell, fBool, 'b'];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtCellBool(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(9);
|
|
|
|
write_XLSBCell(ncell, o);
|
|
|
|
o.write_shift(1, cell.v ? 1 : 0);
|
|
|
|
return o;
|
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function parse_BrtShortBool(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
var fBool = data.read_shift(1);
|
|
|
|
return [cell, fBool, 'b'];
|
|
|
|
}
|
|
|
|
function write_BrtShortBool(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(5);
|
|
|
|
write_XLSBShortCell(ncell, o);
|
|
|
|
o.write_shift(1, cell.v ? 1 : 0);
|
|
|
|
return o;
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.308 BrtCellError */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellError(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2017-02-03 20:50:45 +00:00
|
|
|
var bError = data.read_shift(1);
|
|
|
|
return [cell, bError, 'e'];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function write_BrtCellError(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(9);
|
|
|
|
write_XLSBCell(ncell, o);
|
|
|
|
o.write_shift(1, cell.v);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
function parse_BrtShortError(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
var bError = data.read_shift(1);
|
|
|
|
return [cell, bError, 'e'];
|
|
|
|
}
|
|
|
|
function write_BrtShortError(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(8);
|
|
|
|
write_XLSBShortCell(ncell, o);
|
|
|
|
o.write_shift(1, cell.v);
|
|
|
|
o.write_shift(2, 0);
|
|
|
|
o.write_shift(1, 0);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.311 BrtCellIsst */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellIsst(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2014-01-28 16:38:02 +00:00
|
|
|
var isst = data.read_shift(4);
|
|
|
|
return [cell, isst, 's'];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtCellIsst(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(12);
|
|
|
|
write_XLSBCell(ncell, o);
|
|
|
|
o.write_shift(4, ncell.v);
|
|
|
|
return o;
|
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function parse_BrtShortIsst(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
var isst = data.read_shift(4);
|
|
|
|
return [cell, isst, 's'];
|
|
|
|
}
|
|
|
|
function write_BrtShortIsst(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(8);
|
|
|
|
write_XLSBShortCell(ncell, o);
|
|
|
|
o.write_shift(4, ncell.v);
|
|
|
|
return o;
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.313 BrtCellReal */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellReal(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2014-01-28 16:38:02 +00:00
|
|
|
var value = parse_Xnum(data);
|
|
|
|
return [cell, value, 'n'];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtCellReal(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(16);
|
|
|
|
write_XLSBCell(ncell, o);
|
|
|
|
write_Xnum(cell.v, o);
|
|
|
|
return o;
|
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function parse_BrtShortReal(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
var value = parse_Xnum(data);
|
|
|
|
return [cell, value, 'n'];
|
|
|
|
}
|
|
|
|
function write_BrtShortReal(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(12);
|
|
|
|
write_XLSBShortCell(ncell, o);
|
|
|
|
write_Xnum(cell.v, o);
|
|
|
|
return o;
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.314 BrtCellRk */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellRk(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2014-01-28 16:38:02 +00:00
|
|
|
var value = parse_RkNumber(data);
|
|
|
|
return [cell, value, 'n'];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtCellRk(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(12);
|
|
|
|
write_XLSBCell(ncell, o);
|
|
|
|
write_RkNumber(cell.v, o);
|
|
|
|
return o;
|
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function parse_BrtShortRk(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
var value = parse_RkNumber(data);
|
|
|
|
return [cell, value, 'n'];
|
|
|
|
}
|
|
|
|
function write_BrtShortRk(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(8);
|
|
|
|
write_XLSBShortCell(ncell, o);
|
|
|
|
write_RkNumber(cell.v, o);
|
|
|
|
return o;
|
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.317 BrtCellSt */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtCellSt(data) {
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2014-01-28 16:38:02 +00:00
|
|
|
var value = parse_XLWideString(data);
|
|
|
|
return [cell, value, 'str'];
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-02-03 20:50:45 +00:00
|
|
|
function write_BrtCellSt(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(12 + 4 * cell.v.length);
|
|
|
|
write_XLSBCell(ncell, o);
|
|
|
|
write_XLWideString(cell.v, o);
|
|
|
|
return o.length > o.l ? o.slice(0, o.l) : o;
|
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
function parse_BrtShortSt(data) {
|
|
|
|
var cell = parse_XLSBShortCell(data);
|
|
|
|
var value = parse_XLWideString(data);
|
|
|
|
return [cell, value, 'str'];
|
|
|
|
}
|
|
|
|
function write_BrtShortSt(cell, ncell, o) {
|
|
|
|
if(o == null) o = new_buf(8 + 4 * cell.v.length);
|
|
|
|
write_XLSBShortCell(ncell, o);
|
|
|
|
write_XLWideString(cell.v, o);
|
|
|
|
return o.length > o.l ? o.slice(0, o.l) : o;
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.653 BrtFmlaBool */
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_BrtFmlaBool(data, length, opts) {
|
2017-02-19 20:36:32 +00:00
|
|
|
var end = data.l + length;
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2017-02-19 20:36:32 +00:00
|
|
|
cell.r = opts['!row'];
|
2014-02-12 06:09:42 +00:00
|
|
|
var value = data.read_shift(1);
|
2014-02-13 06:22:42 +00:00
|
|
|
var o = [cell, value, 'b'];
|
|
|
|
if(opts.cellFormula) {
|
2017-02-19 20:36:32 +00:00
|
|
|
data.l += 2;
|
|
|
|
var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
|
|
|
|
o[3] = stringify_formula(formula, null/*range*/, cell, opts.supbooks, opts);/* TODO */
|
2014-02-13 06:22:42 +00:00
|
|
|
}
|
2017-02-19 20:36:32 +00:00
|
|
|
else data.l = end;
|
2014-02-13 06:22:42 +00:00
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.654 BrtFmlaError */
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_BrtFmlaError(data, length, opts) {
|
2017-02-19 20:36:32 +00:00
|
|
|
var end = data.l + length;
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2017-02-19 20:36:32 +00:00
|
|
|
cell.r = opts['!row'];
|
2014-02-13 06:22:42 +00:00
|
|
|
var value = data.read_shift(1);
|
|
|
|
var o = [cell, value, 'e'];
|
|
|
|
if(opts.cellFormula) {
|
2017-02-19 20:36:32 +00:00
|
|
|
data.l += 2;
|
|
|
|
var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
|
|
|
|
o[3] = stringify_formula(formula, null/*range*/, cell, opts.supbooks, opts);/* TODO */
|
2014-02-13 06:22:42 +00:00
|
|
|
}
|
2017-02-19 20:36:32 +00:00
|
|
|
else data.l = end;
|
2014-02-13 06:22:42 +00:00
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.655 BrtFmlaNum */
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_BrtFmlaNum(data, length, opts) {
|
2017-02-19 20:36:32 +00:00
|
|
|
var end = data.l + length;
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2017-02-19 20:36:32 +00:00
|
|
|
cell.r = opts['!row'];
|
2014-01-28 16:38:02 +00:00
|
|
|
var value = parse_Xnum(data);
|
2014-02-13 06:22:42 +00:00
|
|
|
var o = [cell, value, 'n'];
|
|
|
|
if(opts.cellFormula) {
|
2017-02-19 20:36:32 +00:00
|
|
|
data.l += 2;
|
|
|
|
var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
|
|
|
|
o[3] = stringify_formula(formula, null/*range*/, cell, opts.supbooks, opts);/* TODO */
|
2014-02-13 06:22:42 +00:00
|
|
|
}
|
2017-02-19 20:36:32 +00:00
|
|
|
else data.l = end;
|
2014-02-13 06:22:42 +00:00
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.656 BrtFmlaString */
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_BrtFmlaString(data, length, opts) {
|
2017-02-19 20:36:32 +00:00
|
|
|
var end = data.l + length;
|
2015-04-02 20:32:22 +00:00
|
|
|
var cell = parse_XLSBCell(data);
|
2017-02-19 20:36:32 +00:00
|
|
|
cell.r = opts['!row'];
|
2014-02-12 06:09:42 +00:00
|
|
|
var value = parse_XLWideString(data);
|
2014-02-13 06:22:42 +00:00
|
|
|
var o = [cell, value, 'str'];
|
|
|
|
if(opts.cellFormula) {
|
2017-02-19 20:36:32 +00:00
|
|
|
data.l += 2;
|
|
|
|
var formula = parse_XLSBCellParsedFormula(data, end - data.l, opts);
|
|
|
|
o[3] = stringify_formula(formula, null/*range*/, cell, opts.supbooks, opts);/* TODO */
|
2014-02-13 06:22:42 +00:00
|
|
|
}
|
2017-02-19 20:36:32 +00:00
|
|
|
else data.l = end;
|
2014-02-13 06:22:42 +00:00
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.682 BrtMergeCell */
|
2014-03-23 21:30:00 +00:00
|
|
|
var parse_BrtMergeCell = parse_UncheckedRfX;
|
2017-03-16 01:17:24 +00:00
|
|
|
var write_BrtMergeCell = write_UncheckedRfX;
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.107 BrtBeginMergeCells */
|
2017-03-16 01:17:24 +00:00
|
|
|
function write_BrtBeginMergeCells(cnt, o) {
|
|
|
|
if(o == null) o = new_buf(4);
|
|
|
|
o.write_shift(4, cnt);
|
|
|
|
return o;
|
|
|
|
}
|
2014-03-23 21:30:00 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.662 BrtHLink */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtHLink(data, length/*::, opts*/) {
|
2014-04-15 09:04:03 +00:00
|
|
|
var end = data.l + length;
|
|
|
|
var rfx = parse_UncheckedRfX(data, 16);
|
|
|
|
var relId = parse_XLNullableWideString(data);
|
|
|
|
var loc = parse_XLWideString(data);
|
|
|
|
var tooltip = parse_XLWideString(data);
|
|
|
|
var display = parse_XLWideString(data);
|
|
|
|
data.l = end;
|
2017-10-17 00:14:32 +00:00
|
|
|
var o = ({rfx:rfx, relId:relId, loc:loc, display:display}/*:any*/);
|
|
|
|
if(tooltip) o.Tooltip = tooltip;
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-12-15 01:18:40 +00:00
|
|
|
function write_BrtHLink(l, rId) {
|
|
|
|
var o = new_buf(50+4*(l[1].Target.length + (l[1].Tooltip || "").length));
|
2017-03-31 00:47:35 +00:00
|
|
|
write_UncheckedRfX({s:decode_cell(l[0]), e:decode_cell(l[0])}, o);
|
|
|
|
write_RelID("rId" + rId, o);
|
|
|
|
var locidx = l[1].Target.indexOf("#");
|
2018-01-11 08:01:25 +00:00
|
|
|
var loc = locidx == -1 ? "" : l[1].Target.slice(locidx+1);
|
2017-05-09 18:07:57 +00:00
|
|
|
write_XLWideString(loc || "", o);
|
2017-03-31 00:47:35 +00:00
|
|
|
write_XLWideString(l[1].Tooltip || "", o);
|
|
|
|
write_XLWideString("", o);
|
|
|
|
return o.slice(0, o.l);
|
|
|
|
}
|
2014-04-15 09:04:03 +00:00
|
|
|
|
2019-11-15 01:46:49 +00:00
|
|
|
/* [MS-XLSB] 2.4.692 BrtPane */
|
|
|
|
function parse_BrtPane(/*data, length, opts*/) {
|
|
|
|
}
|
|
|
|
|
2017-02-19 20:36:32 +00:00
|
|
|
/* [MS-XLSB] 2.4.6 BrtArrFmla */
|
|
|
|
function parse_BrtArrFmla(data, length, opts) {
|
|
|
|
var end = data.l + length;
|
|
|
|
var rfx = parse_RfX(data, 16);
|
|
|
|
var fAlwaysCalc = data.read_shift(1);
|
2017-03-12 18:02:43 +00:00
|
|
|
var o = [rfx]; o[2] = fAlwaysCalc;
|
2017-02-19 20:36:32 +00:00
|
|
|
if(opts.cellFormula) {
|
|
|
|
var formula = parse_XLSBArrayParsedFormula(data, end - data.l, opts);
|
|
|
|
o[1] = formula;
|
|
|
|
} else data.l = end;
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.750 BrtShrFmla */
|
2017-02-19 20:36:32 +00:00
|
|
|
function parse_BrtShrFmla(data, length, opts) {
|
|
|
|
var end = data.l + length;
|
|
|
|
var rfx = parse_UncheckedRfX(data, 16);
|
2017-03-12 18:02:43 +00:00
|
|
|
var o = [rfx];
|
2017-02-19 20:36:32 +00:00
|
|
|
if(opts.cellFormula) {
|
|
|
|
var formula = parse_XLSBSharedParsedFormula(data, end - data.l, opts);
|
|
|
|
o[1] = formula;
|
|
|
|
data.l = end;
|
|
|
|
} else data.l = end;
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2017-03-28 22:03:03 +00:00
|
|
|
/* [MS-XLSB] 2.4.323 BrtColInfo */
|
|
|
|
/* TODO: once XLS ColInfo is set, combine the functions */
|
|
|
|
function write_BrtColInfo(C/*:number*/, col, o) {
|
|
|
|
if(o == null) o = new_buf(18);
|
|
|
|
var p = col_obj_w(C, col);
|
|
|
|
o.write_shift(-4, C);
|
|
|
|
o.write_shift(-4, C);
|
2017-04-28 07:28:03 +00:00
|
|
|
o.write_shift(4, (p.width || 10) * 256);
|
2017-03-28 22:03:03 +00:00
|
|
|
o.write_shift(4, 0/*ixfe*/); // style
|
2017-04-28 07:28:03 +00:00
|
|
|
var flags = 0;
|
|
|
|
if(col.hidden) flags |= 0x01;
|
|
|
|
if(typeof p.width == 'number') flags |= 0x02;
|
2019-11-01 03:09:14 +00:00
|
|
|
if(col.level) flags |= (col.level << 8);
|
|
|
|
o.write_shift(2, flags); // bit flag
|
2017-03-28 22:03:03 +00:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.678 BrtMargins */
|
2017-10-17 00:14:32 +00:00
|
|
|
var BrtMarginKeys = ["left","right","top","bottom","header","footer"];
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtMargins(data/*::, length, opts*/)/*:Margins*/ {
|
2017-10-17 00:14:32 +00:00
|
|
|
var margins = ({}/*:any*/);
|
|
|
|
BrtMarginKeys.forEach(function(k) { margins[k] = parse_Xnum(data, 8); });
|
|
|
|
return margins;
|
|
|
|
}
|
|
|
|
function write_BrtMargins(margins/*:Margins*/, o) {
|
2017-04-13 01:29:38 +00:00
|
|
|
if(o == null) o = new_buf(6*8);
|
|
|
|
default_margins(margins);
|
2017-10-17 00:14:32 +00:00
|
|
|
BrtMarginKeys.forEach(function(k) { write_Xnum((margins/*:any*/)[k], o); });
|
2017-04-13 01:29:38 +00:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.299 BrtBeginWsView */
|
2018-01-23 09:07:51 +00:00
|
|
|
function parse_BrtBeginWsView(data/*::, length, opts*/) {
|
2017-12-30 05:40:35 +00:00
|
|
|
var f = data.read_shift(2);
|
|
|
|
data.l += 28;
|
|
|
|
return { RTL: f & 0x20 };
|
|
|
|
}
|
2017-12-25 02:25:03 +00:00
|
|
|
function write_BrtBeginWsView(ws, Workbook, o) {
|
2017-04-28 07:28:03 +00:00
|
|
|
if(o == null) o = new_buf(30);
|
2017-12-25 02:25:03 +00:00
|
|
|
var f = 0x39c;
|
|
|
|
if((((Workbook||{}).Views||[])[0]||{}).RTL) f |= 0x20;
|
|
|
|
o.write_shift(2, f); // bit flag
|
2017-04-28 07:28:03 +00:00
|
|
|
o.write_shift(4, 0);
|
|
|
|
o.write_shift(4, 0); // view first row
|
|
|
|
o.write_shift(4, 0); // view first col
|
|
|
|
o.write_shift(1, 0); // gridline color ICV
|
|
|
|
o.write_shift(1, 0);
|
|
|
|
o.write_shift(2, 0);
|
|
|
|
o.write_shift(2, 100); // zoom scale
|
|
|
|
o.write_shift(2, 0);
|
|
|
|
o.write_shift(2, 0);
|
|
|
|
o.write_shift(2, 0);
|
|
|
|
o.write_shift(4, 0); // workbook view id
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
/* [MS-XLSB] 2.4.309 BrtCellIgnoreEC */
|
|
|
|
function write_BrtCellIgnoreEC(ref) {
|
|
|
|
var o = new_buf(24);
|
|
|
|
o.write_shift(4, 4);
|
|
|
|
o.write_shift(4, 1);
|
|
|
|
write_UncheckedRfX(ref, o);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.748 BrtSheetProtection */
|
2017-04-10 05:10:54 +00:00
|
|
|
function write_BrtSheetProtection(sp, o) {
|
|
|
|
if(o == null) o = new_buf(16*4+2);
|
|
|
|
o.write_shift(2, sp.password ? crypto_CreatePasswordVerifier_Method1(sp.password) : 0);
|
|
|
|
o.write_shift(4, 1); // this record should not be written if no protection
|
|
|
|
[
|
|
|
|
["objects", false], // fObjects
|
|
|
|
["scenarios", false], // fScenarios
|
|
|
|
["formatCells", true], // fFormatCells
|
|
|
|
["formatColumns", true], // fFormatColumns
|
|
|
|
["formatRows", true], // fFormatRows
|
|
|
|
["insertColumns", true], // fInsertColumns
|
|
|
|
["insertRows", true], // fInsertRows
|
|
|
|
["insertHyperlinks", true], // fInsertHyperlinks
|
|
|
|
["deleteColumns", true], // fDeleteColumns
|
|
|
|
["deleteRows", true], // fDeleteRows
|
|
|
|
["selectLockedCells", false], // fSelLockedCells
|
|
|
|
["sort", true], // fSort
|
|
|
|
["autoFilter", true], // fAutoFilter
|
|
|
|
["pivotTables", true], // fPivotTables
|
|
|
|
["selectUnlockedCells", false] // fSelUnlockedCells
|
|
|
|
].forEach(function(n) {
|
2017-05-13 18:21:22 +00:00
|
|
|
/*:: if(o == null) throw "unreachable"; */
|
2017-04-28 07:28:03 +00:00
|
|
|
if(n[1]) o.write_shift(4, sp[n[0]] != null && !sp[n[0]] ? 1 : 0);
|
|
|
|
else o.write_shift(4, sp[n[0]] != null && sp[n[0]] ? 0 : 1);
|
2017-04-10 05:10:54 +00:00
|
|
|
});
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2019-11-15 01:46:49 +00:00
|
|
|
function parse_BrtDVal(/*data, length, opts*/) {
|
|
|
|
}
|
|
|
|
function parse_BrtDVal14(/*data, length, opts*/) {
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
/* [MS-XLSB] 2.1.7.61 Worksheet */
|
2017-12-30 05:40:35 +00:00
|
|
|
function parse_ws_bin(data, _opts, idx, rels, wb/*:WBWBProps*/, themes, styles)/*:Worksheet*/ {
|
2014-01-28 16:38:02 +00:00
|
|
|
if(!data) return data;
|
2017-04-08 06:55:35 +00:00
|
|
|
var opts = _opts || {};
|
2014-04-15 09:04:03 +00:00
|
|
|
if(!rels) rels = {'!id':{}};
|
2017-04-09 04:03:19 +00:00
|
|
|
if(DENSE != null && opts.dense == null) opts.dense = DENSE;
|
2017-05-13 18:21:22 +00:00
|
|
|
var s/*:Worksheet*/ = (opts.dense ? [] : {});
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
var ref;
|
2017-02-03 20:50:45 +00:00
|
|
|
var refguess = {s: {r:2000000, c:2000000}, e: {r:0, c:0} };
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2019-11-01 03:09:14 +00:00
|
|
|
var state/*:Array<string>*/ = [];
|
2014-02-19 03:03:28 +00:00
|
|
|
var pass = false, end = false;
|
2017-05-13 18:21:22 +00:00
|
|
|
var row, p, cf, R, C, addr, sstr, rr, cell/*:Cell*/;
|
2017-12-30 05:40:35 +00:00
|
|
|
var merges/*:Array<Range>*/ = [];
|
2017-02-19 20:36:32 +00:00
|
|
|
opts.biff = 12;
|
|
|
|
opts['!row'] = 0;
|
|
|
|
|
|
|
|
var ai = 0, af = false;
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
var arrayf/*:Array<[Range, string]>*/ = [];
|
|
|
|
var sharedf = {};
|
2019-11-01 03:09:14 +00:00
|
|
|
var supbooks = opts.supbooks || /*::(*/wb/*:: :any)*/.supbooks || ([[]]/*:any*/);
|
2017-12-30 05:40:35 +00:00
|
|
|
supbooks.sharedf = sharedf;
|
|
|
|
supbooks.arrayf = arrayf;
|
2017-04-11 22:15:36 +00:00
|
|
|
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
|
2017-11-15 18:14:02 +00:00
|
|
|
if(!opts.supbooks) {
|
|
|
|
opts.supbooks = supbooks;
|
2017-12-30 05:40:35 +00:00
|
|
|
if(wb.Names) for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
2017-11-15 18:14:02 +00:00
|
|
|
}
|
2017-02-19 20:36:32 +00:00
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
var colinfo/*:Array<ColInfo>*/ = [], rowinfo/*:Array<RowInfo>*/ = [];
|
2017-03-20 09:02:25 +00:00
|
|
|
var seencol = false;
|
|
|
|
|
2021-08-18 18:34:02 +00:00
|
|
|
XLSBRecordEnum[0x0010] = { n:"BrtShortReal", f:parse_BrtShortReal };
|
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
recordhopper(data, function ws_parse(val, R_n, RT) {
|
2014-02-19 03:03:28 +00:00
|
|
|
if(end) return;
|
2017-04-09 04:03:19 +00:00
|
|
|
switch(RT) {
|
|
|
|
case 0x0094: /* 'BrtWsDim' */
|
|
|
|
ref = val; break;
|
|
|
|
case 0x0000: /* 'BrtRowHdr' */
|
2014-02-19 03:03:28 +00:00
|
|
|
row = val;
|
|
|
|
if(opts.sheetRows && opts.sheetRows <= row.r) end=true;
|
2017-04-08 06:55:35 +00:00
|
|
|
rr = encode_row(R = row.r);
|
2017-02-19 20:36:32 +00:00
|
|
|
opts['!row'] = row.r;
|
2017-07-09 17:37:45 +00:00
|
|
|
if(val.hidden || val.hpt || val.level != null) {
|
2017-04-28 07:28:03 +00:00
|
|
|
if(val.hpt) val.hpx = pt2px(val.hpt);
|
|
|
|
rowinfo[val.r] = val;
|
|
|
|
}
|
2014-02-19 03:03:28 +00:00
|
|
|
break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0002: /* 'BrtCellRk' */
|
|
|
|
case 0x0003: /* 'BrtCellError' */
|
|
|
|
case 0x0004: /* 'BrtCellBool' */
|
|
|
|
case 0x0005: /* 'BrtCellReal' */
|
|
|
|
case 0x0006: /* 'BrtCellSt' */
|
|
|
|
case 0x0007: /* 'BrtCellIsst' */
|
|
|
|
case 0x0008: /* 'BrtFmlaString' */
|
|
|
|
case 0x0009: /* 'BrtFmlaNum' */
|
|
|
|
case 0x000A: /* 'BrtFmlaBool' */
|
|
|
|
case 0x000B: /* 'BrtFmlaError' */
|
2021-08-18 18:34:02 +00:00
|
|
|
case 0x000D: /* 'BrtShortRk' */
|
|
|
|
case 0x000E: /* 'BrtShortError' */
|
|
|
|
case 0x000F: /* 'BrtShortBool' */
|
|
|
|
case 0x0010: /* 'BrtShortReal' */
|
|
|
|
case 0x0011: /* 'BrtShortSt' */
|
|
|
|
case 0x0012: /* 'BrtShortIsst' */
|
2017-02-10 19:23:01 +00:00
|
|
|
p = ({t:val[2]}/*:any*/);
|
2014-01-28 16:38:02 +00:00
|
|
|
switch(val[2]) {
|
|
|
|
case 'n': p.v = val[1]; break;
|
2014-06-29 18:29:45 +00:00
|
|
|
case 's': sstr = strs[val[1]]; p.v = sstr.t; p.r = sstr.r; break;
|
2014-01-28 16:38:02 +00:00
|
|
|
case 'b': p.v = val[1] ? true : false; break;
|
2017-04-26 02:27:12 +00:00
|
|
|
case 'e': p.v = val[1]; if(opts.cellText !== false) p.w = BErr[p.v]; break;
|
2017-09-30 06:18:11 +00:00
|
|
|
case 'str': p.t = 's'; p.v = val[1]; break;
|
2014-01-28 16:38:02 +00:00
|
|
|
}
|
2017-07-27 20:07:51 +00:00
|
|
|
if((cf = styles.CellXf[val[0].iStyleRef])) safe_format(p,cf.numFmtId,null,opts, themes, styles);
|
2021-08-18 18:34:02 +00:00
|
|
|
C = val[0].c == -1 ? C + 1 : val[0].c;
|
2017-04-08 06:55:35 +00:00
|
|
|
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
|
|
|
|
else s[encode_col(C) + rr] = p;
|
2017-02-19 20:36:32 +00:00
|
|
|
if(opts.cellFormula) {
|
|
|
|
af = false;
|
2017-12-30 05:40:35 +00:00
|
|
|
for(ai = 0; ai < arrayf.length; ++ai) {
|
|
|
|
var aii = arrayf[ai];
|
2017-02-19 20:36:32 +00:00
|
|
|
if(row.r >= aii[0].s.r && row.r <= aii[0].e.r)
|
|
|
|
if(C >= aii[0].s.c && C <= aii[0].e.c) {
|
|
|
|
p.F = encode_range(aii[0]); af = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!af && val.length > 3) p.f = val[3];
|
|
|
|
}
|
2014-02-19 03:03:28 +00:00
|
|
|
if(refguess.s.r > row.r) refguess.s.r = row.r;
|
2014-06-29 18:29:45 +00:00
|
|
|
if(refguess.s.c > C) refguess.s.c = C;
|
2014-02-19 03:03:28 +00:00
|
|
|
if(refguess.e.r < row.r) refguess.e.r = row.r;
|
2014-06-29 18:29:45 +00:00
|
|
|
if(refguess.e.c < C) refguess.e.c = C;
|
2017-07-27 20:07:51 +00:00
|
|
|
if(opts.cellDates && cf && p.t == 'n' && SSF.is_date(SSF._table[cf.numFmtId])) {
|
2017-06-01 21:22:11 +00:00
|
|
|
var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); }
|
2017-03-21 20:44:35 +00:00
|
|
|
}
|
2014-02-19 03:03:28 +00:00
|
|
|
break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0001: /* 'BrtCellBlank' */
|
2021-08-18 18:34:02 +00:00
|
|
|
case 0x000C: /* 'BrtShortBlank' */
|
2017-07-10 22:18:18 +00:00
|
|
|
if(!opts.sheetStubs || pass) break;
|
2017-03-15 08:19:02 +00:00
|
|
|
p = ({t:'z',v:undefined}/*:any*/);
|
2021-08-18 18:34:02 +00:00
|
|
|
C = val[0].c == -1 ? C + 1 : val[0].c;
|
2017-04-08 06:55:35 +00:00
|
|
|
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
|
|
|
|
else s[encode_col(C) + rr] = p;
|
2014-03-29 22:53:15 +00:00
|
|
|
if(refguess.s.r > row.r) refguess.s.r = row.r;
|
2014-06-29 18:29:45 +00:00
|
|
|
if(refguess.s.c > C) refguess.s.c = C;
|
2014-03-29 22:53:15 +00:00
|
|
|
if(refguess.e.r < row.r) refguess.e.r = row.r;
|
2014-06-29 18:29:45 +00:00
|
|
|
if(refguess.e.c < C) refguess.e.c = C;
|
2014-03-29 22:53:15 +00:00
|
|
|
break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x00B0: /* 'BrtMergeCell' */
|
2017-12-30 05:40:35 +00:00
|
|
|
merges.push(val); break;
|
2014-04-15 09:04:03 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x01EE: /* 'BrtHLink' */
|
2014-04-15 09:04:03 +00:00
|
|
|
var rel = rels['!id'][val.relId];
|
|
|
|
if(rel) {
|
|
|
|
val.Target = rel.Target;
|
|
|
|
if(val.loc) val.Target += "#"+val.loc;
|
|
|
|
val.Rel = rel;
|
2017-12-15 01:18:40 +00:00
|
|
|
} else if(val.relId == '') {
|
|
|
|
val.Target = "#" + val.loc;
|
2014-04-15 09:04:03 +00:00
|
|
|
}
|
|
|
|
for(R=val.rfx.s.r;R<=val.rfx.e.r;++R) for(C=val.rfx.s.c;C<=val.rfx.e.c;++C) {
|
2017-04-08 06:55:35 +00:00
|
|
|
if(opts.dense) {
|
|
|
|
if(!s[R]) s[R] = [];
|
|
|
|
if(!s[R][C]) s[R][C] = {t:'z',v:undefined};
|
|
|
|
s[R][C].l = val;
|
|
|
|
} else {
|
|
|
|
addr = encode_cell({c:C,r:R});
|
|
|
|
if(!s[addr]) s[addr] = {t:'z',v:undefined};
|
|
|
|
s[addr].l = val;
|
|
|
|
}
|
2014-04-15 09:04:03 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x01AA: /* 'BrtArrFmla' */
|
2017-04-08 06:55:35 +00:00
|
|
|
if(!opts.cellFormula) break;
|
2017-12-30 05:40:35 +00:00
|
|
|
arrayf.push(val);
|
2017-05-13 18:21:22 +00:00
|
|
|
cell = ((opts.dense ? s[R][C] : s[encode_col(C) + rr])/*:any*/);
|
2017-04-08 06:55:35 +00:00
|
|
|
cell.f = stringify_formula(val[1], refguess, {r:row.r, c:C}, supbooks, opts);
|
|
|
|
cell.F = encode_range(val[0]);
|
2017-02-19 20:36:32 +00:00
|
|
|
break;
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x01AB: /* 'BrtShrFmla' */
|
2017-04-08 06:55:35 +00:00
|
|
|
if(!opts.cellFormula) break;
|
2017-12-30 05:40:35 +00:00
|
|
|
sharedf[encode_cell(val[0].s)] = val[1];
|
2017-04-08 06:55:35 +00:00
|
|
|
cell = (opts.dense ? s[R][C] : s[encode_col(C) + rr]);
|
|
|
|
cell.f = stringify_formula(val[1], refguess, {r:row.r, c:C}, supbooks, opts);
|
2017-02-19 20:36:32 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-20 09:02:25 +00:00
|
|
|
/* identical to 'ColInfo' in XLS */
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x003C: /* 'BrtColInfo' */
|
2017-03-20 09:02:25 +00:00
|
|
|
if(!opts.cellStyles) break;
|
|
|
|
while(val.e >= val.s) {
|
2019-11-01 03:09:14 +00:00
|
|
|
colinfo[val.e--] = { width: val.w/256, hidden: !!(val.flags & 0x01), level: val.level };
|
2017-03-20 09:02:25 +00:00
|
|
|
if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
|
|
|
|
process_col(colinfo[val.e+1]);
|
|
|
|
}
|
2017-04-08 06:55:35 +00:00
|
|
|
break;
|
2014-03-21 02:44:27 +00:00
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
case 0x00A1: /* 'BrtBeginAFilter' */
|
|
|
|
s['!autofilter'] = { ref:encode_range(val) };
|
|
|
|
break;
|
|
|
|
|
2017-04-13 01:29:38 +00:00
|
|
|
case 0x01DC: /* 'BrtMargins' */
|
|
|
|
s['!margins'] = val;
|
|
|
|
break;
|
|
|
|
|
2017-11-20 01:51:14 +00:00
|
|
|
case 0x0093: /* 'BrtWsProp' */
|
|
|
|
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
|
|
|
|
if(val.name) wb.Sheets[idx].CodeName = val.name;
|
|
|
|
break;
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
case 0x0089: /* 'BrtBeginWsView' */
|
|
|
|
if(!wb.Views) wb.Views = [{}];
|
|
|
|
if(!wb.Views[0]) wb.Views[0] = {};
|
|
|
|
if(val.RTL) wb.Views[0].RTL = true;
|
|
|
|
break;
|
|
|
|
|
2017-07-10 22:18:18 +00:00
|
|
|
case 0x01E5: /* 'BrtWsFmtInfo' */
|
2018-01-23 09:07:51 +00:00
|
|
|
break;
|
2019-11-01 03:09:14 +00:00
|
|
|
|
|
|
|
case 0x0040: /* 'BrtDVal' */
|
|
|
|
case 0x041D: /* 'BrtDVal14' */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0097: /* 'BrtPane' */
|
|
|
|
break;
|
2021-08-18 18:34:02 +00:00
|
|
|
case 0x0098: /* 'BrtSel' */
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
|
|
|
|
case 0x0284: /* 'BrtActiveX' */
|
|
|
|
case 0x0271: /* 'BrtBigName' */
|
|
|
|
case 0x0232: /* 'BrtBkHim' */
|
|
|
|
case 0x018C: /* 'BrtBrk' */
|
|
|
|
case 0x0458: /* 'BrtCFIcon' */
|
|
|
|
case 0x047A: /* 'BrtCFRuleExt' */
|
|
|
|
case 0x01D7: /* 'BrtCFVO' */
|
|
|
|
case 0x041A: /* 'BrtCFVO14' */
|
|
|
|
case 0x0289: /* 'BrtCellIgnoreEC' */
|
|
|
|
case 0x0451: /* 'BrtCellIgnoreEC14' */
|
|
|
|
case 0x0031: /* 'BrtCellMeta' */
|
|
|
|
case 0x024D: /* 'BrtCellSmartTagProperty' */
|
|
|
|
case 0x025F: /* 'BrtCellWatch' */
|
|
|
|
case 0x0234: /* 'BrtColor' */
|
|
|
|
case 0x041F: /* 'BrtColor14' */
|
|
|
|
case 0x00A8: /* 'BrtColorFilter' */
|
|
|
|
case 0x00AE: /* 'BrtCustomFilter' */
|
|
|
|
case 0x049C: /* 'BrtCustomFilter14' */
|
|
|
|
case 0x01F3: /* 'BrtDRef' */
|
2020-07-16 21:47:39 +00:00
|
|
|
case 0x01FB: /* 'BrtDXF' */
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0226: /* 'BrtDrawing' */
|
|
|
|
case 0x00AB: /* 'BrtDynamicFilter' */
|
|
|
|
case 0x00A7: /* 'BrtFilter' */
|
|
|
|
case 0x0499: /* 'BrtFilter14' */
|
|
|
|
case 0x00A9: /* 'BrtIconFilter' */
|
|
|
|
case 0x049D: /* 'BrtIconFilter14' */
|
|
|
|
case 0x0227: /* 'BrtLegacyDrawing' */
|
|
|
|
case 0x0228: /* 'BrtLegacyDrawingHF' */
|
|
|
|
case 0x0295: /* 'BrtListPart' */
|
|
|
|
case 0x027F: /* 'BrtOleObject' */
|
|
|
|
case 0x01DE: /* 'BrtPageSetup' */
|
|
|
|
case 0x0219: /* 'BrtPhoneticInfo' */
|
|
|
|
case 0x01DD: /* 'BrtPrintOptions' */
|
|
|
|
case 0x0218: /* 'BrtRangeProtection' */
|
|
|
|
case 0x044F: /* 'BrtRangeProtection14' */
|
|
|
|
case 0x02A8: /* 'BrtRangeProtectionIso' */
|
|
|
|
case 0x0450: /* 'BrtRangeProtectionIso14' */
|
|
|
|
case 0x0400: /* 'BrtRwDescent' */
|
|
|
|
case 0x0297: /* 'BrtSheetCalcProp' */
|
|
|
|
case 0x0217: /* 'BrtSheetProtection' */
|
|
|
|
case 0x02A6: /* 'BrtSheetProtectionIso' */
|
|
|
|
case 0x01F8: /* 'BrtSlc' */
|
|
|
|
case 0x0413: /* 'BrtSparkline' */
|
|
|
|
case 0x01AC: /* 'BrtTable' */
|
|
|
|
case 0x00AA: /* 'BrtTop10Filter' */
|
2018-03-19 21:42:55 +00:00
|
|
|
case 0x0C00: /* 'BrtUid' */
|
2017-04-09 04:03:19 +00:00
|
|
|
case 0x0032: /* 'BrtValueMeta' */
|
|
|
|
case 0x0816: /* 'BrtWebExtension' */
|
|
|
|
case 0x0415: /* 'BrtWsFmtInfoEx14' */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0023: /* 'BrtFRTBegin' */
|
|
|
|
pass = true; break;
|
|
|
|
case 0x0024: /* 'BrtFRTEnd' */
|
|
|
|
pass = false; break;
|
2019-11-01 03:09:14 +00:00
|
|
|
case 0x0025: /* 'BrtACBegin' */
|
|
|
|
state.push(R_n); pass = true; break;
|
|
|
|
case 0x0026: /* 'BrtACEnd' */
|
|
|
|
state.pop(); pass = false; break;
|
2014-03-29 02:05:50 +00:00
|
|
|
|
2017-04-08 06:55:35 +00:00
|
|
|
default:
|
2017-05-09 18:07:57 +00:00
|
|
|
if((R_n||"").indexOf("Begin") > 0){/* empty */}
|
|
|
|
else if((R_n||"").indexOf("End") > 0){/* empty */}
|
2017-04-09 04:03:19 +00:00
|
|
|
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
|
2014-01-28 16:38:02 +00:00
|
|
|
}
|
2014-02-13 06:22:42 +00:00
|
|
|
}, opts);
|
2017-02-19 20:36:32 +00:00
|
|
|
|
|
|
|
delete opts.supbooks;
|
|
|
|
delete opts['!row'];
|
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
if(!s["!ref"] && (refguess.s.r < 2000000 || ref && (ref.e.r > 0 || ref.e.c > 0 || ref.s.r > 0 || ref.s.c > 0))) s["!ref"] = encode_range(ref || refguess);
|
2014-03-29 22:53:15 +00:00
|
|
|
if(opts.sheetRows && s["!ref"]) {
|
2014-06-29 18:29:45 +00:00
|
|
|
var tmpref = safe_decode_range(s["!ref"]);
|
2018-04-06 06:39:48 +00:00
|
|
|
if(opts.sheetRows <= +tmpref.e.r) {
|
2014-02-19 03:03:28 +00:00
|
|
|
tmpref.e.r = opts.sheetRows - 1;
|
|
|
|
if(tmpref.e.r > refguess.e.r) tmpref.e.r = refguess.e.r;
|
|
|
|
if(tmpref.e.r < tmpref.s.r) tmpref.s.r = tmpref.e.r;
|
|
|
|
if(tmpref.e.c > refguess.e.c) tmpref.e.c = refguess.e.c;
|
|
|
|
if(tmpref.e.c < tmpref.s.c) tmpref.s.c = tmpref.e.c;
|
|
|
|
s["!fullref"] = s["!ref"];
|
|
|
|
s["!ref"] = encode_range(tmpref);
|
|
|
|
}
|
|
|
|
}
|
2017-12-30 05:40:35 +00:00
|
|
|
if(merges.length > 0) s["!merges"] = merges;
|
2017-03-20 09:02:25 +00:00
|
|
|
if(colinfo.length > 0) s["!cols"] = colinfo;
|
|
|
|
if(rowinfo.length > 0) s["!rows"] = rowinfo;
|
2014-01-28 16:38:02 +00:00
|
|
|
return s;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
/* TODO: something useful -- this is a stub */
|
2021-08-18 18:34:02 +00:00
|
|
|
function write_ws_bin_cell(ba/*:BufArray*/, cell/*:Cell*/, R/*:number*/, C/*:number*/, opts, ws/*:Worksheet*/, last_seen/*:boolean*/)/*:boolean*/ {
|
|
|
|
if(cell.v === undefined) return false;
|
2017-10-17 00:14:32 +00:00
|
|
|
var vv = "";
|
2014-07-28 13:22:32 +00:00
|
|
|
switch(cell.t) {
|
|
|
|
case 'b': vv = cell.v ? "1" : "0"; break;
|
2017-03-28 22:03:03 +00:00
|
|
|
case 'd': // no BrtCellDate :(
|
2017-10-17 00:14:32 +00:00
|
|
|
cell = dup(cell);
|
2017-03-28 22:03:03 +00:00
|
|
|
cell.z = cell.z || SSF._table[14];
|
2017-10-17 00:14:32 +00:00
|
|
|
cell.v = datenum(parseDate(cell.v)); cell.t = 'n';
|
2017-03-28 22:03:03 +00:00
|
|
|
break;
|
|
|
|
/* falls through */
|
2014-07-28 13:22:32 +00:00
|
|
|
case 'n': case 'e': vv = ''+cell.v; break;
|
|
|
|
default: vv = cell.v; break;
|
|
|
|
}
|
2017-03-12 18:02:43 +00:00
|
|
|
var o/*:any*/ = ({r:R, c:C}/*:any*/);
|
2014-07-28 13:22:32 +00:00
|
|
|
/* TODO: cell style */
|
2017-05-09 18:07:57 +00:00
|
|
|
o.s = get_cell_style(opts.cellXfs, cell, opts);
|
2017-03-31 00:47:35 +00:00
|
|
|
if(cell.l) ws['!links'].push([encode_cell(o), cell.l]);
|
2017-04-02 06:47:25 +00:00
|
|
|
if(cell.c) ws['!comments'].push([encode_cell(o), cell.c]);
|
2014-07-28 13:22:32 +00:00
|
|
|
switch(cell.t) {
|
|
|
|
case 's': case 'str':
|
|
|
|
if(opts.bookSST) {
|
2018-06-22 21:40:01 +00:00
|
|
|
vv = get_sst_id(opts.Strings, (cell.v/*:any*/), opts.revStrings);
|
2017-02-03 20:50:45 +00:00
|
|
|
o.t = "s"; o.v = vv;
|
2021-08-18 18:34:02 +00:00
|
|
|
if(last_seen) write_record(ba, "BrtShortIsst", write_BrtShortIsst(cell, o));
|
|
|
|
else write_record(ba, "BrtCellIsst", write_BrtCellIsst(cell, o));
|
2017-02-03 20:50:45 +00:00
|
|
|
} else {
|
|
|
|
o.t = "str";
|
2021-08-18 18:34:02 +00:00
|
|
|
if(last_seen) write_record(ba, "BrtShortSt", write_BrtShortSt(cell, o));
|
|
|
|
else write_record(ba, "BrtCellSt", write_BrtCellSt(cell, o));
|
2014-07-28 13:22:32 +00:00
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
return true;
|
2017-02-03 20:50:45 +00:00
|
|
|
case 'n':
|
|
|
|
/* TODO: determine threshold for Real vs RK */
|
2021-08-18 18:34:02 +00:00
|
|
|
if(cell.v == (cell.v | 0) && cell.v > -1000 && cell.v < 1000) {
|
|
|
|
if(last_seen) write_record(ba, "BrtShortRk", write_BrtShortRk(cell, o));
|
|
|
|
else write_record(ba, "BrtCellRk", write_BrtCellRk(cell, o));
|
|
|
|
} else {
|
|
|
|
if(last_seen) write_record(ba, "BrtShortReal", write_BrtShortReal(cell, o));
|
|
|
|
else write_record(ba, "BrtCellReal", write_BrtCellReal(cell, o));
|
|
|
|
} return true;
|
2017-02-03 20:50:45 +00:00
|
|
|
case 'b':
|
|
|
|
o.t = "b";
|
2021-08-18 18:34:02 +00:00
|
|
|
if(last_seen) write_record(ba, "BrtShortBool", write_BrtShortBool(cell, o));
|
|
|
|
else write_record(ba, "BrtCellBool", write_BrtCellBool(cell, o));
|
|
|
|
return true;
|
|
|
|
case 'e':
|
|
|
|
o.t = "e";
|
|
|
|
if(last_seen) write_record(ba, "BrtShortError", write_BrtShortError(cell, o));
|
|
|
|
else write_record(ba, "BrtCellError", write_BrtCellError(cell, o));
|
|
|
|
return true;
|
2014-07-28 13:22:32 +00:00
|
|
|
}
|
2021-08-18 18:34:02 +00:00
|
|
|
if(last_seen) write_record(ba, "BrtShortBlank", write_BrtShortBlank(cell, o));
|
|
|
|
else write_record(ba, "BrtCellBlank", write_BrtCellBlank(cell, o));
|
|
|
|
return true;
|
2014-07-28 13:22:32 +00:00
|
|
|
}
|
|
|
|
|
2018-01-23 09:07:51 +00:00
|
|
|
function write_CELLTABLE(ba, ws/*:Worksheet*/, idx/*:number*/, opts/*::, wb:Workbook*/) {
|
2017-12-30 05:40:35 +00:00
|
|
|
var range = safe_decode_range(ws['!ref'] || "A1"), ref, rr = "", cols/*:Array<string>*/ = [];
|
2014-05-29 22:30:03 +00:00
|
|
|
write_record(ba, 'BrtBeginSheetData');
|
2017-04-08 06:55:35 +00:00
|
|
|
var dense = Array.isArray(ws);
|
2017-07-09 17:37:45 +00:00
|
|
|
var cap = range.e.r;
|
|
|
|
if(ws['!rows']) cap = Math.max(range.e.r, ws['!rows'].length - 1);
|
|
|
|
for(var R = range.s.r; R <= cap; ++R) {
|
2014-07-28 13:22:32 +00:00
|
|
|
rr = encode_row(R);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [ACCELLTABLE] */
|
|
|
|
/* BrtRowHdr */
|
2017-02-03 20:50:45 +00:00
|
|
|
write_row_header(ba, ws, range, R);
|
2021-08-18 18:34:02 +00:00
|
|
|
var last_seen = false;
|
2017-07-09 17:37:45 +00:00
|
|
|
if(R <= range.e.r) for(var C = range.s.c; C <= range.e.c; ++C) {
|
2014-07-28 13:22:32 +00:00
|
|
|
/* *16384CELL */
|
|
|
|
if(R === range.s.r) cols[C] = encode_col(C);
|
|
|
|
ref = cols[C] + rr;
|
2017-04-08 06:55:35 +00:00
|
|
|
var cell = dense ? (ws[R]||[])[C] : ws[ref];
|
2021-08-18 18:34:02 +00:00
|
|
|
if(!cell) { last_seen = false; continue; }
|
2014-07-28 13:22:32 +00:00
|
|
|
/* write cell */
|
2021-08-18 18:34:02 +00:00
|
|
|
last_seen = write_ws_bin_cell(ba, cell, R, C, opts, ws, last_seen);
|
2014-07-28 13:22:32 +00:00
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
}
|
|
|
|
write_record(ba, 'BrtEndSheetData');
|
|
|
|
}
|
|
|
|
|
2017-03-16 01:17:24 +00:00
|
|
|
function write_MERGECELLS(ba, ws/*:Worksheet*/) {
|
|
|
|
if(!ws || !ws['!merges']) return;
|
|
|
|
write_record(ba, 'BrtBeginMergeCells', write_BrtBeginMergeCells(ws['!merges'].length));
|
|
|
|
ws['!merges'].forEach(function(m) { write_record(ba, 'BrtMergeCell', write_BrtMergeCell(m)); });
|
|
|
|
write_record(ba, 'BrtEndMergeCells');
|
|
|
|
}
|
|
|
|
|
2018-01-23 09:07:51 +00:00
|
|
|
function write_COLINFOS(ba, ws/*:Worksheet*//*::, idx:number, opts, wb:Workbook*/) {
|
2017-03-28 22:03:03 +00:00
|
|
|
if(!ws || !ws['!cols']) return;
|
|
|
|
write_record(ba, 'BrtBeginColInfos');
|
|
|
|
ws['!cols'].forEach(function(m, i) { if(m) write_record(ba, 'BrtColInfo', write_BrtColInfo(i, m)); });
|
|
|
|
write_record(ba, 'BrtEndColInfos');
|
|
|
|
}
|
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
function write_IGNOREECS(ba, ws/*:Worksheet*/) {
|
|
|
|
if(!ws || !ws['!ref']) return;
|
|
|
|
write_record(ba, 'BrtBeginCellIgnoreECs');
|
|
|
|
write_record(ba, 'BrtCellIgnoreEC', write_BrtCellIgnoreEC(safe_decode_range(ws['!ref'])));
|
|
|
|
write_record(ba, 'BrtEndCellIgnoreECs');
|
|
|
|
}
|
|
|
|
|
2017-03-31 00:47:35 +00:00
|
|
|
function write_HLINKS(ba, ws/*:Worksheet*/, rels) {
|
|
|
|
/* *BrtHLink */
|
|
|
|
ws['!links'].forEach(function(l) {
|
|
|
|
if(!l[1].Target) return;
|
|
|
|
var rId = add_rels(rels, -1, l[1].Target.replace(/#.*$/, ""), RELS.HLINK);
|
|
|
|
write_record(ba, "BrtHLink", write_BrtHLink(l, rId));
|
|
|
|
});
|
|
|
|
delete ws['!links'];
|
|
|
|
}
|
2017-04-02 06:47:25 +00:00
|
|
|
function write_LEGACYDRAWING(ba, ws/*:Worksheet*/, idx/*:number*/, rels) {
|
|
|
|
/* [BrtLegacyDrawing] */
|
|
|
|
if(ws['!comments'].length > 0) {
|
|
|
|
var rId = add_rels(rels, -1, "../drawings/vmlDrawing" + (idx+1) + ".vml", RELS.VML);
|
|
|
|
write_record(ba, "BrtLegacyDrawing", write_RelID("rId" + rId));
|
|
|
|
ws['!legacy'] = rId;
|
|
|
|
}
|
|
|
|
}
|
2017-03-31 00:47:35 +00:00
|
|
|
|
2019-11-01 03:09:14 +00:00
|
|
|
function write_AUTOFILTER(ba, ws, wb, idx) {
|
2017-04-10 05:10:54 +00:00
|
|
|
if(!ws['!autofilter']) return;
|
2019-11-01 03:09:14 +00:00
|
|
|
var data = ws['!autofilter'];
|
|
|
|
var ref = typeof data.ref === "string" ? data.ref : encode_range(data.ref);
|
|
|
|
|
|
|
|
/* Update FilterDatabase defined name for the worksheet */
|
|
|
|
if(!wb.Workbook) wb.Workbook = ({Sheets:[]}/*:any*/);
|
|
|
|
if(!wb.Workbook.Names) wb.Workbook.Names = [];
|
|
|
|
var names/*: Array<any> */ = wb.Workbook.Names;
|
|
|
|
var range = decode_range(ref);
|
|
|
|
if(range.s.r == range.e.r) { range.e.r = decode_range(ws["!ref"]).e.r; ref = encode_range(range); }
|
|
|
|
for(var i = 0; i < names.length; ++i) {
|
|
|
|
var name = names[i];
|
|
|
|
if(name.Name != '_xlnm._FilterDatabase') continue;
|
|
|
|
if(name.Sheet != idx) continue;
|
|
|
|
name.Ref = "'" + wb.SheetNames[idx] + "'!" + ref; break;
|
|
|
|
}
|
|
|
|
if(i == names.length) names.push({ Name: '_xlnm._FilterDatabase', Sheet: idx, Ref: "'" + wb.SheetNames[idx] + "'!" + ref });
|
|
|
|
|
|
|
|
write_record(ba, "BrtBeginAFilter", write_UncheckedRfX(safe_decode_range(ref)));
|
2017-04-10 05:10:54 +00:00
|
|
|
/* *FILTERCOLUMN */
|
|
|
|
/* [SORTSTATE] */
|
|
|
|
/* BrtEndAFilter */
|
|
|
|
write_record(ba, "BrtEndAFilter");
|
|
|
|
}
|
|
|
|
|
2017-12-25 02:25:03 +00:00
|
|
|
function write_WSVIEWS2(ba, ws, Workbook) {
|
2017-04-28 07:28:03 +00:00
|
|
|
write_record(ba, "BrtBeginWsViews");
|
|
|
|
{ /* 1*WSVIEW2 */
|
|
|
|
/* [ACUID] */
|
2017-12-25 02:25:03 +00:00
|
|
|
write_record(ba, "BrtBeginWsView", write_BrtBeginWsView(ws, Workbook));
|
2017-04-28 07:28:03 +00:00
|
|
|
/* [BrtPane] */
|
|
|
|
/* *4BrtSel */
|
|
|
|
/* *4SXSELECT */
|
|
|
|
/* *FRT */
|
|
|
|
write_record(ba, "BrtEndWsView");
|
|
|
|
}
|
|
|
|
/* *FRT */
|
|
|
|
write_record(ba, "BrtEndWsViews");
|
|
|
|
}
|
|
|
|
|
2018-01-23 09:07:51 +00:00
|
|
|
function write_WSFMTINFO(/*::ba, ws*/) {
|
2017-05-09 18:07:57 +00:00
|
|
|
/* [ACWSFMTINFO] */
|
|
|
|
//write_record(ba, "BrtWsFmtInfo", write_BrtWsFmtInfo(ws));
|
|
|
|
}
|
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
function write_SHEETPROTECT(ba, ws) {
|
|
|
|
if(!ws['!protect']) return;
|
|
|
|
/* [BrtSheetProtectionIso] */
|
|
|
|
write_record(ba, "BrtSheetProtection", write_BrtSheetProtection(ws['!protect']));
|
|
|
|
}
|
|
|
|
|
2017-03-31 00:47:35 +00:00
|
|
|
function write_ws_bin(idx/*:number*/, opts, wb/*:Workbook*/, rels) {
|
2014-05-29 22:30:03 +00:00
|
|
|
var ba = buf_array();
|
|
|
|
var s = wb.SheetNames[idx], ws = wb.Sheets[s] || {};
|
2017-11-20 01:51:14 +00:00
|
|
|
var c/*:string*/ = s; try { if(wb && wb.Workbook) c = wb.Workbook.Sheets[idx].CodeName || c; } catch(e) {}
|
2014-06-29 18:29:45 +00:00
|
|
|
var r = safe_decode_range(ws['!ref'] || "A1");
|
2018-04-27 20:11:18 +00:00
|
|
|
if(r.e.c > 0x3FFF || r.e.r > 0xFFFFF) {
|
|
|
|
if(opts.WTF) throw new Error("Range " + (ws['!ref'] || "A1") + " exceeds format limit A1:XFD1048576");
|
|
|
|
r.e.c = Math.min(r.e.c, 0x3FFF);
|
|
|
|
r.e.r = Math.min(r.e.c, 0xFFFFF);
|
|
|
|
}
|
2017-03-31 00:47:35 +00:00
|
|
|
ws['!links'] = [];
|
2017-04-02 06:47:25 +00:00
|
|
|
/* passed back to write_zip and removed there */
|
|
|
|
ws['!comments'] = [];
|
2014-05-29 22:30:03 +00:00
|
|
|
write_record(ba, "BrtBeginSheet");
|
2018-02-14 20:06:35 +00:00
|
|
|
if(wb.vbaraw) write_record(ba, "BrtWsProp", write_BrtWsProp(c));
|
2014-05-29 22:30:03 +00:00
|
|
|
write_record(ba, "BrtWsDim", write_BrtWsDim(r));
|
2017-12-25 02:25:03 +00:00
|
|
|
write_WSVIEWS2(ba, ws, wb.Workbook);
|
2017-05-09 18:07:57 +00:00
|
|
|
write_WSFMTINFO(ba, ws);
|
2017-03-28 22:03:03 +00:00
|
|
|
write_COLINFOS(ba, ws, idx, opts, wb);
|
2014-05-29 22:30:03 +00:00
|
|
|
write_CELLTABLE(ba, ws, idx, opts, wb);
|
|
|
|
/* [BrtSheetCalcProp] */
|
2017-04-10 05:10:54 +00:00
|
|
|
write_SHEETPROTECT(ba, ws);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* *([BrtRangeProtectionIso] BrtRangeProtection) */
|
|
|
|
/* [SCENMAN] */
|
2019-11-01 03:09:14 +00:00
|
|
|
write_AUTOFILTER(ba, ws, wb, idx);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [SORTSTATE] */
|
|
|
|
/* [DCON] */
|
|
|
|
/* [USERSHVIEWS] */
|
2017-03-16 01:17:24 +00:00
|
|
|
write_MERGECELLS(ba, ws);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [BrtPhoneticInfo] */
|
|
|
|
/* *CONDITIONALFORMATTING */
|
|
|
|
/* [DVALS] */
|
2017-03-31 00:47:35 +00:00
|
|
|
write_HLINKS(ba, ws, rels);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [BrtPrintOptions] */
|
2017-04-13 01:29:38 +00:00
|
|
|
if(ws['!margins']) write_record(ba, "BrtMargins", write_BrtMargins(ws['!margins']));
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [BrtPageSetup] */
|
|
|
|
/* [HEADERFOOTER] */
|
|
|
|
/* [RWBRK] */
|
|
|
|
/* [COLBRK] */
|
|
|
|
/* *BrtBigName */
|
|
|
|
/* [CELLWATCHES] */
|
2018-08-15 19:22:47 +00:00
|
|
|
if(!opts || opts.ignoreEC || (opts.ignoreEC == (void 0))) write_IGNOREECS(ba, ws);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [SMARTTAGS] */
|
|
|
|
/* [BrtDrawing] */
|
2017-04-02 06:47:25 +00:00
|
|
|
write_LEGACYDRAWING(ba, ws, idx, rels);
|
2014-05-29 22:30:03 +00:00
|
|
|
/* [BrtLegacyDrawingHF] */
|
|
|
|
/* [BrtBkHim] */
|
|
|
|
/* [OLEOBJECTS] */
|
|
|
|
/* [ACTIVEXCONTROLS] */
|
|
|
|
/* [WEBPUBITEMS] */
|
|
|
|
/* [LISTPARTS] */
|
|
|
|
/* FRTWORKSHEET */
|
|
|
|
write_record(ba, "BrtEndSheet");
|
|
|
|
return ba.end();
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|