2014-06-02 05:19:07 +00:00
|
|
|
var strs = {}; // shared strings
|
|
|
|
var _ssfopts = {}; // spreadsheet formatting options
|
|
|
|
|
|
|
|
RELS.WS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
|
|
|
|
|
|
|
|
function get_sst_id(sst, str) {
|
2014-07-28 13:22:32 +00:00
|
|
|
for(var i = 0, len = sst.length; i < len; ++i) if(sst[i].t === str) { sst.Count ++; return i; }
|
|
|
|
sst[len] = {t:str}; sst.Count ++; sst.Unique ++; return len;
|
2014-06-02 05:19:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_cell_style(styles, cell, opts) {
|
2015-02-28 06:42:41 +00:00
|
|
|
if (typeof style_builder != 'undefined') {
|
2015-03-05 17:18:36 +00:00
|
|
|
if (/^\d+$/.exec(cell.s)) { return cell.s} // if its already an integer index, let it be
|
2015-02-28 06:42:41 +00:00
|
|
|
if (cell.s && (cell.s == +cell.s)) { return cell.s} // if its already an integer index, let it be
|
|
|
|
if (!cell.s) cell.s = {}
|
2015-03-02 05:28:11 +00:00
|
|
|
if (cell.z) cell.s.numFmt = cell.z;
|
2015-02-28 06:42:41 +00:00
|
|
|
cell.s = style_builder.addStyle(cell.s);
|
|
|
|
|
|
|
|
return cell.s;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var z = opts.revssf[cell.z != null ? cell.z : "General"];
|
|
|
|
for(var i = 0, len = styles.length; i != len; ++i) if(styles[i].numFmtId === z) return i;
|
|
|
|
styles[len] = {
|
|
|
|
numFmtId:z,
|
|
|
|
fontId:0,
|
|
|
|
fillId:0,
|
|
|
|
borderId:0,
|
|
|
|
xfId:0,
|
|
|
|
applyNumberFormat:1
|
|
|
|
};
|
|
|
|
return len;
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
}
|
|
|
|
|
2015-03-28 16:32:46 +00:00
|
|
|
function get_cell_style_csf(cellXf) {
|
|
|
|
|
|
|
|
if (cellXf) {
|
|
|
|
var s = {}
|
|
|
|
|
|
|
|
if (typeof cellXf.numFmtId != undefined) {
|
|
|
|
s.numFmt = SSF._table[cellXf.numFmtId];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cellXf.fillId) {
|
|
|
|
s.fill = styles.Fills[cellXf.fillId];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cellXf.fontId) {
|
|
|
|
s.font = styles.Fonts[cellXf.fontId];
|
|
|
|
}
|
|
|
|
if (cellXf.borderId) {
|
|
|
|
// s.border = styles.Borders[cellXf.borderId];
|
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
function safe_format(p, fmtid, fillid, opts) {
|
|
|
|
try {
|
2014-10-26 05:26:18 +00:00
|
|
|
if(p.t === 'e') p.w = p.w || BErr[p.v];
|
|
|
|
else if(fmtid === 0) {
|
2014-06-29 18:29:45 +00:00
|
|
|
if(p.t === 'n') {
|
|
|
|
if((p.v|0) === p.v) p.w = SSF._general_int(p.v,_ssfopts);
|
|
|
|
else p.w = SSF._general_num(p.v,_ssfopts);
|
|
|
|
}
|
2014-10-26 05:26:18 +00:00
|
|
|
else if(p.t === 'd') {
|
|
|
|
var dd = datenum(p.v);
|
|
|
|
if((dd|0) === dd) p.w = SSF._general_int(dd,_ssfopts);
|
|
|
|
else p.w = SSF._general_num(dd,_ssfopts);
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
else if(p.v === undefined) return "";
|
|
|
|
else p.w = SSF._general(p.v,_ssfopts);
|
|
|
|
}
|
2014-10-26 05:26:18 +00:00
|
|
|
else if(p.t === 'd') p.w = SSF.format(fmtid,datenum(p.v),_ssfopts);
|
2014-06-29 18:29:45 +00:00
|
|
|
else p.w = SSF.format(fmtid,p.v,_ssfopts);
|
2014-06-02 05:19:07 +00:00
|
|
|
if(opts.cellNF) p.z = SSF._table[fmtid];
|
|
|
|
} catch(e) { if(opts.WTF) throw e; }
|
|
|
|
}
|