2017-12-30 05:40:35 +00:00
|
|
|
function parse_ws_xml_dim(ws/*:Worksheet*/, s/*:string*/) {
|
2014-06-29 18:29:45 +00:00
|
|
|
var d = safe_decode_range(s);
|
2014-07-28 13:22:32 +00:00
|
|
|
if(d.s.r<=d.e.r && d.s.c<=d.e.c && d.s.r>=0 && d.s.c>=0) ws["!ref"] = encode_range(d);
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-03-20 21:42:12 +00:00
|
|
|
var mergecregex = /<(?:\w:)?mergeCell ref="[A-Z0-9:]+"\s*[\/]?>/g;
|
2017-06-24 06:51:37 +00:00
|
|
|
var sheetdataregex = /<(?:\w+:)?sheetData>([\s\S]*)<\/(?:\w+:)?sheetData>/;
|
2017-04-09 04:03:19 +00:00
|
|
|
var hlinkregex = /<(?:\w:)?hyperlink [^>]*>/mg;
|
2014-07-28 13:22:32 +00:00
|
|
|
var dimregex = /"(\w*:\w*)"/;
|
2017-04-09 04:03:19 +00:00
|
|
|
var colregex = /<(?:\w:)?col[^>]*[\/]?>/g;
|
2017-06-24 06:51:37 +00:00
|
|
|
var afregex = /<(?:\w:)?autoFilter[^>]*([\/]|>([\s\S]*)<\/(?:\w:)?autoFilter)>/g;
|
2017-04-13 01:29:38 +00:00
|
|
|
var marginregex= /<(?:\w:)?pageMargins[^>]*\/>/g;
|
2017-11-20 01:51:14 +00:00
|
|
|
var sheetprregex = /<(?:\w:)?sheetPr(?:[^>a-z][^>]*)?\/>/;
|
2017-12-30 05:40:35 +00:00
|
|
|
var svsregex = /<(?:\w:)?sheetViews[^>]*(?:[\/]|>([\s\S]*)<\/(?:\w:)?sheetViews)>/;
|
2014-01-28 16:38:02 +00:00
|
|
|
/* 18.3 Worksheets */
|
2017-12-30 05:40:35 +00:00
|
|
|
function parse_ws_xml(data/*:?string*/, opts, idx/*:number*/, rels, wb/*:WBWBProps*/, themes, styles)/*:Worksheet*/ {
|
2014-01-28 16:38:02 +00:00
|
|
|
if(!data) return data;
|
2017-04-09 04:03:19 +00:00
|
|
|
if(DENSE != null && opts.dense == null) opts.dense = DENSE;
|
2017-04-10 05:10:54 +00:00
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
/* 18.3.1.99 worksheet CT_Worksheet */
|
2017-04-08 06:55:35 +00:00
|
|
|
var s = opts.dense ? ([]/*:any*/) : ({}/*:any*/);
|
2017-04-10 05:10:54 +00:00
|
|
|
var refguess/*:Range*/ = ({s: {r:2000000, c:2000000}, e: {r:0, c:0} }/*:any*/);
|
|
|
|
|
|
|
|
var data1 = "", data2 = "";
|
2017-06-10 01:47:42 +00:00
|
|
|
var mtch/*:?any*/ = data.match(sheetdataregex);
|
2017-04-10 05:10:54 +00:00
|
|
|
if(mtch) {
|
2018-01-11 08:01:25 +00:00
|
|
|
data1 = data.slice(0, mtch.index);
|
|
|
|
data2 = data.slice(mtch.index + mtch[0].length);
|
2017-04-10 05:10:54 +00:00
|
|
|
} else data1 = data2 = data;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2017-11-20 01:51:14 +00:00
|
|
|
/* 18.3.1.82 sheetPr CT_SheetPr */
|
|
|
|
var sheetPr = data1.match(sheetprregex);
|
|
|
|
if(sheetPr) parse_ws_xml_sheetpr(sheetPr[0], s, wb, idx);
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
/* 18.3.1.35 dimension CT_SheetDimension */
|
2017-02-10 19:23:01 +00:00
|
|
|
// $FlowIgnore
|
2017-04-10 05:10:54 +00:00
|
|
|
var ridx = (data1.match(/<(?:\w*:)?dimension/)||{index:-1}).index;
|
2014-06-29 18:29:45 +00:00
|
|
|
if(ridx > 0) {
|
2018-01-11 08:01:25 +00:00
|
|
|
var ref = data1.slice(ridx,ridx+50).match(dimregex);
|
2017-04-10 05:10:54 +00:00
|
|
|
if(ref) parse_ws_xml_dim(s, ref[1]);
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
/* 18.3.1.88 sheetViews CT_SheetViews */
|
|
|
|
var svs = data1.match(svsregex);
|
|
|
|
if(svs && svs[1]) parse_ws_xml_sheetviews(svs[1], wb);
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
/* 18.3.1.17 cols CT_Cols */
|
2017-12-30 05:40:35 +00:00
|
|
|
var columns/*:Array<ColInfo>*/ = [];
|
2017-02-10 19:23:01 +00:00
|
|
|
if(opts.cellStyles) {
|
2014-06-02 05:19:07 +00:00
|
|
|
/* 18.3.1.13 col CT_Col */
|
2017-04-10 05:10:54 +00:00
|
|
|
var cols = data1.match(colregex);
|
2017-02-10 19:23:01 +00:00
|
|
|
if(cols) parse_ws_xml_cols(columns, cols);
|
2014-06-02 05:19:07 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
/* 18.3.1.80 sheetData CT_SheetData ? */
|
2017-03-18 23:25:50 +00:00
|
|
|
if(mtch) parse_ws_xml_data(mtch[1], s, opts, refguess, themes, styles);
|
2014-04-15 09:04:03 +00:00
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* 18.3.1.2 autoFilter CT_AutoFilter */
|
|
|
|
var afilter = data2.match(afregex);
|
|
|
|
if(afilter) s['!autofilter'] = parse_ws_xml_autofilter(afilter[0]);
|
|
|
|
|
|
|
|
/* 18.3.1.55 mergeCells CT_MergeCells */
|
2017-12-30 05:40:35 +00:00
|
|
|
var merges/*:Array<Range>*/ = [];
|
|
|
|
var _merge = data2.match(mergecregex);
|
|
|
|
if(_merge) for(ridx = 0; ridx != _merge.length; ++ridx)
|
2018-01-11 08:01:25 +00:00
|
|
|
merges[ridx] = safe_decode_range(_merge[ridx].slice(_merge[ridx].indexOf("\"")+1));
|
2017-04-10 05:10:54 +00:00
|
|
|
|
2014-04-15 09:04:03 +00:00
|
|
|
/* 18.3.1.48 hyperlinks CT_Hyperlinks */
|
2017-04-10 05:10:54 +00:00
|
|
|
var hlink = data2.match(hlinkregex);
|
2017-02-10 19:23:01 +00:00
|
|
|
if(hlink) parse_ws_xml_hlinks(s, hlink, rels);
|
2014-04-15 09:04:03 +00:00
|
|
|
|
2017-04-13 01:29:38 +00:00
|
|
|
/* 18.3.1.62 pageMargins CT_PageMargins */
|
|
|
|
var margins = data2.match(marginregex);
|
|
|
|
if(margins) s['!margins'] = parse_ws_xml_margins(parsexmltag(margins[0]));
|
|
|
|
|
2014-03-29 22:53:15 +00:00
|
|
|
if(!s["!ref"] && refguess.e.c >= refguess.s.c && refguess.e.r >= refguess.s.r) s["!ref"] = encode_range(refguess);
|
2014-06-29 18:29:45 +00:00
|
|
|
if(opts.sheetRows > 0 && s["!ref"]) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
if(columns.length > 0) s["!cols"] = columns;
|
2017-12-30 05:40:35 +00:00
|
|
|
if(merges.length > 0) s["!merges"] = merges;
|
2014-01-28 16:38:02 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
function write_ws_xml_merges(merges/*:Array<Range>*/)/*:string*/ {
|
2017-10-17 00:14:32 +00:00
|
|
|
if(merges.length === 0) return "";
|
2014-08-26 17:40:04 +00:00
|
|
|
var o = '<mergeCells count="' + merges.length + '">';
|
|
|
|
for(var i = 0; i != merges.length; ++i) o += '<mergeCell ref="' + encode_range(merges[i]) + '"/>';
|
|
|
|
return o + '</mergeCells>';
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
|
2017-11-20 01:51:14 +00:00
|
|
|
/* 18.3.1.82-3 sheetPr CT_ChartsheetPr / CT_SheetPr */
|
|
|
|
function parse_ws_xml_sheetpr(sheetPr/*:string*/, s, wb/*:WBWBProps*/, idx/*:number*/) {
|
|
|
|
var data = parsexmltag(sheetPr);
|
|
|
|
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
|
|
|
|
if(data.codeName) wb.Sheets[idx].CodeName = data.codeName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 18.3.1.85 sheetProtection CT_SheetProtection */
|
2017-04-04 18:41:11 +00:00
|
|
|
function write_ws_xml_protection(sp)/*:string*/ {
|
|
|
|
// algorithmName, hashValue, saltValue, spinCountpassword
|
|
|
|
var o = ({sheet:1}/*:any*/);
|
|
|
|
var deffalse = ["objects", "scenarios", "selectLockedCells", "selectUnlockedCells"];
|
|
|
|
var deftrue = [
|
|
|
|
"formatColumns", "formatRows", "formatCells",
|
|
|
|
"insertColumns", "insertRows", "insertHyperlinks",
|
|
|
|
"deleteColumns", "deleteRows",
|
|
|
|
"sort", "autoFilter", "pivotTables"
|
|
|
|
];
|
|
|
|
deffalse.forEach(function(n) { if(sp[n] != null && sp[n]) o[n] = "1"; });
|
|
|
|
deftrue.forEach(function(n) { if(sp[n] != null && !sp[n]) o[n] = "0"; });
|
|
|
|
/* TODO: algorithm */
|
|
|
|
if(sp.password) o.password = crypto_CreatePasswordVerifier_Method1(sp.password).toString(16).toUpperCase();
|
|
|
|
return writextag('sheetProtection', null, o);
|
|
|
|
}
|
|
|
|
|
2017-03-28 22:03:03 +00:00
|
|
|
function parse_ws_xml_hlinks(s, data/*:Array<string>*/, rels) {
|
2017-04-08 06:55:35 +00:00
|
|
|
var dense = Array.isArray(s);
|
2014-06-29 18:29:45 +00:00
|
|
|
for(var i = 0; i != data.length; ++i) {
|
2017-06-13 02:26:29 +00:00
|
|
|
var val = parsexmltag(utf8read(data[i]), true);
|
2014-06-05 07:06:20 +00:00
|
|
|
if(!val.ref) return;
|
2017-12-15 01:18:40 +00:00
|
|
|
var rel = ((rels || {})['!id']||[])[val.id];
|
2014-06-05 07:06:20 +00:00
|
|
|
if(rel) {
|
|
|
|
val.Target = rel.Target;
|
|
|
|
if(val.location) val.Target += "#"+val.location;
|
2014-11-13 08:42:15 +00:00
|
|
|
} else {
|
2017-12-15 01:18:40 +00:00
|
|
|
val.Target = "#" + val.location;
|
|
|
|
rel = {Target: val.Target, TargetMode: 'Internal'};
|
2014-06-05 07:06:20 +00:00
|
|
|
}
|
2017-12-15 01:18:40 +00:00
|
|
|
val.Rel = rel;
|
2017-03-28 22:03:03 +00:00
|
|
|
if(val.tooltip) { val.Tooltip = val.tooltip; delete val.tooltip; }
|
2014-06-29 18:29:45 +00:00
|
|
|
var rng = safe_decode_range(val.ref);
|
2014-06-05 07:06:20 +00:00
|
|
|
for(var R=rng.s.r;R<=rng.e.r;++R) for(var C=rng.s.c;C<=rng.e.c;++C) {
|
|
|
|
var addr = encode_cell({c:C,r:R});
|
2017-04-08 06:55:35 +00:00
|
|
|
if(dense) {
|
|
|
|
if(!s[R]) s[R] = [];
|
|
|
|
if(!s[R][C]) s[R][C] = {t:"z",v:undefined};
|
|
|
|
s[R][C].l = val;
|
|
|
|
} else {
|
|
|
|
if(!s[addr]) s[addr] = {t:"z",v:undefined};
|
|
|
|
s[addr].l = val;
|
|
|
|
}
|
2014-06-05 07:06:20 +00:00
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-05 07:06:20 +00:00
|
|
|
|
2017-04-13 01:29:38 +00:00
|
|
|
function parse_ws_xml_margins(margin) {
|
|
|
|
var o = {};
|
|
|
|
["left", "right", "top", "bottom", "header", "footer"].forEach(function(k) {
|
|
|
|
if(margin[k]) o[k] = parseFloat(margin[k]);
|
|
|
|
});
|
|
|
|
return o;
|
|
|
|
}
|
2017-12-30 05:40:35 +00:00
|
|
|
function write_ws_xml_margins(margin)/*:string*/ {
|
2017-04-17 02:28:38 +00:00
|
|
|
default_margins(margin);
|
|
|
|
return writextag('pageMargins', null, margin);
|
|
|
|
}
|
2017-04-13 01:29:38 +00:00
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
function parse_ws_xml_cols(columns, cols) {
|
2014-06-05 07:06:20 +00:00
|
|
|
var seencol = false;
|
|
|
|
for(var coli = 0; coli != cols.length; ++coli) {
|
|
|
|
var coll = parsexmltag(cols[coli], true);
|
2017-04-28 07:28:03 +00:00
|
|
|
if(coll.hidden) coll.hidden = parsexmlbool(coll.hidden);
|
2014-06-29 18:29:45 +00:00
|
|
|
var colm=parseInt(coll.min, 10)-1, colM=parseInt(coll.max,10)-1;
|
2017-03-20 09:02:25 +00:00
|
|
|
delete coll.min; delete coll.max; coll.width = +coll.width;
|
|
|
|
if(!seencol && coll.width) { seencol = true; find_mdw_colw(coll.width); }
|
|
|
|
process_col(coll);
|
|
|
|
while(colm <= colM) columns[colm++] = dup(coll);
|
2014-06-05 07:06:20 +00:00
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-06-05 07:06:20 +00:00
|
|
|
|
2017-02-10 19:23:01 +00:00
|
|
|
function write_ws_xml_cols(ws, cols)/*:string*/ {
|
2018-01-23 09:07:51 +00:00
|
|
|
var o = ["<cols>"], col;
|
2014-06-05 07:06:20 +00:00
|
|
|
for(var i = 0; i != cols.length; ++i) {
|
|
|
|
if(!(col = cols[i])) continue;
|
2017-03-28 22:03:03 +00:00
|
|
|
o[o.length] = (writextag('col', null, col_obj_w(i, col)));
|
2014-06-05 07:06:20 +00:00
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
o[o.length] = "</cols>";
|
2014-06-05 07:06:20 +00:00
|
|
|
return o.join("");
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
function parse_ws_xml_autofilter(data/*:string*/) {
|
2017-04-10 05:10:54 +00:00
|
|
|
var o = { ref: (data.match(/ref="([^"]*)"/)||[])[1]};
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
function write_ws_xml_autofilter(data)/*:string*/ {
|
|
|
|
return writextag("autoFilter", null, {ref:data.ref});
|
|
|
|
}
|
|
|
|
|
2017-04-28 07:28:03 +00:00
|
|
|
/* 18.3.1.88 sheetViews CT_SheetViews */
|
|
|
|
/* 18.3.1.87 sheetView CT_SheetView */
|
2017-12-30 05:40:35 +00:00
|
|
|
var sviewregex = /<(?:\w:)?sheetView(?:[^>a-z][^>]*)?\/>/;
|
|
|
|
function parse_ws_xml_sheetviews(data, wb/*:WBWBProps*/) {
|
|
|
|
(data.match(sviewregex)||[]).forEach(function(r/*:string*/) {
|
|
|
|
var tag = parsexmltag(r);
|
|
|
|
if(parsexmlbool(tag.rightToLeft)) {
|
|
|
|
if(!wb.Views) wb.Views = [{}];
|
|
|
|
if(!wb.Views[0]) wb.Views[0] = {};
|
|
|
|
wb.Views[0].RTL = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-04-28 07:28:03 +00:00
|
|
|
function write_ws_xml_sheetviews(ws, opts, idx, wb)/*:string*/ {
|
2017-12-25 02:25:03 +00:00
|
|
|
var sview = {workbookViewId:"0"};
|
|
|
|
// $FlowIgnore
|
|
|
|
if( (((wb||{}).Workbook||{}).Views||[])[0] ) sview.rightToLeft = wb.Workbook.Views[0].RTL ? "1" : "0";
|
|
|
|
return writextag("sheetViews", writextag("sheetView", null, sview), {});
|
2017-04-28 07:28:03 +00:00
|
|
|
}
|
|
|
|
|
2018-01-23 09:07:51 +00:00
|
|
|
function write_ws_xml_cell(cell/*:Cell*/, ref, ws, opts/*::, idx, wb*/)/*:string*/ {
|
2017-03-18 00:45:06 +00:00
|
|
|
if(cell.v === undefined && cell.f === undefined || cell.t === 'z') return "";
|
2014-06-29 18:29:45 +00:00
|
|
|
var vv = "";
|
2014-10-26 05:26:18 +00:00
|
|
|
var oldt = cell.t, oldv = cell.v;
|
2014-06-29 18:29:45 +00:00
|
|
|
switch(cell.t) {
|
|
|
|
case 'b': vv = cell.v ? "1" : "0"; break;
|
2014-10-26 05:26:18 +00:00
|
|
|
case 'n': vv = ''+cell.v; break;
|
|
|
|
case 'e': vv = BErr[cell.v]; break;
|
|
|
|
case 'd':
|
2017-06-01 21:22:11 +00:00
|
|
|
if(opts.cellDates) vv = parseDate(cell.v, -1).toISOString();
|
2014-10-26 05:26:18 +00:00
|
|
|
else {
|
2017-10-17 00:14:32 +00:00
|
|
|
cell = dup(cell);
|
2014-10-26 05:26:18 +00:00
|
|
|
cell.t = 'n';
|
2017-03-23 01:18:40 +00:00
|
|
|
vv = ''+(cell.v = datenum(parseDate(cell.v)));
|
2014-10-26 05:26:18 +00:00
|
|
|
}
|
2017-05-11 07:29:59 +00:00
|
|
|
if(typeof cell.z === 'undefined') cell.z = SSF._table[14];
|
2014-10-26 05:26:18 +00:00
|
|
|
break;
|
2014-06-29 18:29:45 +00:00
|
|
|
default: vv = cell.v; break;
|
|
|
|
}
|
2017-02-10 19:23:01 +00:00
|
|
|
var v = writetag('v', escapexml(vv)), o = ({r:ref}/*:any*/);
|
2014-05-16 00:33:34 +00:00
|
|
|
/* TODO: cell style */
|
2014-06-29 18:29:45 +00:00
|
|
|
var os = get_cell_style(opts.cellXfs, cell, opts);
|
|
|
|
if(os !== 0) o.s = os;
|
2014-05-16 00:33:34 +00:00
|
|
|
switch(cell.t) {
|
2014-07-28 13:22:32 +00:00
|
|
|
case 'n': break;
|
2014-10-26 05:26:18 +00:00
|
|
|
case 'd': o.t = "d"; break;
|
2014-07-28 13:22:32 +00:00
|
|
|
case 'b': o.t = "b"; break;
|
|
|
|
case 'e': o.t = "e"; break;
|
2017-03-18 00:45:06 +00:00
|
|
|
default: if(cell.v == null) { delete cell.t; break; }
|
2014-05-16 00:33:34 +00:00
|
|
|
if(opts.bookSST) {
|
2018-06-22 21:40:01 +00:00
|
|
|
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v, opts.revStrings));
|
2014-06-29 18:29:45 +00:00
|
|
|
o.t = "s"; break;
|
2014-06-05 07:06:20 +00:00
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
o.t = "str"; break;
|
2014-05-16 00:33:34 +00:00
|
|
|
}
|
2014-10-26 05:26:18 +00:00
|
|
|
if(cell.t != oldt) { cell.t = oldt; cell.v = oldv; }
|
2017-03-18 00:45:06 +00:00
|
|
|
if(cell.f) {
|
2018-01-11 08:01:25 +00:00
|
|
|
var ff = cell.F && cell.F.slice(0, ref.length) == ref ? {t:"array", ref:cell.F} : null;
|
2017-03-18 00:45:06 +00:00
|
|
|
v = writextag('f', escapexml(cell.f), ff) + (cell.v != null ? v : "");
|
|
|
|
}
|
2017-03-31 00:47:35 +00:00
|
|
|
if(cell.l) ws['!links'].push([ref, cell.l]);
|
2017-04-02 06:47:25 +00:00
|
|
|
if(cell.c) ws['!comments'].push([ref, cell.c]);
|
2014-06-29 18:29:45 +00:00
|
|
|
return writextag('c', v, o);
|
|
|
|
}
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
var parse_ws_xml_data = (function() {
|
2014-10-10 02:22:38 +00:00
|
|
|
var cellregex = /<(?:\w+:)?c[ >]/, rowregex = /<\/(?:\w+:)?row>/;
|
2017-02-10 19:23:01 +00:00
|
|
|
var rregex = /r=["']([^"']*)["']/, isregex = /<(?:\w+:)?is>([\S\s]*?)<\/(?:\w+:)?is>/;
|
2017-02-19 20:36:32 +00:00
|
|
|
var refregex = /ref=["']([^"']*)["']/;
|
2014-06-29 18:29:45 +00:00
|
|
|
var match_v = matchtag("v"), match_f = matchtag("f");
|
|
|
|
|
2017-12-30 05:40:35 +00:00
|
|
|
return function parse_ws_xml_data(sdata/*:string*/, s, opts, guess/*:Range*/, themes, styles) {
|
|
|
|
var ri = 0, x = "", cells/*:Array<string>*/ = [], cref/*:?Array<string>*/ = [], idx=0, i=0, cc=0, d="", p/*:any*/;
|
2014-10-10 02:22:38 +00:00
|
|
|
var tag, tagr = 0, tagc = 0;
|
2017-02-19 20:36:32 +00:00
|
|
|
var sstr, ftag;
|
2017-07-05 22:27:54 +00:00
|
|
|
var fmtid = 0, fillid = 0;
|
|
|
|
var do_format = Array.isArray(styles.CellXf), cf;
|
2017-12-30 05:40:35 +00:00
|
|
|
var arrayf/*:Array<[Range, string]>*/ = [];
|
2017-02-19 20:36:32 +00:00
|
|
|
var sharedf = [];
|
2017-04-08 06:55:35 +00:00
|
|
|
var dense = Array.isArray(s);
|
2017-12-30 05:40:35 +00:00
|
|
|
var rows/*:Array<RowInfo>*/ = [], rowobj = {}, rowrite = false;
|
2014-07-28 13:22:32 +00:00
|
|
|
for(var marr = sdata.split(rowregex), mt = 0, marrlen = marr.length; mt != marrlen; ++mt) {
|
2014-06-29 18:29:45 +00:00
|
|
|
x = marr[mt].trim();
|
2014-07-28 13:22:32 +00:00
|
|
|
var xlen = x.length;
|
|
|
|
if(xlen === 0) continue;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
/* 18.3.1.73 row CT_Row */
|
2014-07-28 13:22:32 +00:00
|
|
|
for(ri = 0; ri < xlen; ++ri) if(x.charCodeAt(ri) === 62) break; ++ri;
|
2018-01-11 08:01:25 +00:00
|
|
|
tag = parsexmltag(x.slice(0,ri), true);
|
2017-04-26 02:27:12 +00:00
|
|
|
tagr = tag.r != null ? parseInt(tag.r, 10) : tagr+1; tagc = -1;
|
2014-07-28 13:22:32 +00:00
|
|
|
if(opts.sheetRows && opts.sheetRows < tagr) continue;
|
|
|
|
if(guess.s.r > tagr - 1) guess.s.r = tagr - 1;
|
|
|
|
if(guess.e.r < tagr - 1) guess.e.r = tagr - 1;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
2017-04-28 07:28:03 +00:00
|
|
|
if(opts && opts.cellStyles) {
|
|
|
|
rowobj = {}; rowrite = false;
|
|
|
|
if(tag.ht) { rowrite = true; rowobj.hpt = parseFloat(tag.ht); rowobj.hpx = pt2px(rowobj.hpt); }
|
|
|
|
if(tag.hidden == "1") { rowrite = true; rowobj.hidden = true; }
|
2017-07-09 17:37:45 +00:00
|
|
|
if(tag.outlineLevel != null) { rowrite = true; rowobj.level = +tag.outlineLevel; }
|
2017-04-28 07:28:03 +00:00
|
|
|
if(rowrite) rows[tagr-1] = rowobj;
|
|
|
|
}
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
/* 18.3.1.4 c CT_Cell */
|
2018-01-11 08:01:25 +00:00
|
|
|
cells = x.slice(ri).split(cellregex);
|
2017-02-22 06:57:59 +00:00
|
|
|
for(ri = 0; ri != cells.length; ++ri) {
|
2014-06-29 18:29:45 +00:00
|
|
|
x = cells[ri].trim();
|
|
|
|
if(x.length === 0) continue;
|
|
|
|
cref = x.match(rregex); idx = ri; i=0; cc=0;
|
2018-01-11 08:01:25 +00:00
|
|
|
x = "<c " + (x.slice(0,1)=="<"?">":"") + x;
|
2017-02-10 19:23:01 +00:00
|
|
|
if(cref != null && cref.length === 2) {
|
2014-06-29 18:29:45 +00:00
|
|
|
idx = 0; d=cref[1];
|
|
|
|
for(i=0; i != d.length; ++i) {
|
|
|
|
if((cc=d.charCodeAt(i)-64) < 1 || cc > 26) break;
|
|
|
|
idx = 26*idx + cc;
|
|
|
|
}
|
|
|
|
--idx;
|
2014-10-10 02:22:38 +00:00
|
|
|
tagc = idx;
|
|
|
|
} else ++tagc;
|
2014-06-29 18:29:45 +00:00
|
|
|
for(i = 0; i != x.length; ++i) if(x.charCodeAt(i) === 62) break; ++i;
|
2018-01-11 08:01:25 +00:00
|
|
|
tag = parsexmltag(x.slice(0,i), true);
|
2017-04-17 02:08:23 +00:00
|
|
|
if(!tag.r) tag.r = encode_cell({r:tagr-1, c:tagc});
|
2018-01-11 08:01:25 +00:00
|
|
|
d = x.slice(i);
|
2017-02-10 19:23:01 +00:00
|
|
|
p = ({t:""}/*:any*/);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
2017-02-19 20:36:32 +00:00
|
|
|
if((cref=d.match(match_v))!= null && /*::cref != null && */cref[1] !== '') p.v=unescapexml(cref[1]);
|
|
|
|
if(opts.cellFormula) {
|
|
|
|
if((cref=d.match(match_f))!= null && /*::cref != null && */cref[1] !== '') {
|
2017-03-18 00:45:06 +00:00
|
|
|
/* TODO: match against XLSXFutureFunctions */
|
2017-12-30 05:40:35 +00:00
|
|
|
p.f=_xlfn(unescapexml(utf8read(cref[1])));
|
2017-02-19 20:36:32 +00:00
|
|
|
if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="array"') > -1) {
|
|
|
|
p.F = (d.match(refregex)||[])[1];
|
|
|
|
if(p.F.indexOf(":") > -1) arrayf.push([safe_decode_range(p.F), p.F]);
|
|
|
|
} else if(/*::cref != null && cref[0] != null && */cref[0].indexOf('t="shared"') > -1) {
|
|
|
|
// TODO: parse formula
|
|
|
|
ftag = parsexmltag(cref[0]);
|
2017-12-30 05:40:35 +00:00
|
|
|
sharedf[parseInt(ftag.si, 10)] = [ftag, _xlfn(unescapexml(utf8read(cref[1])))];
|
2017-02-19 20:36:32 +00:00
|
|
|
}
|
|
|
|
} else if((cref=d.match(/<f[^>]*\/>/))) {
|
|
|
|
ftag = parsexmltag(cref[0]);
|
|
|
|
if(sharedf[ftag.si]) p.f = shift_formula_xlsx(sharedf[ftag.si][1], sharedf[ftag.si][0].ref, tag.r);
|
|
|
|
}
|
|
|
|
/* TODO: factor out contains logic */
|
|
|
|
var _tag = decode_cell(tag.r);
|
|
|
|
for(i = 0; i < arrayf.length; ++i)
|
|
|
|
if(_tag.r >= arrayf[i][0].s.r && _tag.r <= arrayf[i][0].e.r)
|
|
|
|
if(_tag.c >= arrayf[i][0].s.c && _tag.c <= arrayf[i][0].e.c)
|
|
|
|
p.F = arrayf[i][1];
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
2017-04-26 02:27:12 +00:00
|
|
|
if(tag.t == null && p.v === undefined) {
|
2017-05-11 07:29:59 +00:00
|
|
|
if(p.f || p.F) {
|
|
|
|
p.v = 0; p.t = "n";
|
|
|
|
} else if(!opts.sheetStubs) continue;
|
|
|
|
else p.t = "z";
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
|
|
|
else p.t = tag.t || "n";
|
|
|
|
if(guess.s.c > idx) guess.s.c = idx;
|
|
|
|
if(guess.e.c < idx) guess.e.c = idx;
|
|
|
|
/* 18.18.11 t ST_CellType */
|
|
|
|
switch(p.t) {
|
2017-03-21 20:44:35 +00:00
|
|
|
case 'n':
|
2017-11-20 01:51:14 +00:00
|
|
|
if(p.v == "" || p.v == null) {
|
|
|
|
if(!opts.sheetStubs) continue;
|
|
|
|
p.t = 'z';
|
|
|
|
} else p.v = parseFloat(p.v);
|
2017-03-21 20:44:35 +00:00
|
|
|
break;
|
2014-06-29 18:29:45 +00:00
|
|
|
case 's':
|
2017-03-10 01:09:18 +00:00
|
|
|
if(typeof p.v == 'undefined') {
|
|
|
|
if(!opts.sheetStubs) continue;
|
2017-03-15 08:19:02 +00:00
|
|
|
p.t = 'z';
|
2017-07-05 22:27:54 +00:00
|
|
|
} else {
|
|
|
|
sstr = strs[parseInt(p.v, 10)];
|
|
|
|
p.v = sstr.t;
|
|
|
|
p.r = sstr.r;
|
|
|
|
if(opts.cellHTML) p.h = sstr.h;
|
2017-03-10 01:09:18 +00:00
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
break;
|
2014-10-26 05:26:18 +00:00
|
|
|
case 'str':
|
|
|
|
p.t = "s";
|
|
|
|
p.v = (p.v!=null) ? utf8read(p.v) : '';
|
2017-04-13 18:28:16 +00:00
|
|
|
if(opts.cellHTML) p.h = escapehtml(p.v);
|
2014-10-26 05:26:18 +00:00
|
|
|
break;
|
2014-06-29 18:29:45 +00:00
|
|
|
case 'inlineStr':
|
|
|
|
cref = d.match(isregex);
|
2014-10-26 05:26:18 +00:00
|
|
|
p.t = 's';
|
2017-03-13 06:46:37 +00:00
|
|
|
if(cref != null && (sstr = parse_si(cref[1]))) p.v = sstr.t; else p.v = "";
|
2017-04-10 05:10:54 +00:00
|
|
|
break;
|
2014-06-29 18:29:45 +00:00
|
|
|
case 'b': p.v = parsexmlbool(p.v); break;
|
|
|
|
case 'd':
|
2017-06-01 21:22:11 +00:00
|
|
|
if(opts.cellDates) p.v = parseDate(p.v, 1);
|
|
|
|
else { p.v = datenum(parseDate(p.v, 1)); p.t = 'n'; }
|
2014-06-29 18:29:45 +00:00
|
|
|
break;
|
2017-03-21 20:44:35 +00:00
|
|
|
/* error string in .w, number in .v */
|
2017-04-21 22:02:02 +00:00
|
|
|
case 'e':
|
2017-04-26 02:27:12 +00:00
|
|
|
if(!opts || opts.cellText !== false) p.w = p.v;
|
2017-04-21 22:02:02 +00:00
|
|
|
p.v = RBErr[p.v]; break;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
|
|
|
/* formatting */
|
|
|
|
fmtid = fillid = 0;
|
|
|
|
if(do_format && tag.s !== undefined) {
|
|
|
|
cf = styles.CellXf[tag.s];
|
|
|
|
if(cf != null) {
|
|
|
|
if(cf.numFmtId != null) fmtid = cf.numFmtId;
|
2017-07-10 22:18:18 +00:00
|
|
|
if(opts.cellStyles) {
|
|
|
|
if(cf.fillId != null) fillid = cf.fillId;
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-18 23:25:50 +00:00
|
|
|
safe_format(p, fmtid, fillid, opts, themes, styles);
|
2017-06-01 21:22:11 +00:00
|
|
|
if(opts.cellDates && do_format && p.t == 'n' && SSF.is_date(SSF._table[fmtid])) { p.t = 'd'; p.v = numdate(p.v); }
|
2017-04-08 06:55:35 +00:00
|
|
|
if(dense) {
|
|
|
|
var _r = decode_cell(tag.r);
|
|
|
|
if(!s[_r.r]) s[_r.r] = [];
|
|
|
|
s[_r.r][_r.c] = p;
|
|
|
|
} else s[tag.r] = p;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-28 07:28:03 +00:00
|
|
|
if(rows.length > 0) s['!rows'] = rows;
|
2014-06-29 18:29:45 +00:00
|
|
|
}; })();
|
|
|
|
|
2018-01-23 09:07:51 +00:00
|
|
|
function write_ws_xml_data(ws/*:Worksheet*/, opts, idx/*:number*/, wb/*:Workbook*//*::, rels*/)/*:string*/ {
|
2017-12-30 05:40:35 +00:00
|
|
|
var o/*:Array<string>*/ = [], r/*:Array<string>*/ = [], range = safe_decode_range(ws['!ref']), cell="", ref, rr = "", cols/*:Array<string>*/ = [], R=0, C=0, rows = ws['!rows'];
|
2017-04-08 06:55:35 +00:00
|
|
|
var dense = Array.isArray(ws);
|
2017-10-17 00:14:32 +00:00
|
|
|
var params = ({r:rr}/*:any*/), row/*:RowInfo*/, height = -1;
|
2014-07-28 13:22:32 +00:00
|
|
|
for(C = range.s.c; C <= range.e.c; ++C) cols[C] = encode_col(C);
|
|
|
|
for(R = range.s.r; R <= range.e.r; ++R) {
|
2014-05-16 00:33:34 +00:00
|
|
|
r = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
rr = encode_row(R);
|
2014-07-28 13:22:32 +00:00
|
|
|
for(C = range.s.c; C <= range.e.c; ++C) {
|
2014-06-29 18:29:45 +00:00
|
|
|
ref = cols[C] + rr;
|
2017-04-08 06:55:35 +00:00
|
|
|
var _cell = dense ? (ws[R]||[])[C]: ws[ref];
|
|
|
|
if(_cell === undefined) continue;
|
|
|
|
if((cell = write_ws_xml_cell(_cell, ref, ws, opts, idx, wb)) != null) r.push(cell);
|
2014-05-16 00:33:34 +00:00
|
|
|
}
|
2018-02-08 18:21:39 +00:00
|
|
|
if(r.length > 0 || (rows && rows[R])) {
|
2017-10-17 00:14:32 +00:00
|
|
|
params = ({r:rr}/*:any*/);
|
2017-03-31 03:57:11 +00:00
|
|
|
if(rows && rows[R]) {
|
2017-10-17 00:14:32 +00:00
|
|
|
row = rows[R];
|
2017-03-31 03:57:11 +00:00
|
|
|
if(row.hidden) params.hidden = 1;
|
2017-10-17 00:14:32 +00:00
|
|
|
height = -1;
|
2017-03-31 03:57:11 +00:00
|
|
|
if (row.hpx) height = px2pt(row.hpx);
|
|
|
|
else if (row.hpt) height = row.hpt;
|
|
|
|
if (height > -1) { params.ht = height; params.customHeight = 1; }
|
2017-07-09 17:37:45 +00:00
|
|
|
if (row.level) { params.outlineLevel = row.level; }
|
2017-03-31 03:57:11 +00:00
|
|
|
}
|
|
|
|
o[o.length] = (writextag('row', r.join(""), params));
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
}
|
2017-07-09 17:37:45 +00:00
|
|
|
if(rows) for(; R < rows.length; ++R) {
|
|
|
|
if(rows && rows[R]) {
|
2017-07-26 08:35:28 +00:00
|
|
|
params = ({r:R+1}/*:any*/);
|
|
|
|
row = rows[R];
|
2017-07-09 17:37:45 +00:00
|
|
|
if(row.hidden) params.hidden = 1;
|
2017-07-26 08:35:28 +00:00
|
|
|
height = -1;
|
2017-07-09 17:37:45 +00:00
|
|
|
if (row.hpx) height = px2pt(row.hpx);
|
|
|
|
else if (row.hpt) height = row.hpt;
|
|
|
|
if (height > -1) { params.ht = height; params.customHeight = 1; }
|
|
|
|
if (row.level) { params.outlineLevel = row.level; }
|
|
|
|
o[o.length] = (writextag('row', "", params));
|
|
|
|
}
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
return o.join("");
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
2014-06-05 07:06:20 +00:00
|
|
|
var WS_XML_ROOT = writextag('worksheet', null, {
|
|
|
|
'xmlns': XMLNS.main[0],
|
|
|
|
'xmlns:r': XMLNS.r
|
|
|
|
});
|
2014-06-02 05:19:07 +00:00
|
|
|
|
2017-03-31 00:47:35 +00:00
|
|
|
function write_ws_xml(idx/*:number*/, opts, wb/*:Workbook*/, rels)/*:string*/ {
|
2014-06-29 18:29:45 +00:00
|
|
|
var o = [XML_HEADER, WS_XML_ROOT];
|
2014-07-28 13:22:32 +00:00
|
|
|
var s = wb.SheetNames[idx], sidx = 0, rdata = "";
|
|
|
|
var ws = wb.Sheets[s];
|
2017-04-10 05:10:54 +00:00
|
|
|
if(ws == null) ws = {};
|
2018-04-27 20:11:18 +00:00
|
|
|
var ref = ws['!ref'] || 'A1';
|
|
|
|
var range = safe_decode_range(ref);
|
|
|
|
if(range.e.c > 0x3FFF || range.e.r > 0xFFFFF) {
|
|
|
|
if(opts.WTF) throw new Error("Range " + ref + " exceeds format limit A1:XFD1048576");
|
|
|
|
range.e.c = Math.min(range.e.c, 0x3FFF);
|
|
|
|
range.e.r = Math.min(range.e.c, 0xFFFFF);
|
|
|
|
ref = encode_range(range);
|
|
|
|
}
|
2017-03-31 00:47:35 +00:00
|
|
|
if(!rels) rels = {};
|
2017-04-02 06:47:25 +00:00
|
|
|
ws['!comments'] = [];
|
2017-04-08 06:55:35 +00:00
|
|
|
ws['!drawing'] = [];
|
2017-03-31 00:47:35 +00:00
|
|
|
|
2018-02-14 20:06:35 +00:00
|
|
|
if(opts.bookType !== 'xlsx' && wb.vbaraw) {
|
|
|
|
var cname = wb.SheetNames[idx];
|
|
|
|
try { if(wb.Workbook) cname = wb.Workbook.Sheets[idx].CodeName || cname; } catch(e) {}
|
|
|
|
o[o.length] = (writextag('sheetPr', null, {'codeName': escapexml(cname)}));
|
|
|
|
}
|
2017-04-10 05:10:54 +00:00
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
o[o.length] = (writextag('dimension', null, {'ref': ref}));
|
|
|
|
|
2017-04-28 07:28:03 +00:00
|
|
|
o[o.length] = write_ws_xml_sheetviews(ws, opts, idx, wb);
|
2017-04-10 05:10:54 +00:00
|
|
|
|
2017-03-31 03:23:52 +00:00
|
|
|
/* TODO: store in WB, process styles */
|
2017-07-09 17:37:45 +00:00
|
|
|
if(opts.sheetFormat) o[o.length] = (writextag('sheetFormatPr', null, {
|
|
|
|
defaultRowHeight:opts.sheetFormat.defaultRowHeight||'16',
|
|
|
|
baseColWidth:opts.sheetFormat.baseColWidth||'10',
|
|
|
|
outlineLevelRow:opts.sheetFormat.outlineLevelRow||'7'
|
|
|
|
}));
|
2017-03-31 03:23:52 +00:00
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
if(ws['!cols'] != null && ws['!cols'].length > 0) o[o.length] = (write_ws_xml_cols(ws, ws['!cols']));
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
o[sidx = o.length] = '<sheetData/>';
|
2017-03-31 00:47:35 +00:00
|
|
|
ws['!links'] = [];
|
2017-03-28 22:03:03 +00:00
|
|
|
if(ws['!ref'] != null) {
|
2017-03-31 00:47:35 +00:00
|
|
|
rdata = write_ws_xml_data(ws, opts, idx, wb, rels);
|
2014-07-28 13:22:32 +00:00
|
|
|
if(rdata.length > 0) o[o.length] = (rdata);
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
if(o.length>sidx+1) { o[o.length] = ('</sheetData>'); o[sidx]=o[sidx].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* sheetCalcPr */
|
|
|
|
|
2017-04-04 18:41:11 +00:00
|
|
|
if(ws['!protect'] != null) o[o.length] = write_ws_xml_protection(ws['!protect']);
|
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* protectedRanges */
|
|
|
|
/* scenarios */
|
|
|
|
|
|
|
|
if(ws['!autofilter'] != null) o[o.length] = write_ws_xml_autofilter(ws['!autofilter']);
|
|
|
|
|
|
|
|
/* sortState */
|
|
|
|
/* dataConsolidate */
|
|
|
|
/* customSheetViews */
|
|
|
|
|
2017-03-28 22:03:03 +00:00
|
|
|
if(ws['!merges'] != null && ws['!merges'].length > 0) o[o.length] = (write_ws_xml_merges(ws['!merges']));
|
2014-08-26 17:40:04 +00:00
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* phoneticPr */
|
|
|
|
/* conditionalFormatting */
|
|
|
|
/* dataValidations */
|
|
|
|
|
2017-04-02 06:47:25 +00:00
|
|
|
var relc = -1, rel, rId = -1;
|
2017-03-31 00:47:35 +00:00
|
|
|
if(ws['!links'].length > 0) {
|
|
|
|
o[o.length] = "<hyperlinks>";
|
|
|
|
ws['!links'].forEach(function(l) {
|
|
|
|
if(!l[1].Target) return;
|
2017-12-15 01:18:40 +00:00
|
|
|
rel = ({"ref":l[0]}/*:any*/);
|
|
|
|
if(l[1].Target.charAt(0) != "#") {
|
|
|
|
rId = add_rels(rels, -1, escapexml(l[1].Target).replace(/#.*$/, ""), RELS.HLINK);
|
|
|
|
rel["r:id"] = "rId"+rId;
|
|
|
|
}
|
2018-01-11 08:01:25 +00:00
|
|
|
if((relc = l[1].Target.indexOf("#")) > -1) rel.location = escapexml(l[1].Target.slice(relc+1));
|
2017-03-31 00:47:35 +00:00
|
|
|
if(l[1].Tooltip) rel.tooltip = escapexml(l[1].Tooltip);
|
|
|
|
o[o.length] = writextag("hyperlink",null,rel);
|
|
|
|
});
|
|
|
|
o[o.length] = "</hyperlinks>";
|
|
|
|
}
|
2017-03-28 22:03:03 +00:00
|
|
|
delete ws['!links'];
|
2017-04-02 06:47:25 +00:00
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* printOptions */
|
2017-04-28 07:28:03 +00:00
|
|
|
if (ws['!margins'] != null) o[o.length] = write_ws_xml_margins(ws['!margins']);
|
2017-04-10 05:10:54 +00:00
|
|
|
/* pageSetup */
|
|
|
|
|
2018-01-23 09:07:51 +00:00
|
|
|
//var hfidx = o.length;
|
2017-04-08 06:55:35 +00:00
|
|
|
o[o.length] = "";
|
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* rowBreaks */
|
|
|
|
/* colBreaks */
|
|
|
|
/* customProperties */
|
|
|
|
/* cellWatches */
|
2018-02-14 20:06:35 +00:00
|
|
|
|
|
|
|
o[o.length] = writetag("ignoredErrors", writextag("ignoredError", null, {numberStoredAsText:1, sqref:ref}));
|
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* smartTags */
|
|
|
|
|
2017-04-08 06:55:35 +00:00
|
|
|
if(ws['!drawing'].length > 0) {
|
|
|
|
rId = add_rels(rels, -1, "../drawings/drawing" + (idx+1) + ".xml", RELS.DRAW);
|
|
|
|
o[o.length] = writextag("drawing", null, {"r:id":"rId" + rId});
|
|
|
|
}
|
|
|
|
else delete ws['!drawing'];
|
2017-04-10 05:10:54 +00:00
|
|
|
|
2017-04-02 06:47:25 +00:00
|
|
|
if(ws['!comments'].length > 0) {
|
|
|
|
rId = add_rels(rels, -1, "../drawings/vmlDrawing" + (idx+1) + ".vml", RELS.VML);
|
|
|
|
o[o.length] = writextag("legacyDrawing", null, {"r:id":"rId" + rId});
|
|
|
|
ws['!legacy'] = rId;
|
|
|
|
}
|
|
|
|
|
2017-04-10 05:10:54 +00:00
|
|
|
/* drawingHF */
|
|
|
|
/* picture */
|
|
|
|
/* oleObjects */
|
|
|
|
/* controls */
|
|
|
|
/* webPublishItems */
|
|
|
|
/* tableParts */
|
|
|
|
/* extList */
|
|
|
|
|
2017-03-31 00:47:35 +00:00
|
|
|
if(o.length>2) { o[o.length] = ('</worksheet>'); o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
return o.join("");
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|