2014-01-22 04:58:26 +00:00
|
|
|
|
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
|
2013-03-27 18:37:22 +00:00
|
|
|
|
/* vim: set ts=2: */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
/*jshint -W041 */
|
2014-04-15 09:04:03 +00:00
|
|
|
|
var XLSX = {};
|
|
|
|
|
(function(XLSX){
|
2014-10-10 02:22:38 +00:00
|
|
|
|
XLSX.version = '0.7.11';
|
2014-05-03 18:51:10 +00:00
|
|
|
|
var current_codepage = 1252, current_cptable;
|
|
|
|
|
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
2014-05-25 09:04:08 +00:00
|
|
|
|
if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel');
|
2014-05-03 18:51:10 +00:00
|
|
|
|
current_cptable = cptable[current_codepage];
|
|
|
|
|
}
|
|
|
|
|
function reset_cp() { set_cp(1252); }
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var set_cp = function(cp) { current_codepage = cp; };
|
2014-05-03 18:51:10 +00:00
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
function char_codes(data) { var o = []; for(var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i); return o; }
|
|
|
|
|
var debom_xml = function(data) { return data; };
|
|
|
|
|
|
|
|
|
|
if(typeof cptable !== 'undefined') {
|
|
|
|
|
set_cp = function(cp) { current_codepage = cp; current_cptable = cptable[cp]; };
|
|
|
|
|
debom_xml = function(data) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.substr(2))); }
|
2014-07-28 13:22:32 +00:00
|
|
|
|
return data;
|
|
|
|
|
};
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
2014-01-23 06:20:19 +00:00
|
|
|
|
/* ssf.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
/*jshint -W041 */
|
2013-12-16 16:32:34 +00:00
|
|
|
|
var SSF = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var make_ssf = function make_ssf(SSF){
|
|
|
|
|
SSF.version = '0.8.1';
|
|
|
|
|
function _strrev(x) { var o = "", i = x.length-1; while(i>=0) o += x.charAt(i--); return o; }
|
|
|
|
|
function fill(c,l) { var o = ""; while(o.length < l) o+=c; return o; }
|
|
|
|
|
function pad0(v,d){var t=""+v; return t.length>=d?t:fill('0',d-t.length)+t;}
|
|
|
|
|
function pad_(v,d){var t=""+v;return t.length>=d?t:fill(' ',d-t.length)+t;}
|
|
|
|
|
function rpad_(v,d){var t=""+v; return t.length>=d?t:t+fill(' ',d-t.length);}
|
|
|
|
|
function pad0r1(v,d){var t=""+Math.round(v); return t.length>=d?t:fill('0',d-t.length)+t;}
|
|
|
|
|
function pad0r2(v,d){var t=""+v; return t.length>=d?t:fill('0',d-t.length)+t;}
|
|
|
|
|
var p2_32 = Math.pow(2,32);
|
|
|
|
|
function pad0r(v,d){if(v>p2_32||v<-p2_32) return pad0r1(v,d); var i = Math.round(v); return pad0r2(i,d); }
|
|
|
|
|
function isgeneral(s, i) { return s.length >= 7 + i && (s.charCodeAt(i)|32) === 103 && (s.charCodeAt(i+1)|32) === 101 && (s.charCodeAt(i+2)|32) === 110 && (s.charCodeAt(i+3)|32) === 101 && (s.charCodeAt(i+4)|32) === 114 && (s.charCodeAt(i+5)|32) === 97 && (s.charCodeAt(i+6)|32) === 108; }
|
2013-03-26 23:54:14 +00:00
|
|
|
|
/* Options */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var opts_fmt = [
|
|
|
|
|
["date1904", 0],
|
|
|
|
|
["output", ""],
|
|
|
|
|
["WTF", false]
|
|
|
|
|
];
|
|
|
|
|
function fixopts(o){
|
|
|
|
|
for(var y = 0; y != opts_fmt.length; ++y) if(o[opts_fmt[y][0]]===undefined) o[opts_fmt[y][0]]=opts_fmt[y][1];
|
|
|
|
|
}
|
2013-03-26 23:54:14 +00:00
|
|
|
|
SSF.opts = opts_fmt;
|
|
|
|
|
var table_fmt = {
|
2014-01-23 06:20:19 +00:00
|
|
|
|
0: 'General',
|
2013-03-26 23:54:14 +00:00
|
|
|
|
1: '0',
|
|
|
|
|
2: '0.00',
|
|
|
|
|
3: '#,##0',
|
|
|
|
|
4: '#,##0.00',
|
|
|
|
|
9: '0%',
|
|
|
|
|
10: '0.00%',
|
|
|
|
|
11: '0.00E+00',
|
|
|
|
|
12: '# ?/?',
|
|
|
|
|
13: '# ??/??',
|
2013-12-27 03:15:16 +00:00
|
|
|
|
14: 'm/d/yy',
|
2013-03-26 23:54:14 +00:00
|
|
|
|
15: 'd-mmm-yy',
|
|
|
|
|
16: 'd-mmm',
|
|
|
|
|
17: 'mmm-yy',
|
|
|
|
|
18: 'h:mm AM/PM',
|
|
|
|
|
19: 'h:mm:ss AM/PM',
|
|
|
|
|
20: 'h:mm',
|
|
|
|
|
21: 'h:mm:ss',
|
|
|
|
|
22: 'm/d/yy h:mm',
|
|
|
|
|
37: '#,##0 ;(#,##0)',
|
|
|
|
|
38: '#,##0 ;[Red](#,##0)',
|
|
|
|
|
39: '#,##0.00;(#,##0.00)',
|
|
|
|
|
40: '#,##0.00;[Red](#,##0.00)',
|
|
|
|
|
45: 'mm:ss',
|
|
|
|
|
46: '[h]:mm:ss',
|
|
|
|
|
47: 'mmss.0',
|
|
|
|
|
48: '##0.0E+0',
|
2014-01-23 06:20:19 +00:00
|
|
|
|
49: '@',
|
|
|
|
|
56: '"上午/下午 "hh"時"mm"分"ss"秒 "',
|
|
|
|
|
65535: 'General'
|
2013-03-26 23:54:14 +00:00
|
|
|
|
};
|
|
|
|
|
var days = [
|
|
|
|
|
['Sun', 'Sunday'],
|
|
|
|
|
['Mon', 'Monday'],
|
|
|
|
|
['Tue', 'Tuesday'],
|
|
|
|
|
['Wed', 'Wednesday'],
|
|
|
|
|
['Thu', 'Thursday'],
|
|
|
|
|
['Fri', 'Friday'],
|
|
|
|
|
['Sat', 'Saturday']
|
|
|
|
|
];
|
|
|
|
|
var months = [
|
|
|
|
|
['J', 'Jan', 'January'],
|
|
|
|
|
['F', 'Feb', 'February'],
|
|
|
|
|
['M', 'Mar', 'March'],
|
|
|
|
|
['A', 'Apr', 'April'],
|
|
|
|
|
['M', 'May', 'May'],
|
|
|
|
|
['J', 'Jun', 'June'],
|
|
|
|
|
['J', 'Jul', 'July'],
|
|
|
|
|
['A', 'Aug', 'August'],
|
|
|
|
|
['S', 'Sep', 'September'],
|
|
|
|
|
['O', 'Oct', 'October'],
|
|
|
|
|
['N', 'Nov', 'November'],
|
2013-04-17 01:32:20 +00:00
|
|
|
|
['D', 'Dec', 'December']
|
2013-03-26 23:54:14 +00:00
|
|
|
|
];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function frac(x, D, mixed) {
|
2013-12-27 03:15:16 +00:00
|
|
|
|
var sgn = x < 0 ? -1 : 1;
|
|
|
|
|
var B = x * sgn;
|
|
|
|
|
var P_2 = 0, P_1 = 1, P = 0;
|
|
|
|
|
var Q_2 = 1, Q_1 = 0, Q = 0;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
var A = Math.floor(B);
|
2013-12-27 03:15:16 +00:00
|
|
|
|
while(Q_1 < D) {
|
2014-01-23 06:20:19 +00:00
|
|
|
|
A = Math.floor(B);
|
2013-12-27 03:15:16 +00:00
|
|
|
|
P = A * P_1 + P_2;
|
|
|
|
|
Q = A * Q_1 + Q_2;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
if((B - A) < 0.0000000005) break;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
B = 1 / (B - A);
|
|
|
|
|
P_2 = P_1; P_1 = P;
|
|
|
|
|
Q_2 = Q_1; Q_1 = Q;
|
|
|
|
|
}
|
|
|
|
|
if(Q > D) { Q = Q_1; P = P_1; }
|
|
|
|
|
if(Q > D) { Q = Q_2; P = P_2; }
|
|
|
|
|
if(!mixed) return [0, sgn * P, Q];
|
2014-01-23 06:20:19 +00:00
|
|
|
|
if(Q===0) throw "Unexpected state: "+P+" "+P_1+" "+P_2+" "+Q+" "+Q_1+" "+Q_2;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
var q = Math.floor(sgn * P/Q);
|
|
|
|
|
return [q, sgn*P - q*Q, Q];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
function general_fmt_int(v, opts) { return ""+v; }
|
|
|
|
|
SSF._general_int = general_fmt_int;
|
|
|
|
|
var general_fmt_num = (function make_general_fmt_num() {
|
|
|
|
|
var gnr1 = /\.(\d*[1-9])0+$/, gnr2 = /\.0*$/, gnr4 = /\.(\d*[1-9])0+/, gnr5 = /\.0*[Ee]/, gnr6 = /(E[+-])(\d)$/;
|
|
|
|
|
function gfn2(v) {
|
|
|
|
|
var w = (v<0?12:11);
|
|
|
|
|
var o = gfn5(v.toFixed(12)); if(o.length <= w) return o;
|
|
|
|
|
o = v.toPrecision(10); if(o.length <= w) return o;
|
|
|
|
|
return v.toExponential(5);
|
|
|
|
|
}
|
|
|
|
|
function gfn3(v) {
|
|
|
|
|
var o = v.toFixed(11).replace(gnr1,".$1");
|
|
|
|
|
if(o.length > (v<0?12:11)) o = v.toPrecision(6);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
function gfn4(o) {
|
|
|
|
|
for(var i = 0; i != o.length; ++i) if((o.charCodeAt(i) | 0x20) === 101) return o.replace(gnr4,".$1").replace(gnr5,"E").replace("e","E").replace(gnr6,"$10$2");
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
function gfn5(o) {
|
|
|
|
|
//for(var i = 0; i != o.length; ++i) if(o.charCodeAt(i) === 46) return o.replace(gnr2,"").replace(gnr1,".$1");
|
|
|
|
|
//return o;
|
|
|
|
|
return o.indexOf(".") > -1 ? o.replace(gnr2,"").replace(gnr1,".$1") : o;
|
|
|
|
|
}
|
|
|
|
|
return function general_fmt_num(v, opts) {
|
|
|
|
|
var V = Math.floor(Math.log(Math.abs(v))*Math.LOG10E), o;
|
|
|
|
|
if(V >= -4 && V <= -1) o = v.toPrecision(10+V);
|
|
|
|
|
else if(Math.abs(V) <= 9) o = gfn2(v);
|
|
|
|
|
else if(V === 10) o = v.toFixed(10).substr(0,12);
|
|
|
|
|
else o = gfn3(v);
|
|
|
|
|
return gfn5(gfn4(o));
|
|
|
|
|
};})();
|
|
|
|
|
SSF._general_num = general_fmt_num;
|
|
|
|
|
function general_fmt(v, opts) {
|
|
|
|
|
switch(typeof v) {
|
|
|
|
|
case 'string': return v;
|
|
|
|
|
case 'boolean': return v ? "TRUE" : "FALSE";
|
|
|
|
|
case 'number': return (v|0) === v ? general_fmt_int(v, opts) : general_fmt_num(v, opts);
|
2013-12-27 03:15:16 +00:00
|
|
|
|
}
|
2014-02-17 08:44:22 +00:00
|
|
|
|
throw new Error("unsupported value in General format: " + v);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2013-03-26 23:54:14 +00:00
|
|
|
|
SSF._general = general_fmt;
|
2014-05-03 18:51:10 +00:00
|
|
|
|
function fix_hijri(date, o) { return 0; }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_date_code(v,opts,b2) {
|
|
|
|
|
if(v > 2958465 || v < 0) return null;
|
|
|
|
|
var date = (v|0), time = Math.floor(86400 * (v - date)), dow=0;
|
2014-05-03 18:51:10 +00:00
|
|
|
|
var dout=[];
|
|
|
|
|
var out={D:date, T:time, u:86400*(v-date)-time,y:0,m:0,d:0,H:0,M:0,S:0,q:0};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(Math.abs(out.u) < 1e-6) out.u = 0;
|
|
|
|
|
fixopts(opts != null ? opts : (opts=[]));
|
2013-03-26 23:54:14 +00:00
|
|
|
|
if(opts.date1904) date += 1462;
|
2014-03-29 22:53:15 +00:00
|
|
|
|
if(out.u > 0.999) {
|
2014-03-29 02:05:50 +00:00
|
|
|
|
out.u = 0;
|
|
|
|
|
if(++time == 86400) { time = 0; ++date; }
|
|
|
|
|
}
|
2014-04-03 22:51:54 +00:00
|
|
|
|
if(date === 60) {dout = b2 ? [1317,10,29] : [1900,2,29]; dow=3;}
|
|
|
|
|
else if(date === 0) {dout = b2 ? [1317,8,29] : [1900,1,0]; dow=6;}
|
2013-03-26 23:54:14 +00:00
|
|
|
|
else {
|
|
|
|
|
if(date > 60) --date;
|
|
|
|
|
/* 1 = Jan 1 1900 */
|
|
|
|
|
var d = new Date(1900,0,1);
|
|
|
|
|
d.setDate(d.getDate() + date - 1);
|
|
|
|
|
dout = [d.getFullYear(), d.getMonth()+1,d.getDate()];
|
|
|
|
|
dow = d.getDay();
|
2014-04-03 22:51:54 +00:00
|
|
|
|
if(date < 60) dow = (dow + 6) % 7;
|
|
|
|
|
if(b2) dow = fix_hijri(d, dout);
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
2013-10-30 22:26:31 +00:00
|
|
|
|
out.y = dout[0]; out.m = dout[1]; out.d = dout[2];
|
2013-03-26 23:54:14 +00:00
|
|
|
|
out.S = time % 60; time = Math.floor(time / 60);
|
|
|
|
|
out.M = time % 60; time = Math.floor(time / 60);
|
|
|
|
|
out.H = time;
|
|
|
|
|
out.q = dow;
|
|
|
|
|
return out;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2013-03-26 23:54:14 +00:00
|
|
|
|
SSF.parse_date_code = parse_date_code;
|
2014-01-22 04:58:26 +00:00
|
|
|
|
/*jshint -W086 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_date(type, fmt, val, ss0) {
|
|
|
|
|
var o="", ss=0, tt=0, y = val.y, out, outl = 0;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
switch(type) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 98: /* 'b' buddhist year */
|
|
|
|
|
y = val.y + 543;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
/* falls through */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 121: /* 'y' year */
|
|
|
|
|
switch(fmt.length) {
|
|
|
|
|
case 1: case 2: out = y % 100; outl = 2; break;
|
|
|
|
|
default: out = y % 10000; outl = 4; break;
|
|
|
|
|
} break;
|
|
|
|
|
case 109: /* 'm' month */
|
|
|
|
|
switch(fmt.length) {
|
|
|
|
|
case 1: case 2: out = val.m; outl = fmt.length; break;
|
|
|
|
|
case 3: return months[val.m-1][1];
|
|
|
|
|
case 5: return months[val.m-1][0];
|
2014-02-12 06:09:42 +00:00
|
|
|
|
default: return months[val.m-1][2];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
} break;
|
|
|
|
|
case 100: /* 'd' day */
|
|
|
|
|
switch(fmt.length) {
|
|
|
|
|
case 1: case 2: out = val.d; outl = fmt.length; break;
|
|
|
|
|
case 3: return days[val.q][0];
|
2014-02-12 06:09:42 +00:00
|
|
|
|
default: return days[val.q][1];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
} break;
|
|
|
|
|
case 104: /* 'h' 12-hour */
|
|
|
|
|
switch(fmt.length) {
|
|
|
|
|
case 1: case 2: out = 1+(val.H+11)%12; outl = fmt.length; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
default: throw 'bad hour format: ' + fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
} break;
|
|
|
|
|
case 72: /* 'H' 24-hour */
|
|
|
|
|
switch(fmt.length) {
|
|
|
|
|
case 1: case 2: out = val.H; outl = fmt.length; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
default: throw 'bad hour format: ' + fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
} break;
|
|
|
|
|
case 77: /* 'M' minutes */
|
|
|
|
|
switch(fmt.length) {
|
|
|
|
|
case 1: case 2: out = val.M; outl = fmt.length; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
default: throw 'bad minute format: ' + fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
} break;
|
|
|
|
|
case 115: /* 's' seconds */
|
|
|
|
|
if(val.u === 0) switch(fmt) {
|
|
|
|
|
case 's': case 'ss': return pad0(val.S, fmt.length);
|
|
|
|
|
case '.0': case '.00': case '.000':
|
2014-01-23 06:20:19 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
switch(fmt) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
case 's': case 'ss': case '.0': case '.00': case '.000':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(ss0 >= 2) tt = ss0 === 3 ? 1000 : 100;
|
|
|
|
|
else tt = ss0 === 1 ? 10 : 1;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
ss = Math.round((tt)*(val.S + val.u));
|
|
|
|
|
if(ss >= 60*tt) ss = 0;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(fmt === 's') return ss === 0 ? "0" : ""+ss/tt;
|
|
|
|
|
o = pad0(ss,2 + ss0);
|
|
|
|
|
if(fmt === 'ss') return o.substr(0,2);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
return "." + o.substr(2,fmt.length-1);
|
2013-03-26 23:54:14 +00:00
|
|
|
|
default: throw 'bad second format: ' + fmt;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 90: /* 'Z' absolute time */
|
|
|
|
|
switch(fmt) {
|
|
|
|
|
case '[h]': case '[hh]': out = val.D*24+val.H; break;
|
|
|
|
|
case '[m]': case '[mm]': out = (val.D*24+val.H)*60+val.M; break;
|
|
|
|
|
case '[s]': case '[ss]': out = ((val.D*24+val.H)*60+val.M)*60+Math.round(val.S+val.u); break;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
default: throw 'bad abstime format: ' + fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
} outl = fmt.length === 3 ? 1 : 2; break;
|
|
|
|
|
case 101: /* 'e' era */
|
|
|
|
|
out = y; outl = 1;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(outl > 0) return pad0(out, outl); else return "";
|
|
|
|
|
}
|
2014-01-22 04:58:26 +00:00
|
|
|
|
/*jshint +W086 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function commaify(s) {
|
|
|
|
|
if(s.length <= 3) return s;
|
|
|
|
|
var j = (s.length % 3), o = s.substr(0,j);
|
|
|
|
|
for(; j!=s.length; j+=3) o+=(o.length > 0 ? "," : "") + s.substr(j,3);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
var write_num = (function make_write_num(){
|
|
|
|
|
var pct1 = /%/g;
|
|
|
|
|
function write_num_pct(type, fmt, val){
|
|
|
|
|
var sfmt = fmt.replace(pct1,""), mul = fmt.length - sfmt.length;
|
|
|
|
|
return write_num(type, sfmt, val * Math.pow(10,2*mul)) + fill("%",mul);
|
|
|
|
|
}
|
|
|
|
|
function write_num_cm(type, fmt, val){
|
|
|
|
|
var idx = fmt.length - 1;
|
|
|
|
|
while(fmt.charCodeAt(idx-1) === 44) --idx;
|
|
|
|
|
return write_num(type, fmt.substr(0,idx), val / Math.pow(10,3*(fmt.length-idx)));
|
|
|
|
|
}
|
|
|
|
|
function write_num_exp(fmt, val){
|
|
|
|
|
var o;
|
|
|
|
|
var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
|
|
|
|
|
if(fmt.match(/^#+0.0E\+0$/)) {
|
|
|
|
|
var period = fmt.indexOf("."); if(period === -1) period=fmt.indexOf('E');
|
|
|
|
|
var ee = Math.floor(Math.log(Math.abs(val))*Math.LOG10E)%period;
|
|
|
|
|
if(ee < 0) ee += period;
|
|
|
|
|
o = (val/Math.pow(10,ee)).toPrecision(idx+1+(period+ee)%period);
|
|
|
|
|
if(o.indexOf("e") === -1) {
|
|
|
|
|
var fakee = Math.floor(Math.log(Math.abs(val))*Math.LOG10E);
|
|
|
|
|
if(o.indexOf(".") === -1) o = o[0] + "." + o.substr(1) + "E+" + (fakee - o.length+ee);
|
|
|
|
|
else o += "E+" + (fakee - ee);
|
|
|
|
|
while(o.substr(0,2) === "0.") {
|
|
|
|
|
o = o[0] + o.substr(2,period) + "." + o.substr(2+period);
|
|
|
|
|
o = o.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");
|
2014-01-23 06:20:19 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o = o.replace(/\+-/,"-");
|
|
|
|
|
}
|
|
|
|
|
o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function($$,$1,$2,$3) { return $1 + $2 + $3.substr(0,(period+ee)%period) + "." + $3.substr(ee) + "E"; });
|
|
|
|
|
} else o = val.toExponential(idx);
|
|
|
|
|
if(fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0,o.length-1) + "0" + o[o.length-1];
|
|
|
|
|
if(fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/,"e");
|
|
|
|
|
return o.replace("e","E");
|
|
|
|
|
}
|
|
|
|
|
var frac1 = /# (\?+)( ?)\/( ?)(\d+)/;
|
|
|
|
|
function write_num_f1(r, aval, sign) {
|
|
|
|
|
var den = parseInt(r[4]), rr = Math.round(aval * den), base = Math.floor(rr/den);
|
|
|
|
|
var myn = (rr - base*den), myd = den;
|
|
|
|
|
return sign + (base === 0 ? "" : ""+base) + " " + (myn === 0 ? fill(" ", r[1].length + 1 + r[4].length) : pad_(myn,r[1].length) + r[2] + "/" + r[3] + pad0(myd,r[4].length));
|
|
|
|
|
}
|
|
|
|
|
function write_num_f2(r, aval, sign) {
|
|
|
|
|
return sign + (aval === 0 ? "" : ""+aval) + fill(" ", r[1].length + 2 + r[4].length);
|
|
|
|
|
}
|
|
|
|
|
var dec1 = /^#*0*\.(0+)/;
|
|
|
|
|
var closeparen = /\).*[0#]/;
|
|
|
|
|
var phone = /\(###\) ###\\?-####/;
|
|
|
|
|
function hashq(str) {
|
|
|
|
|
var o = "", cc;
|
|
|
|
|
for(var i = 0; i != str.length; ++i) switch((cc=str.charCodeAt(i))) {
|
|
|
|
|
case 35: break;
|
|
|
|
|
case 63: o+= " "; break;
|
|
|
|
|
case 48: o+= "0"; break;
|
|
|
|
|
default: o+= String.fromCharCode(cc);
|
2013-12-27 03:15:16 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
function rnd(val, d) { var dd = Math.pow(10,d); return ""+(Math.round(val * dd)/dd); }
|
|
|
|
|
function dec(val, d) { return Math.round((val-Math.floor(val))*Math.pow(10,d)); }
|
|
|
|
|
function flr(val) { if(val < 2147483647 && val > -2147483648) return ""+(val >= 0 ? (val|0) : (val-1|0)); return ""+Math.floor(val); }
|
|
|
|
|
function write_num_flt(type, fmt, val) {
|
|
|
|
|
if(type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
|
|
|
|
|
var ffmt = fmt.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");
|
|
|
|
|
if(val >= 0) return write_num_flt('n', ffmt, val);
|
|
|
|
|
return '(' + write_num_flt('n', ffmt, -val) + ')';
|
2014-01-23 06:20:19 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val);
|
|
|
|
|
if(fmt.indexOf('%') !== -1) return write_num_pct(type, fmt, val);
|
|
|
|
|
if(fmt.indexOf('E') !== -1) return write_num_exp(fmt, val);
|
|
|
|
|
if(fmt.charCodeAt(0) === 36) return "$"+write_num_flt(type,fmt.substr(fmt[1]==' '?2:1),val);
|
|
|
|
|
var o, oo;
|
|
|
|
|
var r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
|
|
|
|
|
if(fmt.match(/^00+$/)) return sign + pad0r(aval,fmt.length);
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(fmt.match(/^[#?]+$/)) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o = pad0r(val,0); if(o === "0") o = "";
|
|
|
|
|
return o.length > fmt.length ? o : hashq(fmt.substr(0,fmt.length-o.length)) + o;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(frac1)) !== null) return write_num_f1(r, aval, sign);
|
|
|
|
|
if(fmt.match(/^#+0+$/) !== null) return sign + pad0r(aval,fmt.length - fmt.indexOf("0"));
|
|
|
|
|
if((r = fmt.match(dec1)) !== null) {
|
|
|
|
|
o = rnd(val, r[1].length).replace(/^([^\.]+)$/,"$1."+r[1]).replace(/\.$/,"."+r[1]).replace(/\.(\d*)$/,function($$, $1) { return "." + $1 + fill("0", r[1].length-$1.length); });
|
|
|
|
|
return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./,".");
|
2014-01-23 06:20:19 +00:00
|
|
|
|
}
|
2014-03-29 02:05:50 +00:00
|
|
|
|
fmt = fmt.replace(/^#+([0.])/, "$1");
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^(0*)\.(#*)$/)) !== null) {
|
|
|
|
|
return sign + rnd(aval, r[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,r[1].length?"0.":".");
|
2014-02-17 08:44:22 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^#,##0(\.?)$/)) !== null) return sign + commaify(pad0r(aval,0));
|
|
|
|
|
if((r = fmt.match(/^#,##0\.([#0]*0)$/)) !== null) {
|
|
|
|
|
return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(""+(Math.floor(val))) + "." + pad0(dec(val, r[1].length),r[1].length);
|
2014-02-17 08:44:22 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^#,#*,#0/)) !== null) return write_num_flt(type,fmt.replace(/^#,#*,/,""),val);
|
|
|
|
|
if((r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) !== null) {
|
|
|
|
|
o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g,""), val));
|
|
|
|
|
ri = 0;
|
|
|
|
|
return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o[ri++]:x==='0'?'0':"";}));
|
2014-03-29 22:53:15 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(fmt.match(phone) !== null) {
|
|
|
|
|
o = write_num_flt(type, "##########", val);
|
|
|
|
|
return "(" + o.substr(0,3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
|
2014-03-29 22:53:15 +00:00
|
|
|
|
}
|
2014-06-05 07:06:20 +00:00
|
|
|
|
var oa = "";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) !== null) {
|
|
|
|
|
ri = Math.min(r[4].length,7);
|
|
|
|
|
ff = frac(aval, Math.pow(10,ri)-1, false);
|
|
|
|
|
o = "" + sign;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
oa = write_num("n", r[1], ff[1]);
|
|
|
|
|
if(oa[oa.length-1] == " ") oa = oa.substr(0,oa.length-1) + "0";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o += oa + r[2] + "/" + r[3];
|
|
|
|
|
oa = rpad_(ff[2],ri);
|
|
|
|
|
if(oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length-oa.length)) + oa;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
o += oa;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) !== null) {
|
|
|
|
|
ri = Math.min(Math.max(r[1].length, r[4].length),7);
|
|
|
|
|
ff = frac(aval, Math.pow(10,ri)-1, true);
|
|
|
|
|
return sign + (ff[0]||(ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1],ri) + r[2] + "/" + r[3] + rpad_(ff[2],ri): fill(" ", 2*ri+1 + r[2].length + r[3].length));
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(/^[#0?]+$/)) !== null) {
|
|
|
|
|
o = pad0r(val, 0);
|
|
|
|
|
if(fmt.length <= o.length) return o;
|
|
|
|
|
return hashq(fmt.substr(0,fmt.length-o.length)) + o;
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(/^([#0?]+)\.([#0]+)$/)) !== null) {
|
|
|
|
|
o = "" + val.toFixed(Math.min(r[2].length,10)).replace(/([^0])0+$/,"$1");
|
|
|
|
|
ri = o.indexOf(".");
|
|
|
|
|
var lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
|
|
|
|
|
return hashq(fmt.substr(0,lres) + o + fmt.substr(fmt.length-rres));
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(/^00,000\.([#0]*0)$/)) !== null) {
|
|
|
|
|
ri = dec(val, r[1].length);
|
|
|
|
|
return val < 0 ? "-" + write_num_flt(type, fmt, -val) : commaify(flr(val)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function($$) { return "00," + ($$.length < 3 ? pad0(0,3-$$.length) : "") + $$; }) + "." + pad0(ri,r[1].length);
|
|
|
|
|
}
|
|
|
|
|
switch(fmt) {
|
|
|
|
|
case "#,###": var x = commaify(pad0r(aval,0)); return x !== "0" ? sign + x : "";
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
throw new Error("unsupported format |" + fmt + "|");
|
|
|
|
|
}
|
|
|
|
|
function write_num_cm2(type, fmt, val){
|
|
|
|
|
var idx = fmt.length - 1;
|
|
|
|
|
while(fmt.charCodeAt(idx-1) === 44) --idx;
|
|
|
|
|
return write_num(type, fmt.substr(0,idx), val / Math.pow(10,3*(fmt.length-idx)));
|
|
|
|
|
}
|
|
|
|
|
function write_num_pct2(type, fmt, val){
|
|
|
|
|
var sfmt = fmt.replace(pct1,""), mul = fmt.length - sfmt.length;
|
|
|
|
|
return write_num(type, sfmt, val * Math.pow(10,2*mul)) + fill("%",mul);
|
|
|
|
|
}
|
|
|
|
|
function write_num_exp2(fmt, val){
|
|
|
|
|
var o;
|
|
|
|
|
var idx = fmt.indexOf("E") - fmt.indexOf(".") - 1;
|
|
|
|
|
if(fmt.match(/^#+0.0E\+0$/)) {
|
|
|
|
|
var period = fmt.indexOf("."); if(period === -1) period=fmt.indexOf('E');
|
|
|
|
|
var ee = Math.floor(Math.log(Math.abs(val))*Math.LOG10E)%period;
|
|
|
|
|
if(ee < 0) ee += period;
|
|
|
|
|
o = (val/Math.pow(10,ee)).toPrecision(idx+1+(period+ee)%period);
|
|
|
|
|
if(!o.match(/[Ee]/)) {
|
|
|
|
|
var fakee = Math.floor(Math.log(Math.abs(val))*Math.LOG10E);
|
|
|
|
|
if(o.indexOf(".") === -1) o = o[0] + "." + o.substr(1) + "E+" + (fakee - o.length+ee);
|
|
|
|
|
else o += "E+" + (fakee - ee);
|
|
|
|
|
o = o.replace(/\+-/,"-");
|
|
|
|
|
}
|
|
|
|
|
o = o.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function($$,$1,$2,$3) { return $1 + $2 + $3.substr(0,(period+ee)%period) + "." + $3.substr(ee) + "E"; });
|
|
|
|
|
} else o = val.toExponential(idx);
|
|
|
|
|
if(fmt.match(/E\+00$/) && o.match(/e[+-]\d$/)) o = o.substr(0,o.length-1) + "0" + o[o.length-1];
|
|
|
|
|
if(fmt.match(/E\-/) && o.match(/e\+/)) o = o.replace(/e\+/,"e");
|
|
|
|
|
return o.replace("e","E");
|
|
|
|
|
}
|
|
|
|
|
function write_num_int(type, fmt, val) {
|
|
|
|
|
if(type.charCodeAt(0) === 40 && !fmt.match(closeparen)) {
|
|
|
|
|
var ffmt = fmt.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");
|
|
|
|
|
if(val >= 0) return write_num_int('n', ffmt, val);
|
|
|
|
|
return '(' + write_num_int('n', ffmt, -val) + ')';
|
|
|
|
|
}
|
|
|
|
|
if(fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val);
|
|
|
|
|
if(fmt.indexOf('%') !== -1) return write_num_pct2(type, fmt, val);
|
|
|
|
|
if(fmt.indexOf('E') !== -1) return write_num_exp2(fmt, val);
|
|
|
|
|
if(fmt.charCodeAt(0) === 36) return "$"+write_num_int(type,fmt.substr(fmt[1]==' '?2:1),val);
|
|
|
|
|
var o;
|
|
|
|
|
var r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : "";
|
|
|
|
|
if(fmt.match(/^00+$/)) return sign + pad0(aval,fmt.length);
|
|
|
|
|
if(fmt.match(/^[#?]+$/)) {
|
|
|
|
|
o = (""+val); if(val === 0) o = "";
|
|
|
|
|
return o.length > fmt.length ? o : hashq(fmt.substr(0,fmt.length-o.length)) + o;
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(frac1)) !== null) return write_num_f2(r, aval, sign);
|
|
|
|
|
if(fmt.match(/^#+0+$/) !== null) return sign + pad0(aval,fmt.length - fmt.indexOf("0"));
|
|
|
|
|
if((r = fmt.match(dec1)) !== null) {
|
|
|
|
|
o = (""+val).replace(/^([^\.]+)$/,"$1."+r[1]).replace(/\.$/,"."+r[1]).replace(/\.(\d*)$/,function($$, $1) { return "." + $1 + fill("0", r[1].length-$1.length); });
|
|
|
|
|
return fmt.indexOf("0.") !== -1 ? o : o.replace(/^0\./,".");
|
|
|
|
|
}
|
|
|
|
|
fmt = fmt.replace(/^#+([0.])/, "$1");
|
|
|
|
|
if((r = fmt.match(/^(0*)\.(#*)$/)) !== null) {
|
|
|
|
|
return sign + (""+aval).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,r[1].length?"0.":".");
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(/^#,##0(\.?)$/)) !== null) return sign + commaify((""+aval));
|
|
|
|
|
if((r = fmt.match(/^#,##0\.([#0]*0)$/)) !== null) {
|
|
|
|
|
return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify((""+val)) + "." + fill('0',r[1].length);
|
|
|
|
|
}
|
|
|
|
|
if((r = fmt.match(/^#,#*,#0/)) !== null) return write_num_int(type,fmt.replace(/^#,#*,/,""),val);
|
|
|
|
|
if((r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/)) !== null) {
|
|
|
|
|
o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g,""), val));
|
|
|
|
|
ri = 0;
|
|
|
|
|
return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o[ri++]:x==='0'?'0':"";}));
|
|
|
|
|
}
|
|
|
|
|
if(fmt.match(phone) !== null) {
|
|
|
|
|
o = write_num_int(type, "##########", val);
|
|
|
|
|
return "(" + o.substr(0,3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
|
|
|
|
|
}
|
|
|
|
|
var oa = "";
|
|
|
|
|
if((r = fmt.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)) !== null) {
|
|
|
|
|
ri = Math.min(r[4].length,7);
|
|
|
|
|
ff = frac(aval, Math.pow(10,ri)-1, false);
|
|
|
|
|
o = "" + sign;
|
|
|
|
|
oa = write_num("n", r[1], ff[1]);
|
|
|
|
|
if(oa[oa.length-1] == " ") oa = oa.substr(0,oa.length-1) + "0";
|
|
|
|
|
o += oa + r[2] + "/" + r[3];
|
|
|
|
|
oa = rpad_(ff[2],ri);
|
|
|
|
|
if(oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length-oa.length)) + oa;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
o += oa;
|
|
|
|
|
return o;
|
2014-03-29 02:05:50 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)) !== null) {
|
|
|
|
|
ri = Math.min(Math.max(r[1].length, r[4].length),7);
|
|
|
|
|
ff = frac(aval, Math.pow(10,ri)-1, true);
|
|
|
|
|
return sign + (ff[0]||(ff[1] ? "" : "0")) + " " + (ff[1] ? pad_(ff[1],ri) + r[2] + "/" + r[3] + rpad_(ff[2],ri): fill(" ", 2*ri+1 + r[2].length + r[3].length));
|
2013-12-27 03:15:16 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^[#0?]+$/)) !== null) {
|
|
|
|
|
o = "" + val;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
if(fmt.length <= o.length) return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return hashq(fmt.substr(0,fmt.length-o.length)) + o;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^([#0]+)\.([#0]+)$/)) !== null) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
o = "" + val.toFixed(Math.min(r[2].length,10)).replace(/([^0])0+$/,"$1");
|
2014-06-29 18:29:45 +00:00
|
|
|
|
ri = o.indexOf(".");
|
|
|
|
|
var lres = fmt.indexOf(".") - ri, rres = fmt.length - o.length - lres;
|
|
|
|
|
return hashq(fmt.substr(0,lres) + o + fmt.substr(fmt.length-rres));
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((r = fmt.match(/^00,000\.([#0]*0)$/)) !== null) {
|
|
|
|
|
return val < 0 ? "-" + write_num_int(type, fmt, -val) : commaify(""+val).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function($$) { return "00," + ($$.length < 3 ? pad0(0,3-$$.length) : "") + $$; }) + "." + pad0(0,r[1].length);
|
2014-03-29 02:05:50 +00:00
|
|
|
|
}
|
2013-12-27 03:15:16 +00:00
|
|
|
|
switch(fmt) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case "#,###": var x = commaify(""+aval); return x !== "0" ? sign + x : "";
|
2013-12-27 03:15:16 +00:00
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
throw new Error("unsupported format |" + fmt + "|");
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
return function write_num(type, fmt, val) {
|
|
|
|
|
return (val|0) === val ? write_num_int(type, fmt, val) : write_num_flt(type, fmt, val);
|
|
|
|
|
};})();
|
2013-03-26 23:54:14 +00:00
|
|
|
|
function split_fmt(fmt) {
|
2013-12-27 03:15:16 +00:00
|
|
|
|
var out = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var in_str = false, cc;
|
|
|
|
|
for(var i = 0, j = 0; i < fmt.length; ++i) switch((cc=fmt.charCodeAt(i))) {
|
|
|
|
|
case 34: /* '"' */
|
|
|
|
|
in_str = !in_str; break;
|
|
|
|
|
case 95: case 42: case 92: /* '_' '*' '\\' */
|
|
|
|
|
++i; break;
|
|
|
|
|
case 59: /* ';' */
|
|
|
|
|
out[out.length] = fmt.substr(j,i-j);
|
|
|
|
|
j = i+1;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[out.length] = fmt.substr(j);
|
|
|
|
|
if(in_str === true) throw new Error("Format |" + fmt + "| unterminated string ");
|
2013-12-27 03:15:16 +00:00
|
|
|
|
return out;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
|
|
|
|
SSF._split = split_fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var abstime = /\[[HhMmSs]*\]/;
|
2013-12-16 16:32:34 +00:00
|
|
|
|
function eval_fmt(fmt, v, opts, flen) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var out = [], o = "", i = 0, c = "", lst='t', q, dt, j, cc;
|
2013-04-17 01:32:20 +00:00
|
|
|
|
var hr='H';
|
2013-03-26 23:54:14 +00:00
|
|
|
|
/* Tokenize */
|
|
|
|
|
while(i < fmt.length) {
|
2013-04-17 01:32:20 +00:00
|
|
|
|
switch((c = fmt[i])) {
|
2014-01-23 06:20:19 +00:00
|
|
|
|
case 'G': /* General */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(!isgeneral(fmt, i)) throw new Error('unrecognized character ' + c + ' in ' +fmt);
|
|
|
|
|
out[out.length] = {t:'G', v:'General'}; i+=7; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
case '"': /* Literal text */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(o="";(cc=fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) o += String.fromCharCode(cc);
|
|
|
|
|
out[out.length] = {t:'t', v:o}; ++i; break;
|
|
|
|
|
case '\\': var w = fmt[++i], t = (w === "(" || w === ")") ? w : 't';
|
|
|
|
|
out[out.length] = {t:t, v:w}; ++i; break;
|
|
|
|
|
case '_': out[out.length] = {t:'t', v:" "}; i+=2; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
case '@': /* Text Placeholder */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[out.length] = {t:'T', v:v}; ++i; break;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
case 'B': case 'b':
|
|
|
|
|
if(fmt[i+1] === "1" || fmt[i+1] === "2") {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(dt==null) { dt=parse_date_code(v, opts, fmt[i+1] === "2"); if(dt==null) return ""; }
|
|
|
|
|
out[out.length] = {t:'X', v:fmt.substr(i,2)}; lst = c; i+=2; break;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
}
|
|
|
|
|
/* falls through */
|
2014-01-23 06:20:19 +00:00
|
|
|
|
case 'M': case 'D': case 'Y': case 'H': case 'S': case 'E':
|
|
|
|
|
c = c.toLowerCase();
|
|
|
|
|
/* falls through */
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case 'm': case 'd': case 'y': case 'h': case 's': case 'e': case 'g':
|
2013-12-27 03:15:16 +00:00
|
|
|
|
if(v < 0) return "";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(dt==null) { dt=parse_date_code(v, opts); if(dt==null) return ""; }
|
|
|
|
|
o = c; while(++i<fmt.length && fmt[i].toLowerCase() === c) o+=c;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
if(c === 'm' && lst.toLowerCase() === 'h') c = 'M'; /* m = minute */
|
|
|
|
|
if(c === 'h') c = hr;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[out.length] = {t:c, v:o}; lst = c; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
case 'A':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
q={t:c, v:"A"};
|
|
|
|
|
if(dt==null) dt=parse_date_code(v, opts);
|
|
|
|
|
if(fmt.substr(i, 3) === "A/P") { if(dt!=null) q.v = dt.H >= 12 ? "P" : "A"; q.t = 'T'; hr='h';i+=3;}
|
|
|
|
|
else if(fmt.substr(i,5) === "AM/PM") { if(dt!=null) q.v = dt.H >= 12 ? "PM" : "AM"; q.t = 'T'; i+=5; hr='h'; }
|
|
|
|
|
else { q.t = "t"; ++i; }
|
|
|
|
|
if(dt==null && q.t === 'T') return "";
|
|
|
|
|
out[out.length] = q; lst = c; break;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
case '[':
|
2013-12-27 03:15:16 +00:00
|
|
|
|
o = c;
|
2014-02-12 06:09:42 +00:00
|
|
|
|
while(fmt[i++] !== ']' && i < fmt.length) o += fmt[i];
|
|
|
|
|
if(o.substr(-1) !== ']') throw 'unterminated "[" block: |' + o + '|';
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(o.match(abstime)) {
|
|
|
|
|
if(dt==null) { dt=parse_date_code(v, opts); if(dt==null) return ""; }
|
|
|
|
|
out[out.length] = {t:'Z', v:o.toLowerCase()};
|
2014-01-23 06:20:19 +00:00
|
|
|
|
} else { o=""; }
|
2013-12-27 03:15:16 +00:00
|
|
|
|
break;
|
|
|
|
|
/* Numbers */
|
2014-05-22 12:16:51 +00:00
|
|
|
|
case '.':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(dt != null) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
o = c; while((c=fmt[++i]) === "0") o += c;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[out.length] = {t:'s', v:o}; break;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '0': case '#':
|
2014-04-03 22:51:54 +00:00
|
|
|
|
o = c; while("0#?.,E+-%".indexOf(c=fmt[++i]) > -1 || c=='\\' && fmt[i+1] == "-" && "0#".indexOf(fmt[i+2])>-1) o += c;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[out.length] = {t:'n', v:o}; break;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
case '?':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o = c; while(fmt[++i] === c) o+=c;
|
|
|
|
|
q={t:c, v:o}; out[out.length] = q; lst = c; break;
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case '*': ++i; if(fmt[i] == ' ' || fmt[i] == '*') ++i; break; // **
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case '(': case ')': out[out.length] = {t:(flen===1?'t':c), v:c}; ++i; break;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o = c; while("0123456789".indexOf(fmt[++i]) > -1) o+=fmt[i];
|
|
|
|
|
out[out.length] = {t:'D', v:o}; break;
|
|
|
|
|
case ' ': out[out.length] = {t:c, v:c}; ++i; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
default:
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxz".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);
|
|
|
|
|
out[out.length] = {t:'t', v:c}; ++i; break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-22 12:16:51 +00:00
|
|
|
|
var bt = 0, ss0 = 0, ssm;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
for(i=out.length-1, lst='t'; i >= 0; --i) {
|
|
|
|
|
switch(out[i].t) {
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case 'h': case 'H': out[i].t = hr; lst='h'; if(bt < 1) bt = 1; break;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
case 's':
|
|
|
|
|
if((ssm=out[i].v.match(/\.0+$/))) ss0=Math.max(ss0,ssm[0].length-1);
|
|
|
|
|
if(bt < 3) bt = 3;
|
2014-03-29 02:05:50 +00:00
|
|
|
|
/* falls through */
|
|
|
|
|
case 'd': case 'y': case 'M': case 'e': lst=out[i].t; break;
|
|
|
|
|
case 'm': if(lst === 's') { out[i].t = 'M'; if(bt < 2) bt = 2; } break;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
case 'X': if(out[i].v === "B2");
|
|
|
|
|
break;
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case 'Z':
|
|
|
|
|
if(bt < 1 && out[i].v.match(/[Hh]/)) bt = 1;
|
|
|
|
|
if(bt < 2 && out[i].v.match(/[Mm]/)) bt = 2;
|
|
|
|
|
if(bt < 3 && out[i].v.match(/[Ss]/)) bt = 3;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-29 02:05:50 +00:00
|
|
|
|
switch(bt) {
|
|
|
|
|
case 0: break;
|
|
|
|
|
case 1:
|
2014-03-29 22:53:15 +00:00
|
|
|
|
if(dt.u >= 0.5) { dt.u = 0; ++dt.S; }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(dt.S >= 60) { dt.S = 0; ++dt.M; }
|
|
|
|
|
if(dt.M >= 60) { dt.M = 0; ++dt.H; }
|
2014-03-29 02:05:50 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2014-03-29 22:53:15 +00:00
|
|
|
|
if(dt.u >= 0.5) { dt.u = 0; ++dt.S; }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(dt.S >= 60) { dt.S = 0; ++dt.M; }
|
2014-03-29 02:05:50 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2013-03-26 23:54:14 +00:00
|
|
|
|
/* replace fields */
|
2014-05-22 12:16:51 +00:00
|
|
|
|
var nstr = "", jj;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
for(i=0; i < out.length; ++i) {
|
|
|
|
|
switch(out[i].t) {
|
2014-02-12 06:09:42 +00:00
|
|
|
|
case 't': case 'T': case ' ': case 'D': break;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 'X': out[i] = undefined; break;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
case 'd': case 'm': case 'y': case 'h': case 'H': case 'M': case 's': case 'e': case 'b': case 'Z':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[i].v = write_date(out[i].t.charCodeAt(0), out[i].v, dt, ss0);
|
2013-03-26 23:54:14 +00:00
|
|
|
|
out[i].t = 't'; break;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
case 'n': case '(': case '?':
|
2014-05-22 12:16:51 +00:00
|
|
|
|
jj = i+1;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
while(out[jj] != null && (
|
|
|
|
|
(c=out[jj].t) === "?" || c === "D" ||
|
|
|
|
|
(c === " " || c === "t") && out[jj+1] != null && (out[jj+1].t === '?' || out[jj+1].t === "t" && out[jj+1].v === '/') ||
|
|
|
|
|
out[i].t === '(' && (c === ' ' || c === 'n' || c === ')') ||
|
|
|
|
|
c === 't' && (out[jj].v === '/' || '$€'.indexOf(out[jj].v) > -1 || out[jj].v === ' ' && out[jj+1] != null && out[jj+1].t == '?')
|
|
|
|
|
)) {
|
2014-01-23 06:20:19 +00:00
|
|
|
|
out[i].v += out[jj].v;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[jj] = undefined; ++jj;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
}
|
2014-05-22 12:16:51 +00:00
|
|
|
|
nstr += out[i].v;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
i = jj-1; break;
|
|
|
|
|
case 'G': out[i].t = 't'; out[i].v = general_fmt(v,opts); break;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var vv = "", myv, ostr;
|
|
|
|
|
if(nstr.length > 0) {
|
|
|
|
|
myv = (v<0&&nstr.charCodeAt(0) === 45 ? -v : v); /* '-' */
|
|
|
|
|
ostr = write_num(nstr.charCodeAt(0) === 40 ? '(' : 'n', nstr, myv); /* '(' */
|
2014-05-22 12:16:51 +00:00
|
|
|
|
jj=ostr.length-1;
|
|
|
|
|
var decpt = out.length;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(i=0; i < out.length; ++i) if(out[i] != null && out[i].v.indexOf(".") > -1) { decpt = i; break; }
|
|
|
|
|
var lasti=out.length;
|
|
|
|
|
if(decpt === out.length && ostr.indexOf("E") === -1) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
for(i=out.length-1; i>= 0;--i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(out[i] == null || 'n?('.indexOf(out[i].t) === -1) continue;
|
|
|
|
|
if(jj>=out[i].v.length-1) { jj -= out[i].v.length; out[i].v = ostr.substr(jj+1, out[i].v.length); }
|
|
|
|
|
else if(jj < 0) out[i].v = "";
|
|
|
|
|
else { out[i].v = ostr.substr(0, jj+1); jj = -1; }
|
2014-05-22 12:16:51 +00:00
|
|
|
|
out[i].t = 't';
|
|
|
|
|
lasti = i;
|
|
|
|
|
}
|
|
|
|
|
if(jj>=0 && lasti<out.length) out[lasti].v = ostr.substr(0,jj+1) + out[lasti].v;
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
else if(decpt !== out.length && ostr.indexOf("E") === -1) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
jj = ostr.indexOf(".")-1;
|
|
|
|
|
for(i=decpt; i>= 0; --i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(out[i] == null || 'n?('.indexOf(out[i].t) === -1) continue;
|
|
|
|
|
j=out[i].v.indexOf(".")>-1&&i===decpt?out[i].v.indexOf(".")-1:out[i].v.length-1;
|
|
|
|
|
vv = out[i].v.substr(j+1);
|
|
|
|
|
for(; j>=0; --j) {
|
|
|
|
|
if(jj>=0 && (out[i].v[j] === "0" || out[i].v[j] === "#")) vv = ostr[jj--] + vv;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[i].v = vv;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
out[i].t = 't';
|
|
|
|
|
lasti = i;
|
|
|
|
|
}
|
|
|
|
|
if(jj>=0 && lasti<out.length) out[lasti].v = ostr.substr(0,jj+1) + out[lasti].v;
|
|
|
|
|
jj = ostr.indexOf(".")+1;
|
|
|
|
|
for(i=decpt; i<out.length; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(out[i] == null || 'n?('.indexOf(out[i].t) === -1 && i !== decpt ) continue;
|
|
|
|
|
j=out[i].v.indexOf(".")>-1&&i===decpt?out[i].v.indexOf(".")+1:0;
|
|
|
|
|
vv = out[i].v.substr(0,j);
|
|
|
|
|
for(; j<out[i].v.length; ++j) {
|
|
|
|
|
if(jj<ostr.length) vv += ostr[jj++];
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out[i].v = vv;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
out[i].t = 't';
|
|
|
|
|
lasti = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(i=0; i<out.length; ++i) if(out[i] != null && 'n(?'.indexOf(out[i].t)>-1) {
|
|
|
|
|
myv = (flen >1 && v < 0 && i>0 && out[i-1].v === "-" ? -v:v);
|
|
|
|
|
out[i].v = write_num(out[i].t, out[i].v, myv);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
out[i].t = 't';
|
|
|
|
|
}
|
2014-06-05 07:06:20 +00:00
|
|
|
|
var retval = "";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(i=0; i !== out.length; ++i) if(out[i] != null) retval += out[i].v;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
return retval;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
|
|
|
|
SSF._eval = eval_fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var cfregex = /\[[=<>]/;
|
|
|
|
|
var cfregex2 = /\[([=<>]*)(-?\d+\.?\d*)\]/;
|
|
|
|
|
function chkcond(v, rr) {
|
|
|
|
|
if(rr == null) return false;
|
|
|
|
|
var thresh = parseFloat(rr[2]);
|
|
|
|
|
switch(rr[1]) {
|
|
|
|
|
case "=": if(v == thresh) return true; break;
|
|
|
|
|
case ">": if(v > thresh) return true; break;
|
|
|
|
|
case "<": if(v < thresh) return true; break;
|
|
|
|
|
case "<>": if(v != thresh) return true; break;
|
|
|
|
|
case ">=": if(v >= thresh) return true; break;
|
|
|
|
|
case "<=": if(v <= thresh) return true; break;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
function choose_fmt(f, v) {
|
|
|
|
|
var fmt = split_fmt(f);
|
|
|
|
|
var l = fmt.length, lat = fmt[l-1].indexOf("@");
|
|
|
|
|
if(l<4 && lat>-1) --l;
|
|
|
|
|
if(fmt.length > 4) throw "cannot find right format for |" + fmt + "|";
|
|
|
|
|
if(typeof v !== "number") return [4, fmt.length === 4 || lat>-1?fmt[fmt.length-1]:"@"];
|
2013-12-27 03:15:16 +00:00
|
|
|
|
switch(fmt.length) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 1: fmt = lat>-1 ? ["General", "General", "General", fmt[0]] : [fmt[0], fmt[0], fmt[0], "@"]; break;
|
|
|
|
|
case 2: fmt = lat>-1 ? [fmt[0], fmt[0], fmt[0], fmt[1]] : [fmt[0], fmt[1], fmt[0], "@"]; break;
|
|
|
|
|
case 3: fmt = lat>-1 ? [fmt[0], fmt[1], fmt[0], fmt[2]] : [fmt[0], fmt[1], fmt[2], "@"]; break;
|
2013-12-27 03:15:16 +00:00
|
|
|
|
case 4: break;
|
|
|
|
|
}
|
2014-03-29 22:53:15 +00:00
|
|
|
|
var ff = v > 0 ? fmt[0] : v < 0 ? fmt[1] : fmt[2];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(fmt[0].indexOf("[") === -1 && fmt[1].indexOf("[") === -1) return [l, ff];
|
|
|
|
|
if(fmt[0].match(cfregex) != null || fmt[1].match(cfregex) != null) {
|
|
|
|
|
var m1 = fmt[0].match(cfregex2);
|
|
|
|
|
var m2 = fmt[1].match(cfregex2);
|
|
|
|
|
return chkcond(v, m1) ? [l, fmt[0]] : chkcond(v, m2) ? [l, fmt[1]] : [l, fmt[m1 != null && m2 != null ? 2 : 1]];
|
2014-03-29 22:53:15 +00:00
|
|
|
|
}
|
|
|
|
|
return [l, ff];
|
2013-03-26 23:54:14 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function format(fmt,v,o) {
|
|
|
|
|
fixopts(o != null ? o : (o=[]));
|
|
|
|
|
var sfmt = "";
|
|
|
|
|
switch(typeof fmt) {
|
|
|
|
|
case "string": sfmt = fmt; break;
|
|
|
|
|
case "number": sfmt = (o.table != null ? o.table : table_fmt)[fmt]; break;
|
|
|
|
|
}
|
|
|
|
|
if(isgeneral(sfmt,0)) return general_fmt(v, o);
|
|
|
|
|
var f = choose_fmt(sfmt, v);
|
|
|
|
|
if(isgeneral(f[1])) return general_fmt(v, o);
|
|
|
|
|
if(v === true) v = "TRUE"; else if(v === false) v = "FALSE";
|
|
|
|
|
else if(v === "" || v == null) return "";
|
2013-12-27 03:15:16 +00:00
|
|
|
|
return eval_fmt(f[1], v, o, f[0]);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2013-03-26 23:54:14 +00:00
|
|
|
|
SSF._table = table_fmt;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
SSF.load = function load_entry(fmt, idx) { table_fmt[idx] = fmt; };
|
2013-03-26 23:54:14 +00:00
|
|
|
|
SSF.format = format;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
SSF.get_table = function get_table() { return table_fmt; };
|
|
|
|
|
SSF.load_table = function load_table(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i] !== undefined) SSF.load(tbl[i], i); };
|
2013-12-16 16:32:34 +00:00
|
|
|
|
};
|
|
|
|
|
make_ssf(SSF);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function isval(x) { return x !== undefined && x !== null; }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function keys(o) { return Object.keys(o); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function evert_key(obj, key) {
|
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
|
for(var i = 0; i !== K.length; ++i) o[obj[K[i]][key]] = K[i];
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function evert(obj) {
|
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
|
for(var i = 0; i !== K.length; ++i) o[obj[K[i]]] = K[i];
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function evert_num(obj) {
|
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
|
for(var i = 0; i !== K.length; ++i) o[obj[K[i]]] = parseInt(K[i],10);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function evert_arr(obj) {
|
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
|
for(var i = 0; i !== K.length; ++i) {
|
|
|
|
|
if(o[obj[K[i]]] == null) o[obj[K[i]]] = [];
|
|
|
|
|
o[obj[K[i]]].push(K[i]);
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o;
|
|
|
|
|
}
|
2014-05-22 12:16:51 +00:00
|
|
|
|
|
|
|
|
|
/* TODO: date1904 logic */
|
|
|
|
|
function datenum(v, date1904) {
|
|
|
|
|
if(date1904) v+=1462;
|
|
|
|
|
var epoch = Date.parse(v);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return (epoch + 2209161600000) / (24 * 60 * 60 * 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cc2str(arr) {
|
|
|
|
|
var o = "";
|
|
|
|
|
for(var i = 0; i != arr.length; ++i) o += String.fromCharCode(arr[i]);
|
|
|
|
|
return o;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
|
|
|
|
|
var has_buf = (typeof Buffer !== 'undefined');
|
2014-01-28 16:38:02 +00:00
|
|
|
|
function getdata(data) {
|
|
|
|
|
if(!data) return null;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(data.name.substr(-4) === ".bin") {
|
|
|
|
|
if(data.data) return char_codes(data.data);
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(data.asNodeBuffer && has_buf) return data.asNodeBuffer();
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(data._data && data._data.getContent) return Array.prototype.slice.call(data._data.getContent());
|
|
|
|
|
} else {
|
|
|
|
|
if(data.data) return data.name.substr(-4) !== ".bin" ? debom_xml(data.data) : char_codes(data.data);
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(data.asNodeBuffer && has_buf) return debom_xml(data.asNodeBuffer().toString('binary'));
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(data.asBinary) return debom_xml(data.asBinary());
|
|
|
|
|
if(data._data && data._data.getContent) return debom_xml(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-10 02:22:38 +00:00
|
|
|
|
function safegetzipfile(zip, file) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var f = file; if(zip.files[f]) return zip.files[f];
|
|
|
|
|
f = file.toLowerCase(); if(zip.files[f]) return zip.files[f];
|
|
|
|
|
f = f.replace(/\//g,'\\'); if(zip.files[f]) return zip.files[f];
|
2014-10-10 02:22:38 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getzipfile(zip, file) {
|
|
|
|
|
var o = safegetzipfile(zip, file);
|
|
|
|
|
if(o == null) throw new Error("Cannot find file " + file + " in zip");
|
|
|
|
|
return o;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-15 05:08:18 +00:00
|
|
|
|
function getzipdata(zip, file, safe) {
|
|
|
|
|
if(!safe) return getdata(getzipfile(zip, file));
|
|
|
|
|
if(!file) return null;
|
|
|
|
|
try { return getzipdata(zip, file); } catch(e) { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var _fs, jszip;
|
|
|
|
|
if(typeof JSZip !== 'undefined') jszip = JSZip;
|
|
|
|
|
if (typeof exports !== 'undefined') {
|
|
|
|
|
if (typeof module !== 'undefined' && module.exports) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(has_buf && typeof jszip === 'undefined') jszip = require('js'+'zip');
|
|
|
|
|
if(typeof jszip === 'undefined') jszip = require('./js'+'zip').JSZip;
|
|
|
|
|
_fs = require('f'+'s');
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var attregexg=/\b[\w:]+=["'][^"]*['"]/g;
|
|
|
|
|
var tagregex=/<[^>]*>/g;
|
|
|
|
|
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
function parsexmltag(tag, skip_root) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var z = [];
|
|
|
|
|
var eq = 0, c = 0;
|
|
|
|
|
for(; eq !== tag.length; ++eq) if((c = tag.charCodeAt(eq)) === 32 || c === 10 || c === 13) break;
|
|
|
|
|
if(!skip_root) z[0] = tag.substr(0, eq);
|
|
|
|
|
if(eq === tag.length) return z;
|
|
|
|
|
var m = tag.match(attregexg), j=0, w="", v="", i=0, q="", cc="";
|
2014-06-02 05:19:07 +00:00
|
|
|
|
if(m) for(i = 0; i != m.length; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
cc = m[i];
|
|
|
|
|
for(c=0; c != cc.length; ++c) if(cc.charCodeAt(c) === 61) break;
|
|
|
|
|
q = cc.substr(0,c); v = cc.substring(c+2, cc.length-1);
|
|
|
|
|
for(j=0;j!=q.length;++j) if(q.charCodeAt(j) === 58) break;
|
|
|
|
|
if(j===q.length) z[q] = v;
|
|
|
|
|
else z[(j===5 && q.substr(0,5)==="xmlns"?"xmlns":"")+q.substr(j+1)] = v;
|
2014-06-02 05:19:07 +00:00
|
|
|
|
}
|
2013-05-02 16:59:27 +00:00
|
|
|
|
return z;
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function strip_ns(x) { return x.replace(nsregex2, "<$1"); }
|
2013-05-02 16:59:27 +00:00
|
|
|
|
|
|
|
|
|
var encodings = {
|
|
|
|
|
'"': '"',
|
|
|
|
|
''': "'",
|
|
|
|
|
'>': '>',
|
|
|
|
|
'<': '<',
|
|
|
|
|
'&': '&'
|
|
|
|
|
};
|
2014-01-29 06:00:09 +00:00
|
|
|
|
var rencoding = evert(encodings);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var rencstr = "&<>'\"".split("");
|
2014-01-29 06:00:09 +00:00
|
|
|
|
|
2013-05-02 16:59:27 +00:00
|
|
|
|
// TODO: CP remap (need to read file version to determine OS)
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var encregex = /&[a-z]*;/g, coderegex = /_x([\da-fA-F]+)_/g;
|
2013-05-02 16:59:27 +00:00
|
|
|
|
function unescapexml(text){
|
|
|
|
|
var s = text + '';
|
2014-07-28 13:22:32 +00:00
|
|
|
|
return s.replace(encregex, function($$) { return encodings[$$]; }).replace(coderegex,function(m,c) {return String.fromCharCode(parseInt(c,16));});
|
2013-05-02 16:59:27 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var decregex=/[&<>'"]/g, charegex = /[\u0000-\u0008\u000b-\u001f]/g;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
function escapexml(text){
|
|
|
|
|
var s = text + '';
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return s.replace(decregex, function(y) { return rencoding[y]; }).replace(charegex,function(s) { return "_x" + ("000"+s.charCodeAt(0).toString(16)).substr(-4) + "_";});
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-05-02 16:59:27 +00:00
|
|
|
|
function parsexmlbool(value, tag) {
|
|
|
|
|
switch(value) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case '1': case 'true': case 'TRUE': return true;
|
|
|
|
|
/* case '0': case 'false': case 'FALSE':*/
|
|
|
|
|
default: return false;
|
2013-05-02 16:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var utf8read = function utf8reada(orig) {
|
|
|
|
|
var out = "", i = 0, c = 0, d = 0, e = 0, f = 0, w = 0;
|
2013-05-02 16:59:27 +00:00
|
|
|
|
while (i < orig.length) {
|
|
|
|
|
c = orig.charCodeAt(i++);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if (c < 128) { out += String.fromCharCode(c); continue; }
|
|
|
|
|
d = orig.charCodeAt(i++);
|
|
|
|
|
if (c>191 && c<224) { out += String.fromCharCode(((c & 31) << 6) | (d & 63)); continue; }
|
|
|
|
|
e = orig.charCodeAt(i++);
|
|
|
|
|
if (c < 240) { out += String.fromCharCode(((c & 15) << 12) | ((d & 63) << 6) | (e & 63)); continue; }
|
|
|
|
|
f = orig.charCodeAt(i++);
|
|
|
|
|
w = (((c & 7) << 18) | ((d & 63) << 12) | ((e & 63) << 6) | (f & 63))-65536;
|
|
|
|
|
out += String.fromCharCode(0xD800 + ((w>>>10)&1023));
|
|
|
|
|
out += String.fromCharCode(0xDC00 + (w&1023));
|
2013-05-02 16:59:27 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return out;
|
2013-05-02 16:59:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(has_buf) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var utf8readb = function utf8readb(data) {
|
|
|
|
|
var out = new Buffer(2*data.length), w, i, j = 1, k = 0, ww=0, c;
|
|
|
|
|
for(i = 0; i < data.length; i+=j) {
|
|
|
|
|
j = 1;
|
|
|
|
|
if((c=data.charCodeAt(i)) < 128) w = c;
|
|
|
|
|
else if(c < 224) { w = (c&31)*64+(data.charCodeAt(i+1)&63); j=2; }
|
|
|
|
|
else if(c < 240) { w=(c&15)*4096+(data.charCodeAt(i+1)&63)*64+(data.charCodeAt(i+2)&63); j=3; }
|
|
|
|
|
else { j = 4;
|
|
|
|
|
w = (c & 7)*262144+(data.charCodeAt(i+1)&63)*4096+(data.charCodeAt(i+2)&63)*64+(data.charCodeAt(i+3)&63);
|
|
|
|
|
w -= 65536; ww = 0xD800 + ((w>>>10)&1023); w = 0xDC00 + (w&1023);
|
|
|
|
|
}
|
|
|
|
|
if(ww !== 0) { out[k++] = ww&255; out[k++] = ww>>>8; ww = 0; }
|
|
|
|
|
out[k++] = w%256; out[k++] = w>>>8;
|
|
|
|
|
}
|
|
|
|
|
out.length = k;
|
|
|
|
|
return out.toString('ucs2');
|
|
|
|
|
};
|
|
|
|
|
var corpus = "foo bar baz\u00e2\u0098\u0083\u00f0\u009f\u008d\u00a3";
|
|
|
|
|
if(utf8read(corpus) == utf8readb(corpus)) utf8read = utf8readb;
|
|
|
|
|
var utf8readc = function utf8readc(data) { return Buffer(data, 'binary').toString('utf8'); };
|
|
|
|
|
if(utf8read(corpus) == utf8readc(corpus)) utf8read = utf8readc;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-02 16:59:27 +00:00
|
|
|
|
// matches <foo>...</foo> extracts content
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var matchtag = (function() {
|
|
|
|
|
var mtcache = {};
|
|
|
|
|
return function matchtag(f,g) {
|
|
|
|
|
var t = f+"|"+g;
|
|
|
|
|
if(mtcache[t] !== undefined) return mtcache[t];
|
|
|
|
|
return (mtcache[t] = new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?(?:[^>]*)>([^\u2603]*)</(?:\\w+:)?'+f+'>',(g||"")));
|
|
|
|
|
};
|
|
|
|
|
})();
|
2013-05-02 16:59:27 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var vtregex = (function(){ var vt_cache = {};
|
|
|
|
|
return function vt_regex(bt) {
|
|
|
|
|
if(vt_cache[bt] !== undefined) return vt_cache[bt];
|
|
|
|
|
return (vt_cache[bt] = new RegExp("<vt:" + bt + ">(.*?)</vt:" + bt + ">", 'g') );
|
|
|
|
|
};})();
|
|
|
|
|
var vtvregex = /<\/?vt:variant>/g, vtmregex = /<vt:([^>]*)>(.*)</;
|
2013-05-02 16:59:27 +00:00
|
|
|
|
function parseVector(data) {
|
|
|
|
|
var h = parsexmltag(data);
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var matches = data.match(vtregex(h.baseType))||[];
|
2013-05-02 16:59:27 +00:00
|
|
|
|
if(matches.length != h.size) throw "unexpected vector length " + matches.length + " != " + h.size;
|
|
|
|
|
var res = [];
|
|
|
|
|
matches.forEach(function(x) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var v = x.replace(vtvregex,"").match(vtmregex);
|
2013-05-02 16:59:27 +00:00
|
|
|
|
res.push({v:v[2], t:v[1]});
|
|
|
|
|
});
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var wtregex = /(^\s|\s$|\n)/;
|
|
|
|
|
function writetag(f,g) {return '<' + f + (g.match(wtregex)?' xml:space="preserve"' : "") + '>' + g + '</' + f + '>';}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function wxt_helper(h) { return keys(h).map(function(k) { return " " + k + '="' + h[k] + '"';}).join(""); }
|
|
|
|
|
function writextag(f,g,h) { return '<' + f + (isval(h) ? wxt_helper(h) : "") + (isval(g) ? (g.match(wtregex)?' xml:space="preserve"' : "") + '>' + g + '</' + f : "/") + '>';}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
function write_w3cdtf(d, t) { try { return d.toISOString().replace(/\.\d*/,""); } catch(e) { if(t) throw e; } }
|
|
|
|
|
|
|
|
|
|
function write_vt(s) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
switch(typeof s) {
|
|
|
|
|
case 'string': return writextag('vt:lpwstr', s);
|
|
|
|
|
case 'number': return writextag((s|0)==s?'vt:i4':'vt:r8', String(s));
|
|
|
|
|
case 'boolean': return writextag('vt:bool',s?'true':'false');
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(s instanceof Date) return writextag('vt:filetime', write_w3cdtf(s));
|
|
|
|
|
throw new Error("Unable to serialize " + s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
|
|
|
|
|
var XMLNS = {
|
|
|
|
|
'dc': 'http://purl.org/dc/elements/1.1/',
|
|
|
|
|
'dcterms': 'http://purl.org/dc/terms/',
|
|
|
|
|
'dcmitype': 'http://purl.org/dc/dcmitype/',
|
|
|
|
|
'mx': 'http://schemas.microsoft.com/office/mac/excel/2008/main',
|
|
|
|
|
'r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
|
|
|
|
'sjs': 'http://schemas.openxmlformats.org/package/2006/sheetjs/core-properties',
|
|
|
|
|
'vt': 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes',
|
|
|
|
|
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
|
|
|
'xsd': 'http://www.w3.org/2001/XMLSchema'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
XMLNS.main = [
|
|
|
|
|
'http://schemas.openxmlformats.org/spreadsheetml/2006/main',
|
|
|
|
|
'http://purl.oclc.org/ooxml/spreadsheetml/main',
|
|
|
|
|
'http://schemas.microsoft.com/office/excel/2006/main',
|
|
|
|
|
'http://schemas.microsoft.com/office/excel/2006/2'
|
|
|
|
|
];
|
2014-01-28 16:38:02 +00:00
|
|
|
|
function readIEEE754(buf, idx, isLE, nl, ml) {
|
|
|
|
|
if(isLE === undefined) isLE = true;
|
|
|
|
|
if(!nl) nl = 8;
|
|
|
|
|
if(!ml && nl === 8) ml = 52;
|
|
|
|
|
var e, m, el = nl * 8 - ml - 1, eMax = (1 << el) - 1, eBias = eMax >> 1;
|
|
|
|
|
var bits = -7, d = isLE ? -1 : 1, i = isLE ? (nl - 1) : 0, s = buf[idx + i];
|
|
|
|
|
|
|
|
|
|
i += d;
|
|
|
|
|
e = s & ((1 << (-bits)) - 1); s >>>= (-bits); bits += el;
|
|
|
|
|
for (; bits > 0; e = e * 256 + buf[idx + i], i += d, bits -= 8);
|
|
|
|
|
m = e & ((1 << (-bits)) - 1); e >>>= (-bits); bits += ml;
|
|
|
|
|
for (; bits > 0; m = m * 256 + buf[idx + i], i += d, bits -= 8);
|
|
|
|
|
if (e === eMax) return m ? NaN : ((s ? -1 : 1) * Infinity);
|
|
|
|
|
else if (e === 0) e = 1 - eBias;
|
|
|
|
|
else { m = m + Math.pow(2, ml); e = e - eBias; }
|
|
|
|
|
return (s ? -1 : 1) * m * Math.pow(2, e - ml);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var __toBuffer, ___toBuffer;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
__toBuffer = ___toBuffer = function toBuffer_(bufs) { var x = []; for(var i = 0; i < bufs[0].length; ++i) { x.push.apply(x, bufs[0][i]); } return x; };
|
|
|
|
|
var __double, ___double;
|
|
|
|
|
__double = ___double = function(b, idx) { return readIEEE754(b, idx);};
|
|
|
|
|
|
|
|
|
|
var is_buf = function is_buf_a(a) { return Array.isArray(a); };
|
|
|
|
|
if(has_buf) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
__toBuffer = function(bufs) { return (bufs[0].length > 0 && Buffer.isBuffer(bufs[0][0])) ? Buffer.concat(bufs[0]) : ___toBuffer(bufs);};
|
2014-07-28 13:22:32 +00:00
|
|
|
|
__double = function double_(b,i) { if(Buffer.isBuffer(b)) return b.readDoubleLE(i); return ___double(b,i); };
|
|
|
|
|
is_buf = function is_buf_b(a) { return Buffer.isBuffer(a) || Array.isArray(a); };
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var __readUInt8 = function(b, idx) { return b[idx]; };
|
|
|
|
|
var __readUInt16LE = function(b, idx) { return b[idx+1]*(1<<8)+b[idx]; };
|
|
|
|
|
var __readInt16LE = function(b, idx) { var u = b[idx+1]*(1<<8)+b[idx]; return (u < 0x8000) ? u : (0xffff - u + 1) * -1; };
|
|
|
|
|
var __readUInt32LE = function(b, idx) { return b[idx+3]*(1<<24)+(b[idx+2]<<16)+(b[idx+1]<<8)+b[idx]; };
|
|
|
|
|
var __readInt32LE = function(b, idx) { return (b[idx+3]<<24)|(b[idx+2]<<16)|(b[idx+1]<<8)|b[idx]; };
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ReadShift(size, t) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var o="", oo=[], w, vv, i, loc;
|
|
|
|
|
if(t === 'dbcs') {
|
|
|
|
|
loc = this.l;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(has_buf && Buffer.isBuffer(this)) o = this.slice(this.l, this.l+2*size).toString("utf16le");
|
2014-06-29 18:29:45 +00:00
|
|
|
|
else for(i = 0; i != size; ++i) { o+=String.fromCharCode(__readUInt16LE(this, loc)); loc+=2; }
|
|
|
|
|
size *= 2;
|
|
|
|
|
} else switch(size) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 1: o = __readUInt8(this, this.l); break;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 2: o = (t === 'i' ? __readInt16LE : __readUInt16LE)(this, this.l); break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 4: o = __readUInt32LE(this, this.l); break;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
case 8: if(t === 'f') { o = __double(this, this.l); break; }
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
this.l+=size; return o;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
function WriteShift(t, val, f) {
|
|
|
|
|
var size, i;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(f === 'dbcs') {
|
|
|
|
|
for(i = 0; i != val.length; ++i) this.writeUInt16LE(val.charCodeAt(i), this.l + 2 * i);
|
|
|
|
|
size = 2 * val.length;
|
|
|
|
|
} else switch(t) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
case 1: size = 1; this[this.l] = val&255; break;
|
|
|
|
|
case 3: size = 3; this[this.l+2] = val & 255; val >>>= 8; this[this.l+1] = val&255; val >>>= 8; this[this.l] = val&255; break;
|
2014-05-29 22:30:03 +00:00
|
|
|
|
case 4: size = 4; this.writeUInt32LE(val, this.l); break;
|
|
|
|
|
case 8: size = 8; if(f === 'f') { this.writeDoubleLE(val, this.l); break; }
|
|
|
|
|
/* falls through */
|
|
|
|
|
case 16: break;
|
|
|
|
|
case -4: size = 4; this.writeInt32LE(val, this.l); break;
|
|
|
|
|
}
|
|
|
|
|
this.l += size; return this;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function prep_blob(blob, pos) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
blob.l = pos;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
blob.read_shift = ReadShift;
|
|
|
|
|
blob.write_shift = WriteShift;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parsenoop(blob, length) { blob.l += length; }
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
|
|
|
|
function writenoop(blob, length) { blob.l += length; }
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function new_buf(sz) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var o = has_buf ? new Buffer(sz) : new Array(sz);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
prep_blob(o, 0);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.1.4 Record */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function recordhopper(data, cb, opts) {
|
2014-01-29 06:00:09 +00:00
|
|
|
|
var tmpbyte, cntbyte, length;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
prep_blob(data, data.l || 0);
|
|
|
|
|
while(data.l < data.length) {
|
|
|
|
|
var RT = data.read_shift(1);
|
|
|
|
|
if(RT & 0x80) RT = (RT & 0x7F) + ((data.read_shift(1) & 0x7F)<<7);
|
|
|
|
|
var R = RecordEnum[RT] || RecordEnum[0xFFFF];
|
2014-02-12 06:09:42 +00:00
|
|
|
|
tmpbyte = data.read_shift(1);
|
|
|
|
|
length = tmpbyte & 0x7F;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
for(cntbyte = 1; cntbyte <4 && (tmpbyte & 0x80); ++cntbyte) length += ((tmpbyte = data.read_shift(1)) & 0x7F)<<(7*cntbyte);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
var d = R.f(data, length, opts);
|
2014-01-31 11:52:18 +00:00
|
|
|
|
if(cb(d, R, RT)) return;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* control buffer usage for fixed-length buffers */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function buf_array() {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var bufs = [], blksz = 2048;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var newblk = function ba_newblk(sz) {
|
|
|
|
|
var o = new_buf(sz);
|
|
|
|
|
prep_blob(o, 0);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
return o;
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var curbuf = newblk(blksz);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var endbuf = function ba_endbuf() {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
curbuf.length = curbuf.l;
|
|
|
|
|
if(curbuf.length > 0) bufs.push(curbuf);
|
|
|
|
|
curbuf = null;
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var next = function ba_next(sz) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
if(sz < curbuf.length - curbuf.l) return curbuf;
|
|
|
|
|
endbuf();
|
|
|
|
|
return (curbuf = newblk(Math.max(sz+1, blksz)));
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var end = function ba_end() {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
endbuf();
|
|
|
|
|
return __toBuffer([bufs]);
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var push = function ba_push(buf) { endbuf(); curbuf = buf; next(blksz); };
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
|
|
|
|
return { next:next, push:push, end:end, _bufs:bufs };
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_record(ba, type, payload, length) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var t = evert_RE[type], l;
|
|
|
|
|
if(!length) length = RecordEnum[t].p || (payload||[]).length || 0;
|
|
|
|
|
l = 1 + (t >= 0x80 ? 1 : 0) + 1 + length;
|
|
|
|
|
if(length >= 0x80) ++l; if(length >= 0x4000) ++l; if(length >= 0x200000) ++l;
|
|
|
|
|
var o = ba.next(l);
|
|
|
|
|
if(t <= 0x7F) o.write_shift(1, t);
|
|
|
|
|
else {
|
|
|
|
|
o.write_shift(1, (t & 0x7F) + 0x80);
|
|
|
|
|
o.write_shift(1, (t >> 7));
|
|
|
|
|
}
|
|
|
|
|
for(var i = 0; i != 4; ++i) {
|
|
|
|
|
if(length >= 0x80) { o.write_shift(1, (length & 0x7F)+0x80); length >>= 7; }
|
|
|
|
|
else { o.write_shift(1, length); break; }
|
|
|
|
|
}
|
|
|
|
|
if(length > 0 && is_buf(payload)) ba.push(payload);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-02-12 06:09:42 +00:00
|
|
|
|
/* [MS-XLSB] 2.5.143 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_StrRun(data, length) {
|
2014-02-12 06:09:42 +00:00
|
|
|
|
return { ich: data.read_shift(2), ifnt: data.read_shift(2) };
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.1.7.121 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_RichStr(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var start = data.l;
|
|
|
|
|
var flags = data.read_shift(1);
|
|
|
|
|
var str = parse_XLWideString(data);
|
2014-02-12 06:09:42 +00:00
|
|
|
|
var rgsStrRun = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var z = { t: str, h: str };
|
|
|
|
|
if((flags & 1) !== 0) { /* fRichStr */
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* TODO: formatted string */
|
|
|
|
|
var dwSizeStrRun = data.read_shift(4);
|
2014-02-12 06:09:42 +00:00
|
|
|
|
for(var i = 0; i != dwSizeStrRun; ++i) rgsStrRun.push(parse_StrRun(data));
|
2014-06-29 18:29:45 +00:00
|
|
|
|
z.r = rgsStrRun;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
else z.r = "<t>" + escapexml(str) + "</t>";
|
|
|
|
|
if((flags & 2) !== 0) { /* fExtStr */
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* TODO: phonetic string */
|
|
|
|
|
}
|
|
|
|
|
data.l = start + length;
|
|
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
function write_RichStr(str, o) {
|
|
|
|
|
/* TODO: formatted string */
|
|
|
|
|
if(o == null) o = new_buf(5+2*str.t.length);
|
|
|
|
|
o.write_shift(1,0);
|
|
|
|
|
write_XLWideString(str.t, o);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.9 */
|
|
|
|
|
function parse_Cell(data) {
|
|
|
|
|
var col = data.read_shift(4);
|
|
|
|
|
var iStyleRef = data.read_shift(2);
|
|
|
|
|
iStyleRef += data.read_shift(1) <<16;
|
|
|
|
|
var fPhShow = data.read_shift(1);
|
2014-01-31 11:52:18 +00:00
|
|
|
|
return { c:col, iStyleRef: iStyleRef };
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
function write_Cell(cell, o) {
|
|
|
|
|
if(o == null) o = new_buf(8);
|
|
|
|
|
o.write_shift(-4, cell.c);
|
|
|
|
|
o.write_shift(3, cell.iStyleRef === undefined ? cell.iStyleRef : cell.s);
|
|
|
|
|
o.write_shift(1, 0); /* fPhShow */
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.21 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_CodeName (data, length) { return parse_XLWideString(data, length); }
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* [MS-XLSB] 2.5.166 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_XLNullableWideString(data) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var cchCharacters = data.read_shift(4);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return cchCharacters === 0 || cchCharacters === 0xFFFFFFFF ? "" : data.read_shift(cchCharacters, 'dbcs');
|
|
|
|
|
}
|
|
|
|
|
function write_XLNullableWideString(data, o) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
if(!o) o = new_buf(127);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o.write_shift(4, data.length > 0 ? data.length : 0xFFFFFFFF);
|
|
|
|
|
if(data.length > 0) o.write_shift(0, data, 'dbcs');
|
2014-05-29 22:30:03 +00:00
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.168 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_XLWideString(data) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var cchCharacters = data.read_shift(4);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return cchCharacters === 0 ? "" : data.read_shift(cchCharacters, 'dbcs');
|
|
|
|
|
}
|
|
|
|
|
function write_XLWideString(data, o) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(o == null) o = new_buf(4+2*data.length);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
o.write_shift(4, data.length);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(data.length > 0) o.write_shift(0, data, 'dbcs');
|
2014-05-29 22:30:03 +00:00
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.5.114 */
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var parse_RelID = parse_XLNullableWideString;
|
|
|
|
|
var write_RelID = write_XLNullableWideString;
|
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.122 */
|
|
|
|
|
function parse_RkNumber(data) {
|
|
|
|
|
var b = data.slice(data.l, data.l+4);
|
|
|
|
|
var fX100 = b[0] & 1, fInt = b[0] & 2;
|
|
|
|
|
data.l+=4;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
b[0] &= 0xFC;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var RK = fInt === 0 ? __double([0,0,0,0,b[0],b[1],b[2],b[3]],0) : __readInt32LE(b,0)>>2;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
return fX100 ? RK/100 : RK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.153 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_UncheckedRfX(data) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
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);
|
|
|
|
|
cell.e.c = data.read_shift(4);
|
|
|
|
|
return cell;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_UncheckedRfX(r, o) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
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);
|
|
|
|
|
o.write_shift(4, r.e.c);
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.171 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_Xnum(data, length) { return data.read_shift(8, 'f'); }
|
|
|
|
|
function write_Xnum(data, o) { return (o || new_buf(8)).write_shift(8, 'f', data); }
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.5.198.2 */
|
|
|
|
|
var BErr = {
|
|
|
|
|
0x00: "#NULL!",
|
|
|
|
|
0x07: "#DIV/0!",
|
|
|
|
|
0x0F: "#VALUE!",
|
|
|
|
|
0x17: "#REF!",
|
|
|
|
|
0x1D: "#NAME?",
|
|
|
|
|
0x24: "#NUM!",
|
|
|
|
|
0x2A: "#N/A",
|
|
|
|
|
0x2B: "#GETTING_DATA",
|
|
|
|
|
0xFF: "#WTF?"
|
|
|
|
|
};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var RBErr = evert_num(BErr);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-03-29 02:05:50 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.321 BrtColor */
|
|
|
|
|
function parse_BrtColor(data, length) {
|
|
|
|
|
var out = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var d = data.read_shift(1);
|
2014-03-29 02:05:50 +00:00
|
|
|
|
out.fValidRGB = d & 1;
|
|
|
|
|
out.xColorType = d >>> 1;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out.index = data.read_shift(1);
|
|
|
|
|
out.nTintAndShade = data.read_shift(2, 'i');
|
|
|
|
|
out.bRed = data.read_shift(1);
|
|
|
|
|
out.bGreen = data.read_shift(1);
|
|
|
|
|
out.bBlue = data.read_shift(1);
|
|
|
|
|
out.bAlpha = data.read_shift(1);
|
2014-03-29 02:05:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* [MS-XLSB] 2.5.52 */
|
2014-03-29 02:05:50 +00:00
|
|
|
|
function parse_FontFlags(data, length) {
|
|
|
|
|
var d = data.read_shift(1);
|
|
|
|
|
data.l++;
|
|
|
|
|
var out = {
|
|
|
|
|
fItalic: d & 0x2,
|
|
|
|
|
fStrikeout: d & 0x8,
|
|
|
|
|
fOutline: d & 0x10,
|
|
|
|
|
fShadow: d & 0x20,
|
|
|
|
|
fCondense: d & 0x40,
|
2014-05-17 18:57:29 +00:00
|
|
|
|
fExtend: d & 0x80
|
2014-03-29 02:05:50 +00:00
|
|
|
|
};
|
|
|
|
|
return out;
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* 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 */
|
|
|
|
|
var ct2type = {
|
|
|
|
|
/* Workbook */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml": "workbooks",
|
2014-04-23 01:37:08 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Worksheet */
|
|
|
|
|
"application/vnd.ms-excel.binIndexWs": "TODO", /* Binary Index */
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Chartsheet */
|
|
|
|
|
"application/vnd.ms-excel.chartsheet": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Dialogsheet */
|
|
|
|
|
"application/vnd.ms-excel.dialogsheet": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Macrosheet */
|
|
|
|
|
"application/vnd.ms-excel.macrosheet": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.macrosheet+xml": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.intlmacrosheet": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.binIndexMs": "TODO", /* Binary Index */
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* File Properties */
|
|
|
|
|
"application/vnd.openxmlformats-package.core-properties+xml": "coreprops",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.custom-properties+xml": "custprops",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.extended-properties+xml": "extprops",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Custom Data Properties */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.customXmlProperties+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Comments */
|
|
|
|
|
"application/vnd.ms-excel.comments": "comments",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml": "comments",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* PivotTable */
|
|
|
|
|
"application/vnd.ms-excel.pivotTable": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Calculation Chain */
|
|
|
|
|
"application/vnd.ms-excel.calcChain": "calcchains",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml": "calcchains",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Printer Settings */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* ActiveX */
|
|
|
|
|
"application/vnd.ms-office.activeX": "TODO",
|
|
|
|
|
"application/vnd.ms-office.activeX+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Custom Toolbars */
|
|
|
|
|
"application/vnd.ms-excel.attachedToolbars": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* External Data Connections */
|
|
|
|
|
"application/vnd.ms-excel.connections": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* External Links */
|
|
|
|
|
"application/vnd.ms-excel.externalLink": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml": "TODO",
|
2013-05-02 16:59:27 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Metadata */
|
|
|
|
|
"application/vnd.ms-excel.sheetMetadata": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* PivotCache */
|
|
|
|
|
"application/vnd.ms-excel.pivotCacheDefinition": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.pivotCacheRecords": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml": "TODO",
|
2014-04-23 01:37:08 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Query Table */
|
|
|
|
|
"application/vnd.ms-excel.queryTable": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml": "TODO",
|
2013-05-02 16:59:27 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Shared Workbook */
|
|
|
|
|
"application/vnd.ms-excel.userNames": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.revisionHeaders": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.revisionLog": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml": "TODO",
|
2014-01-18 13:45:49 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Single Cell Table */
|
|
|
|
|
"application/vnd.ms-excel.tableSingleCells": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml": "TODO",
|
2012-12-04 19:27:20 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* Slicer */
|
|
|
|
|
"application/vnd.ms-excel.slicer": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.slicerCache": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.slicer+xml": "TODO",
|
|
|
|
|
"application/vnd.ms-excel.slicerCache+xml": "TODO",
|
2014-04-03 22:51:54 +00:00
|
|
|
|
|
|
|
|
|
/* Sort Map */
|
|
|
|
|
"application/vnd.ms-excel.wsSortMap": "TODO",
|
|
|
|
|
|
|
|
|
|
/* Table */
|
|
|
|
|
"application/vnd.ms-excel.table": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml": "TODO",
|
|
|
|
|
|
|
|
|
|
/* Themes */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.theme+xml": "themes",
|
|
|
|
|
|
|
|
|
|
/* Timeline */
|
|
|
|
|
"application/vnd.ms-excel.Timeline+xml": "TODO", /* verify */
|
|
|
|
|
"application/vnd.ms-excel.TimelineCache+xml": "TODO", /* verify */
|
|
|
|
|
|
|
|
|
|
/* VBA */
|
|
|
|
|
"application/vnd.ms-office.vbaProject": "vba",
|
|
|
|
|
"application/vnd.ms-office.vbaProjectSignature": "vba",
|
|
|
|
|
|
|
|
|
|
/* Volatile Dependencies */
|
|
|
|
|
"application/vnd.ms-office.volatileDependencies": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml": "TODO",
|
|
|
|
|
|
|
|
|
|
/* Control Properties */
|
|
|
|
|
"application/vnd.ms-excel.controlproperties+xml": "TODO",
|
|
|
|
|
|
|
|
|
|
/* Data Model */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.model+data": "TODO",
|
|
|
|
|
|
|
|
|
|
/* Survey */
|
|
|
|
|
"application/vnd.ms-excel.Survey+xml": "TODO",
|
|
|
|
|
|
|
|
|
|
/* Drawing */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawing+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml": "TODO",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml": "TODO",
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* VML */
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.vmlDrawing": "TODO",
|
|
|
|
|
|
|
|
|
|
"application/vnd.openxmlformats-package.relationships+xml": "rels",
|
|
|
|
|
"application/vnd.openxmlformats-officedocument.oleObject": "TODO",
|
|
|
|
|
|
|
|
|
|
"sheet": "js"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var CT_LIST = (function(){
|
|
|
|
|
var o = {
|
|
|
|
|
workbooks: {
|
|
|
|
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
|
|
|
|
|
xlsm: "application/vnd.ms-excel.sheet.macroEnabled.main+xml",
|
|
|
|
|
xlsb: "application/vnd.ms-excel.sheet.binary.macroEnabled.main",
|
|
|
|
|
xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
|
|
|
|
|
},
|
|
|
|
|
strs: { /* Shared Strings */
|
|
|
|
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
|
|
|
|
|
xlsb: "application/vnd.ms-excel.sharedStrings"
|
|
|
|
|
},
|
|
|
|
|
sheets: {
|
|
|
|
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
|
|
|
|
|
xlsb: "application/vnd.ms-excel.worksheet"
|
|
|
|
|
},
|
|
|
|
|
styles: {/* Styles */
|
|
|
|
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
|
|
|
|
|
xlsb: "application/vnd.ms-excel.styles"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
keys(o).forEach(function(k) { if(!o[k].xlsm) o[k].xlsm = o[k].xlsx; });
|
|
|
|
|
keys(o).forEach(function(k){ keys(o[k]).forEach(function(v) { ct2type[o[k][v]] = k; }); });
|
|
|
|
|
return o;
|
|
|
|
|
})();
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var type2ct = evert_arr(ct2type);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
XMLNS.CT = 'http://schemas.openxmlformats.org/package/2006/content-types';
|
|
|
|
|
|
|
|
|
|
function parse_ct(data, opts) {
|
|
|
|
|
var ctext = {};
|
|
|
|
|
if(!data || !data.match) return data;
|
|
|
|
|
var ct = { workbooks: [], sheets: [], calcchains: [], themes: [], styles: [],
|
|
|
|
|
coreprops: [], extprops: [], custprops: [], strs:[], comments: [], vba: [],
|
|
|
|
|
TODO:[], rels:[], xmlns: "" };
|
2014-06-29 18:29:45 +00:00
|
|
|
|
(data.match(tagregex)||[]).forEach(function(x) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var y = parsexmltag(x);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
switch(y[0].replace(nsregex,"<")) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
case '<?xml': break;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
case '<Types': ct.xmlns = y['xmlns' + (y[0].match(/<(\w+):/)||["",""])[1] ]; break;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
case '<Default': ctext[y.Extension] = y.ContentType; break;
|
|
|
|
|
case '<Override':
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(ct[ct2type[y.ContentType]] !== undefined) ct[ct2type[y.ContentType]].push(y.PartName);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
else if(opts.WTF) console.error(y);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if(ct.xmlns !== XMLNS.CT) throw new Error("Unknown Namespace: " + ct.xmlns);
|
|
|
|
|
ct.calcchain = ct.calcchains.length > 0 ? ct.calcchains[0] : "";
|
|
|
|
|
ct.sst = ct.strs.length > 0 ? ct.strs[0] : "";
|
|
|
|
|
ct.style = ct.styles.length > 0 ? ct.styles[0] : "";
|
|
|
|
|
ct.defaults = ctext;
|
|
|
|
|
delete ct.calcchains;
|
|
|
|
|
return ct;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var CTYPE_XML_ROOT = writextag('Types', null, {
|
|
|
|
|
'xmlns': XMLNS.CT,
|
|
|
|
|
'xmlns:xsd': XMLNS.xsd,
|
|
|
|
|
'xmlns:xsi': XMLNS.xsi
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var CTYPE_DEFAULTS = [
|
|
|
|
|
['xml', 'application/xml'],
|
2014-05-29 22:30:03 +00:00
|
|
|
|
['bin', 'application/vnd.ms-excel.sheet.binary.macroEnabled.main'],
|
2014-05-16 00:33:34 +00:00
|
|
|
|
['rels', type2ct.rels[0]]
|
|
|
|
|
].map(function(x) {
|
|
|
|
|
return writextag('Default', null, {'Extension':x[0], 'ContentType': x[1]});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function write_ct(ct, opts) {
|
|
|
|
|
var o = [], v;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (XML_HEADER);
|
|
|
|
|
o[o.length] = (CTYPE_XML_ROOT);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
o = o.concat(CTYPE_DEFAULTS);
|
|
|
|
|
var f1 = function(w) {
|
|
|
|
|
if(ct[w] && ct[w].length > 0) {
|
|
|
|
|
v = ct[w][0];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (writextag('Override', null, {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
'PartName': (v[0] == '/' ? "":"/") + v,
|
2014-05-16 00:50:55 +00:00
|
|
|
|
'ContentType': CT_LIST[w][opts.bookType || 'xlsx']
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
var f2 = function(w) {
|
|
|
|
|
ct[w].forEach(function(v) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (writextag('Override', null, {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
'PartName': (v[0] == '/' ? "":"/") + v,
|
2014-05-16 00:50:55 +00:00
|
|
|
|
'ContentType': CT_LIST[w][opts.bookType || 'xlsx']
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
var f3 = function(t) {
|
|
|
|
|
(ct[t]||[]).forEach(function(v) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (writextag('Override', null, {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
'PartName': (v[0] == '/' ? "":"/") + v,
|
|
|
|
|
'ContentType': type2ct[t][0]
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
f1('workbooks');
|
|
|
|
|
f2('sheets');
|
2014-05-16 00:50:55 +00:00
|
|
|
|
f3('themes');
|
2014-05-16 00:33:34 +00:00
|
|
|
|
['strs', 'styles'].forEach(f1);
|
|
|
|
|
['coreprops', 'extprops', 'custprops'].forEach(f3);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(o.length>2){ o[o.length] = ('</Types>'); o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
|
|
|
|
/* 9.3.2 OPC Relationships Markup */
|
|
|
|
|
var RELS = {
|
|
|
|
|
WB: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
|
|
|
SHEET: "http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function parse_rels(data, currentFilePath) {
|
|
|
|
|
if (!data) return data;
|
|
|
|
|
if (currentFilePath.charAt(0) !== '/') {
|
|
|
|
|
currentFilePath = '/'+currentFilePath;
|
|
|
|
|
}
|
|
|
|
|
var rels = {};
|
|
|
|
|
var hash = {};
|
|
|
|
|
var resolveRelativePathIntoAbsolute = function (to) {
|
|
|
|
|
var toksFrom = currentFilePath.split('/');
|
|
|
|
|
toksFrom.pop(); // folder path
|
|
|
|
|
var toksTo = to.split('/');
|
|
|
|
|
var reversed = [];
|
|
|
|
|
while (toksTo.length !== 0) {
|
|
|
|
|
var tokTo = toksTo.shift();
|
|
|
|
|
if (tokTo === '..') {
|
|
|
|
|
toksFrom.pop();
|
|
|
|
|
} else if (tokTo !== '.') {
|
|
|
|
|
toksFrom.push(tokTo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return toksFrom.join('/');
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
data.match(tagregex).forEach(function(x) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
|
/* 9.3.2.2 OPC_Relationships */
|
|
|
|
|
if (y[0] === '<Relationship') {
|
|
|
|
|
var rel = {}; rel.Type = y.Type; rel.Target = y.Target; rel.Id = y.Id; rel.TargetMode = y.TargetMode;
|
|
|
|
|
var canonictarget = y.TargetMode === 'External' ? y.Target : resolveRelativePathIntoAbsolute(y.Target);
|
|
|
|
|
rels[canonictarget] = rel;
|
|
|
|
|
hash[y.Id] = rel;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
rels["!id"] = hash;
|
|
|
|
|
return rels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMLNS.RELS = 'http://schemas.openxmlformats.org/package/2006/relationships';
|
|
|
|
|
|
|
|
|
|
var RELS_ROOT = writextag('Relationships', null, {
|
|
|
|
|
//'xmlns:ns0': XMLNS.RELS,
|
|
|
|
|
'xmlns': XMLNS.RELS
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* TODO */
|
|
|
|
|
function write_rels(rels) {
|
|
|
|
|
var o = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (XML_HEADER);
|
|
|
|
|
o[o.length] = (RELS_ROOT);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
keys(rels['!id']).forEach(function(rid) { var rel = rels['!id'][rid];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (writextag('Relationship', null, rel));
|
2014-05-16 00:33:34 +00:00
|
|
|
|
});
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(o.length>2){ o[o.length] = ('</Relationships>'); o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
|
|
|
|
/* ECMA-376 Part II 11.1 Core Properties Part */
|
|
|
|
|
/* [MS-OSHARED] 2.3.3.2.[1-2].1 (PIDSI/PIDDSI) */
|
|
|
|
|
var CORE_PROPS = [
|
|
|
|
|
["cp:category", "Category"],
|
|
|
|
|
["cp:contentStatus", "ContentStatus"],
|
|
|
|
|
["cp:keywords", "Keywords"],
|
|
|
|
|
["cp:lastModifiedBy", "LastAuthor"],
|
|
|
|
|
["cp:lastPrinted", "LastPrinted"],
|
|
|
|
|
["cp:revision", "RevNumber"],
|
|
|
|
|
["cp:version", "Version"],
|
|
|
|
|
["dc:creator", "Author"],
|
|
|
|
|
["dc:description", "Comments"],
|
|
|
|
|
["dc:identifier", "Identifier"],
|
|
|
|
|
["dc:language", "Language"],
|
|
|
|
|
["dc:subject", "Subject"],
|
|
|
|
|
["dc:title", "Title"],
|
|
|
|
|
["dcterms:created", "CreatedDate", 'date'],
|
|
|
|
|
["dcterms:modified", "ModifiedDate", 'date']
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
XMLNS.CORE_PROPS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties";
|
|
|
|
|
RELS.CORE_PROPS = 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties';
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var CORE_PROPS_REGEX = (function() {
|
|
|
|
|
var r = new Array(CORE_PROPS.length);
|
|
|
|
|
for(var i = 0; i < CORE_PROPS.length; ++i) {
|
|
|
|
|
var f = CORE_PROPS[i];
|
|
|
|
|
var g = "(?:"+ f[0].substr(0,f[0].indexOf(":")) +":)"+ f[0].substr(f[0].indexOf(":")+1);
|
|
|
|
|
r[i] = new RegExp("<" + g + "[^>]*>(.*)<\/" + g + ">");
|
|
|
|
|
}
|
|
|
|
|
return r;
|
|
|
|
|
})();
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
function parse_core_props(data) {
|
|
|
|
|
var p = {};
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(var i = 0; i < CORE_PROPS.length; ++i) {
|
|
|
|
|
var f = CORE_PROPS[i], cur = data.match(CORE_PROPS_REGEX[i]);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(cur != null && cur.length > 0) p[f[1]] = cur[1];
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(f[2] === 'date' && p[f[1]]) p[f[1]] = new Date(p[f[1]]);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var CORE_PROPS_XML_ROOT = writextag('cp:coreProperties', null, {
|
|
|
|
|
//'xmlns': XMLNS.CORE_PROPS,
|
|
|
|
|
'xmlns:cp': XMLNS.CORE_PROPS,
|
|
|
|
|
'xmlns:dc': XMLNS.dc,
|
|
|
|
|
'xmlns:dcterms': XMLNS.dcterms,
|
|
|
|
|
'xmlns:dcmitype': XMLNS.dcmitype,
|
|
|
|
|
'xmlns:xsi': XMLNS.xsi
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function cp_doit(f, g, h, o, p) {
|
|
|
|
|
if(p[f] != null || g == null || g === "") return;
|
|
|
|
|
p[f] = g;
|
|
|
|
|
o[o.length] = (h ? writextag(f,g,h) : writetag(f,g));
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function write_core_props(cp, opts) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var o = [XML_HEADER, CORE_PROPS_XML_ROOT], p = {};
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(!cp) return o.join("");
|
|
|
|
|
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(cp.CreatedDate != null) cp_doit("dcterms:created", typeof cp.CreatedDate === "string" ? cp.CreatedDate : write_w3cdtf(cp.CreatedDate, opts.WTF), {"xsi:type":"dcterms:W3CDTF"}, o, p);
|
|
|
|
|
if(cp.ModifiedDate != null) cp_doit("dcterms:modified", typeof cp.ModifiedDate === "string" ? cp.ModifiedDate : write_w3cdtf(cp.ModifiedDate, opts.WTF), {"xsi:type":"dcterms:W3CDTF"}, o, p);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(var i = 0; i != CORE_PROPS.length; ++i) { var f = CORE_PROPS[i]; cp_doit(f[0], cp[f[1]], null, o, p); }
|
|
|
|
|
if(o.length>2){ o[o.length] = ('</cp:coreProperties>'); o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
|
|
|
|
/* 15.2.12.3 Extended File Properties Part */
|
|
|
|
|
/* [MS-OSHARED] 2.3.3.2.[1-2].1 (PIDSI/PIDDSI) */
|
|
|
|
|
var EXT_PROPS = [
|
|
|
|
|
["Application", "Application", "string"],
|
|
|
|
|
["AppVersion", "AppVersion", "string"],
|
|
|
|
|
["Company", "Company", "string"],
|
|
|
|
|
["DocSecurity", "DocSecurity", "string"],
|
|
|
|
|
["Manager", "Manager", "string"],
|
|
|
|
|
["HyperlinksChanged", "HyperlinksChanged", "bool"],
|
|
|
|
|
["SharedDoc", "SharedDoc", "bool"],
|
|
|
|
|
["LinksUpToDate", "LinksUpToDate", "bool"],
|
|
|
|
|
["ScaleCrop", "ScaleCrop", "bool"],
|
|
|
|
|
["HeadingPairs", "HeadingPairs", "raw"],
|
2014-06-03 18:39:46 +00:00
|
|
|
|
["TitlesOfParts", "TitlesOfParts", "raw"]
|
2014-05-16 00:33:34 +00:00
|
|
|
|
];
|
2014-04-03 22:51:54 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
XMLNS.EXT_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";
|
|
|
|
|
RELS.EXT_PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties';
|
2014-03-29 02:05:50 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function parse_ext_props(data, p) {
|
|
|
|
|
var q = {}; if(!p) p = {};
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
EXT_PROPS.forEach(function(f) {
|
|
|
|
|
switch(f[2]) {
|
|
|
|
|
case "string": p[f[1]] = (data.match(matchtag(f[0]))||[])[1]; break;
|
|
|
|
|
case "bool": p[f[1]] = (data.match(matchtag(f[0]))||[])[1] === "true"; break;
|
|
|
|
|
case "raw":
|
|
|
|
|
var cur = data.match(new RegExp("<" + f[0] + "[^>]*>(.*)<\/" + f[0] + ">"));
|
|
|
|
|
if(cur && cur.length > 0) q[f[1]] = cur[1];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-02-18 03:16:38 +00:00
|
|
|
|
});
|
2012-12-04 19:27:20 +00:00
|
|
|
|
|
2013-04-17 01:32:20 +00:00
|
|
|
|
if(q.HeadingPairs && q.TitlesOfParts) {
|
|
|
|
|
var v = parseVector(q.HeadingPairs);
|
2013-03-05 22:01:01 +00:00
|
|
|
|
var j = 0, widx = 0;
|
|
|
|
|
for(var i = 0; i !== v.length; ++i) {
|
|
|
|
|
switch(v[i].v) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case "Worksheets": widx = j; p.Worksheets = +(v[++i].v); break;
|
2013-03-05 22:01:01 +00:00
|
|
|
|
case "Named Ranges": ++i; break; // TODO: Handle Named Ranges
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var parts = parseVector(q.TitlesOfParts).map(function(x) { return utf8read(x.v); });
|
2013-04-17 01:32:20 +00:00
|
|
|
|
p.SheetNames = parts.slice(widx, widx + p.Worksheets);
|
2013-03-05 22:01:01 +00:00
|
|
|
|
}
|
2012-12-04 19:27:20 +00:00
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var EXT_PROPS_XML_ROOT = writextag('Properties', null, {
|
|
|
|
|
'xmlns': XMLNS.EXT_PROPS,
|
|
|
|
|
'xmlns:vt': XMLNS.vt
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function write_ext_props(cp, opts) {
|
|
|
|
|
var o = [], p = {}, W = writextag;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
if(!cp) cp = {};
|
|
|
|
|
cp.Application = "SheetJS";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (XML_HEADER);
|
|
|
|
|
o[o.length] = (EXT_PROPS_XML_ROOT);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
EXT_PROPS.forEach(function(f) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(cp[f[1]] === undefined) return;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var v;
|
|
|
|
|
switch(f[2]) {
|
|
|
|
|
case 'string': v = cp[f[1]]; break;
|
|
|
|
|
case 'bool': v = cp[f[1]] ? 'true' : 'false'; break;
|
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(v !== undefined) o[o.length] = (W(f[0], v));
|
2014-05-16 00:33:34 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* TODO: HeadingPairs, TitlesOfParts */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (W('HeadingPairs', W('vt:vector', W('vt:variant', '<vt:lpstr>Worksheets</vt:lpstr>')+W('vt:variant', W('vt:i4', String(cp.Worksheets))), {size:2, baseType:"variant"})));
|
|
|
|
|
o[o.length] = (W('TitlesOfParts', W('vt:vector', cp.SheetNames.map(function(s) { return "<vt:lpstr>" + s + "</vt:lpstr>"; }).join(""), {size: cp.Worksheets, baseType:"lpstr"})));
|
|
|
|
|
if(o.length>2){ o[o.length] = ('</Properties>'); o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
2014-02-14 03:39:03 +00:00
|
|
|
|
/* 15.2.12.2 Custom File Properties Part */
|
2014-05-16 00:33:34 +00:00
|
|
|
|
XMLNS.CUST_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties";
|
|
|
|
|
RELS.CUST_PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties';
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var custregex = /<[^>]+>[^<]*/g;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function parse_cust_props(data, opts) {
|
2014-02-14 03:39:03 +00:00
|
|
|
|
var p = {}, name;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var m = data.match(custregex);
|
|
|
|
|
if(m) for(var i = 0; i != m.length; ++i) {
|
|
|
|
|
var x = m[i], y = parsexmltag(x);
|
2014-02-14 03:39:03 +00:00
|
|
|
|
switch(y[0]) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
case '<?xml': break;
|
|
|
|
|
case '<Properties':
|
|
|
|
|
if(y.xmlns !== XMLNS.CUST_PROPS) throw "unrecognized xmlns " + y.xmlns;
|
|
|
|
|
if(y.xmlnsvt && y.xmlnsvt !== XMLNS.vt) throw "unrecognized vt " + y.xmlnsvt;
|
|
|
|
|
break;
|
2014-02-14 03:39:03 +00:00
|
|
|
|
case '<property': name = y.name; break;
|
|
|
|
|
case '</property>': name = null; break;
|
|
|
|
|
default: if (x.indexOf('<vt:') === 0) {
|
|
|
|
|
var toks = x.split('>');
|
|
|
|
|
var type = toks[0].substring(4), text = toks[1];
|
|
|
|
|
/* 22.4.2.32 (CT_Variant). Omit the binary types from 22.4 (Variant Types) */
|
|
|
|
|
switch(type) {
|
|
|
|
|
case 'lpstr': case 'lpwstr': case 'bstr': case 'lpwstr':
|
|
|
|
|
p[name] = unescapexml(text);
|
|
|
|
|
break;
|
|
|
|
|
case 'bool':
|
|
|
|
|
p[name] = parsexmlbool(text, '<vt:bool>');
|
|
|
|
|
break;
|
|
|
|
|
case 'i1': case 'i2': case 'i4': case 'i8': case 'int': case 'uint':
|
|
|
|
|
p[name] = parseInt(text, 10);
|
|
|
|
|
break;
|
|
|
|
|
case 'r4': case 'r8': case 'decimal':
|
|
|
|
|
p[name] = parseFloat(text);
|
|
|
|
|
break;
|
|
|
|
|
case 'filetime': case 'date':
|
2014-05-16 00:33:34 +00:00
|
|
|
|
p[name] = new Date(text);
|
2014-02-14 03:39:03 +00:00
|
|
|
|
break;
|
|
|
|
|
case 'cy': case 'error':
|
|
|
|
|
p[name] = unescapexml(text);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(typeof console !== 'undefined') console.warn('Unexpected', x, type, toks);
|
2014-02-14 03:39:03 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
} else if(x.substr(0,2) === "</") {
|
|
|
|
|
} else if(opts.WTF) throw new Error(x);
|
2014-02-14 03:39:03 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-02-14 03:39:03 +00:00
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var CUST_PROPS_XML_ROOT = writextag('Properties', null, {
|
|
|
|
|
'xmlns': XMLNS.CUST_PROPS,
|
|
|
|
|
'xmlns:vt': XMLNS.vt
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function write_cust_props(cp, opts) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var o = [XML_HEADER, CUST_PROPS_XML_ROOT];
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(!cp) return o.join("");
|
|
|
|
|
var pid = 1;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
keys(cp).forEach(function custprop(k) { ++pid;
|
|
|
|
|
o[o.length] = (writextag('property', write_vt(cp[k]), {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
'fmtid': '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}',
|
|
|
|
|
'pid': pid,
|
|
|
|
|
'name': k
|
|
|
|
|
}));
|
|
|
|
|
});
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(o.length>2){ o[o.length] = '</Properties>'; o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
|
|
|
|
/* 18.4.1 charset to codepage mapping */
|
|
|
|
|
var CS2CP = {
|
|
|
|
|
0: 1252, /* ANSI */
|
|
|
|
|
1: 65001, /* DEFAULT */
|
|
|
|
|
2: 65001, /* SYMBOL */
|
|
|
|
|
77: 10000, /* MAC */
|
|
|
|
|
128: 932, /* SHIFTJIS */
|
|
|
|
|
129: 949, /* HANGUL */
|
|
|
|
|
130: 1361, /* JOHAB */
|
|
|
|
|
134: 936, /* GB2312 */
|
|
|
|
|
136: 950, /* CHINESEBIG5 */
|
|
|
|
|
161: 1253, /* GREEK */
|
|
|
|
|
162: 1254, /* TURKISH */
|
|
|
|
|
163: 1258, /* VIETNAMESE */
|
|
|
|
|
177: 1255, /* HEBREW */
|
|
|
|
|
178: 1256, /* ARABIC */
|
|
|
|
|
186: 1257, /* BALTIC */
|
|
|
|
|
204: 1251, /* RUSSIAN */
|
|
|
|
|
222: 874, /* THAI */
|
|
|
|
|
238: 1250, /* EASTEUROPE */
|
|
|
|
|
255: 1252, /* OEM */
|
|
|
|
|
69: 6969 /* MISC */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Parse a list of <r> tags */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var parse_rs = (function parse_rs_factory() {
|
|
|
|
|
var tregex = matchtag("t"), rpregex = matchtag("rPr"), rregex = /<r>/g, rend = /<\/r>/, nlregex = /\r\n/g;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* 18.4.7 rPr CT_RPrElt */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var parse_rpr = function parse_rpr(rpr, intro, outro) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var font = {}, cp = 65001;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var m = rpr.match(tagregex), i = 0;
|
|
|
|
|
if(m) for(;i!=m.length; ++i) {
|
|
|
|
|
var y = parsexmltag(m[i]);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
switch(y[0]) {
|
|
|
|
|
/* 18.8.12 condense CT_BooleanProperty */
|
|
|
|
|
/* ** not required . */
|
|
|
|
|
case '<condense': break;
|
|
|
|
|
/* 18.8.17 extend CT_BooleanProperty */
|
|
|
|
|
/* ** not required . */
|
|
|
|
|
case '<extend': break;
|
|
|
|
|
/* 18.8.36 shadow CT_BooleanProperty */
|
|
|
|
|
/* ** not required . */
|
|
|
|
|
case '<shadow':
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '<shadow/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.1 charset CT_IntProperty TODO */
|
|
|
|
|
case '<charset':
|
|
|
|
|
if(y.val == '1') break;
|
|
|
|
|
cp = CS2CP[parseInt(y.val, 10)];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.2 outline CT_BooleanProperty TODO */
|
|
|
|
|
case '<outline':
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '<outline/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.5 rFont CT_FontName */
|
|
|
|
|
case '<rFont': font.name = y.val; break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.11 sz CT_FontSize */
|
|
|
|
|
case '<sz': font.sz = y.val; break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.10 strike CT_BooleanProperty */
|
|
|
|
|
case '<strike':
|
|
|
|
|
if(!y.val) break;
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '<strike/>': font.strike = 1; break;
|
|
|
|
|
case '</strike>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.13 u CT_UnderlineProperty */
|
|
|
|
|
case '<u':
|
|
|
|
|
if(!y.val) break;
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '<u/>': font.u = 1; break;
|
|
|
|
|
case '</u>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.2 b */
|
|
|
|
|
case '<b':
|
|
|
|
|
if(!y.val) break;
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '<b/>': font.b = 1; break;
|
|
|
|
|
case '</b>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.26 i */
|
|
|
|
|
case '<i':
|
|
|
|
|
if(!y.val) break;
|
|
|
|
|
/* falls through */
|
|
|
|
|
case '<i/>': font.i = 1; break;
|
|
|
|
|
case '</i>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.3.1.15 color CT_Color TODO: tint, theme, auto, indexed */
|
|
|
|
|
case '<color':
|
|
|
|
|
if(y.rgb) font.color = y.rgb.substr(2,6);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.18 family ST_FontFamily */
|
|
|
|
|
case '<family': font.family = y.val; break;
|
|
|
|
|
|
|
|
|
|
/* 18.4.14 vertAlign CT_VerticalAlignFontProperty TODO */
|
|
|
|
|
case '<vertAlign': break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.35 scheme CT_FontScheme TODO */
|
|
|
|
|
case '<scheme': break;
|
|
|
|
|
|
|
|
|
|
default:
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(y[0].charCodeAt(1) !== 47) throw 'Unrecognized rich format ' + y[0];
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* TODO: These should be generated styles, not inline */
|
|
|
|
|
var style = [];
|
|
|
|
|
if(font.b) style.push("font-weight: bold;");
|
|
|
|
|
if(font.i) style.push("font-style: italic;");
|
|
|
|
|
intro.push('<span style="' + style.join("") + '">');
|
|
|
|
|
outro.push("</span>");
|
|
|
|
|
return cp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* 18.4.4 r CT_RElt */
|
|
|
|
|
function parse_r(r) {
|
|
|
|
|
var terms = [[],"",[]];
|
|
|
|
|
/* 18.4.12 t ST_Xstring */
|
|
|
|
|
var t = r.match(tregex), cp = 65001;
|
|
|
|
|
if(!isval(t)) return "";
|
|
|
|
|
terms[1] = t[1];
|
|
|
|
|
|
|
|
|
|
var rpr = r.match(rpregex);
|
|
|
|
|
if(isval(rpr)) cp = parse_rpr(rpr[1], terms[0], terms[2]);
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return terms[0].join("") + terms[1].replace(nlregex,'<br/>') + terms[2].join("");
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return function parse_rs(rs) {
|
|
|
|
|
return rs.replace(rregex,"").split(rend).map(parse_r).join("");
|
2014-05-16 00:33:34 +00:00
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
/* 18.4.8 si CT_Rst */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var sitregex = /<t[^>]*>([^<]*)<\/t>/g, sirregex = /<r>/;
|
|
|
|
|
function parse_si(x, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var html = opts ? opts.cellHTML : true;
|
|
|
|
|
var z = {};
|
|
|
|
|
if(!x) return null;
|
|
|
|
|
var y;
|
|
|
|
|
/* 18.4.12 t ST_Xstring (Plaintext String) */
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(x.charCodeAt(1) === 116) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
z.t = utf8read(unescapexml(x.substr(x.indexOf(">")+1).split(/<\/t>/)[0]));
|
|
|
|
|
z.r = x;
|
|
|
|
|
if(html) z.h = z.t;
|
|
|
|
|
}
|
|
|
|
|
/* 18.4.4 r CT_RElt (Rich Text Run) */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
else if((y = x.match(sirregex))) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
z.r = x;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
z.t = utf8read(unescapexml(x.match(sitregex).join("").replace(tagregex,"")));
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(html) z.h = parse_rs(x);
|
|
|
|
|
}
|
|
|
|
|
/* 18.4.3 phoneticPr CT_PhoneticPr (TODO: needed for Asian support) */
|
|
|
|
|
/* 18.4.6 rPh CT_PhoneticRun (TODO: needed for Asian support) */
|
|
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
/* 18.4 Shared String Table */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var sstr0 = /<sst([^>]*)>([\s\S]*)<\/sst>/;
|
|
|
|
|
var sstr1 = /<(?:si|sstItem)>/g;
|
|
|
|
|
var sstr2 = /<\/(?:si|sstItem)>/;
|
|
|
|
|
function parse_sst_xml(data, opts) {
|
|
|
|
|
var s = [], ss;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* 18.4.9 sst CT_Sst */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var sst = data.match(sstr0);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(isval(sst)) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
ss = sst[2].replace(sstr1,"").split(sstr2);
|
|
|
|
|
for(var i = 0; i != ss.length; ++i) {
|
|
|
|
|
var o = parse_si(ss[i], opts);
|
|
|
|
|
if(o != null) s[s.length] = o;
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
sst = parsexmltag(sst[1]); s.Count = sst.count; s.Unique = sst.uniqueCount;
|
|
|
|
|
}
|
|
|
|
|
return s;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
RELS.SST = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var straywsregex = /^\s|\s$|[\t\n\r]/;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_sst_xml(sst, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(!opts.bookSST) return "";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var o = [XML_HEADER];
|
|
|
|
|
o[o.length] = (writextag('sst', null, {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
xmlns: XMLNS.main[0],
|
|
|
|
|
count: sst.Count,
|
|
|
|
|
uniqueCount: sst.Unique
|
|
|
|
|
}));
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(var i = 0; i != sst.length; ++i) { if(sst[i] == null) continue;
|
|
|
|
|
var s = sst[i];
|
2014-05-22 12:16:51 +00:00
|
|
|
|
var sitag = "<si>";
|
|
|
|
|
if(s.r) sitag += s.r;
|
|
|
|
|
else {
|
|
|
|
|
sitag += "<t";
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(s.t.match(straywsregex)) sitag += ' xml:space="preserve"';
|
2014-06-29 18:29:45 +00:00
|
|
|
|
sitag += ">" + escapexml(s.t) + "</t>";
|
2014-05-22 12:16:51 +00:00
|
|
|
|
}
|
|
|
|
|
sitag += "</si>";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (sitag);
|
|
|
|
|
}
|
|
|
|
|
if(o.length>2){ o[o.length] = ('</sst>'); o[1]=o[1].replace("/>",">"); }
|
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
|
|
|
|
/* [MS-XLSB] 2.4.219 BrtBeginSst */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtBeginSst(data, length) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return [data.read_shift(4), data.read_shift(4)];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.45 Shared Strings */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_sst_bin(data, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var s = [];
|
|
|
|
|
var pass = false;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
recordhopper(data, function hopper_sst(val, R, RT) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
switch(R.n) {
|
|
|
|
|
case 'BrtBeginSst': s.Count = val[0]; s.Unique = val[1]; break;
|
|
|
|
|
case 'BrtSSTItem': s.push(val); break;
|
|
|
|
|
case 'BrtEndSst': return true;
|
|
|
|
|
/* TODO: produce a test case with a future record */
|
|
|
|
|
case 'BrtFRTBegin': pass = true; break;
|
|
|
|
|
case 'BrtFRTEnd': pass = false; break;
|
|
|
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R.n);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return s;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
function write_BrtBeginSst(sst, o) {
|
|
|
|
|
if(!o) o = new_buf(8);
|
|
|
|
|
o.write_shift(4, sst.Count);
|
|
|
|
|
o.write_shift(4, sst.Unique);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var write_BrtSSTItem = write_RichStr;
|
|
|
|
|
|
|
|
|
|
function write_sst_bin(sst, opts) {
|
|
|
|
|
var ba = buf_array();
|
|
|
|
|
write_record(ba, "BrtBeginSst", write_BrtBeginSst(sst));
|
|
|
|
|
for(var i = 0; i < sst.length; ++i) write_record(ba, "BrtSSTItem", write_BrtSSTItem(sst[i]));
|
|
|
|
|
write_record(ba, "BrtEndSst");
|
|
|
|
|
return ba.end();
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function hex2RGB(h) {
|
|
|
|
|
var o = h.substr(h[0]==="#"?1:0,6);
|
|
|
|
|
return [parseInt(o.substr(0,2),16),parseInt(o.substr(0,2),16),parseInt(o.substr(0,2),16)];
|
|
|
|
|
}
|
|
|
|
|
function rgb2Hex(rgb) {
|
2014-06-02 05:19:07 +00:00
|
|
|
|
for(var i=0,o=1; i!=3; ++i) o = o*256 + (rgb[i]>255?255:rgb[i]<0?0:rgb[i]);
|
|
|
|
|
return o.toString(16).toUpperCase().substr(1);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function rgb2HSL(rgb) {
|
2014-06-02 05:19:07 +00:00
|
|
|
|
var R = rgb[0]/255, G = rgb[1]/255, B=rgb[2]/255;
|
|
|
|
|
var M = Math.max(R, G, B), m = Math.min(R, G, B), C = M - m;
|
|
|
|
|
if(C === 0) return [0, 0, R];
|
|
|
|
|
|
|
|
|
|
var H6 = 0, S = 0, L2 = (M + m);
|
|
|
|
|
S = C / (L2 > 1 ? 2 - L2 : L2);
|
|
|
|
|
switch(M){
|
|
|
|
|
case R: H6 = ((G - B) / C + 6)%6; break;
|
|
|
|
|
case G: H6 = ((B - R) / C + 2); break;
|
|
|
|
|
case B: H6 = ((R - G) / C + 4); break;
|
|
|
|
|
}
|
|
|
|
|
return [H6 / 6, S, L2 / 2];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function hsl2RGB(hsl){
|
2014-06-02 05:19:07 +00:00
|
|
|
|
var H = hsl[0], S = hsl[1], L = hsl[2];
|
|
|
|
|
var C = S * 2 * (L < 0.5 ? L : 1 - L), m = L - C/2;
|
|
|
|
|
var rgb = [m,m,m], h6 = 6*H;
|
|
|
|
|
|
|
|
|
|
var X;
|
|
|
|
|
if(S !== 0) switch(h6|0) {
|
|
|
|
|
case 0: case 6: X = C * h6; rgb[0] += C; rgb[1] += X; break;
|
|
|
|
|
case 1: X = C * (2 - h6); rgb[0] += X; rgb[1] += C; break;
|
|
|
|
|
case 2: X = C * (h6 - 2); rgb[1] += C; rgb[2] += X; break;
|
|
|
|
|
case 3: X = C * (4 - h6); rgb[1] += X; rgb[2] += C; break;
|
|
|
|
|
case 4: X = C * (h6 - 4); rgb[2] += C; rgb[0] += X; break;
|
|
|
|
|
case 5: X = C * (6 - h6); rgb[2] += X; rgb[0] += C; break;
|
|
|
|
|
}
|
|
|
|
|
for(var i = 0; i != 3; ++i) rgb[i] = Math.round(rgb[i]*255);
|
|
|
|
|
return rgb;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
|
|
|
|
|
|
/* 18.8.3 bgColor tint algorithm */
|
|
|
|
|
function rgb_tint(hex, tint) {
|
|
|
|
|
if(tint === 0) return hex;
|
|
|
|
|
var hsl = rgb2HSL(hex2RGB(hex));
|
|
|
|
|
if (tint < 0) hsl[2] = hsl[2] * (1 + tint);
|
|
|
|
|
else hsl[2] = 1 - (1 - hsl[2]) * (1 - tint);
|
|
|
|
|
return rgb2Hex(hsl2RGB(hsl));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 18.3.1.13 width calculations */
|
|
|
|
|
var DEF_MDW = 7, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
|
|
|
|
|
function width2px(width) { return (( width + ((128/MDW)|0)/256 )* MDW )|0; }
|
|
|
|
|
function px2char(px) { return (((px - 5)/MDW * 100 + 0.5)|0)/100; }
|
|
|
|
|
function char2width(chr) { return (((chr * MDW + 5)/MDW*256)|0)/256; }
|
|
|
|
|
function cycle_width(collw) { return char2width(px2char(width2px(collw))); }
|
|
|
|
|
function find_mdw(collw, coll) {
|
|
|
|
|
if(cycle_width(collw) != collw) {
|
|
|
|
|
for(MDW=DEF_MDW; MDW>MIN_MDW; --MDW) if(cycle_width(collw) === collw) break;
|
|
|
|
|
if(MDW === MIN_MDW) for(MDW=DEF_MDW+1; MDW<MAX_MDW; ++MDW) if(cycle_width(collw) === collw) break;
|
|
|
|
|
if(MDW === MAX_MDW) MDW = DEF_MDW;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var styles = {}; // shared styles
|
|
|
|
|
|
2014-05-29 06:18:23 +00:00
|
|
|
|
var themes = {}; // shared themes
|
|
|
|
|
|
|
|
|
|
/* 18.8.21 fills CT_Fills */
|
|
|
|
|
function parse_fills(t, opts) {
|
|
|
|
|
styles.Fills = [];
|
|
|
|
|
var fill = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
t[0].match(tagregex).forEach(function(x) {
|
2014-05-29 06:18:23 +00:00
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
|
switch(y[0]) {
|
|
|
|
|
case '<fills': case '<fills>': case '</fills>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.20 fill CT_Fill */
|
|
|
|
|
case '<fill>': break;
|
|
|
|
|
case '</fill>': styles.Fills.push(fill); fill = {}; break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.32 patternFill CT_PatternFill */
|
|
|
|
|
case '<patternFill':
|
|
|
|
|
if(y.patternType) fill.patternType = y.patternType;
|
|
|
|
|
break;
|
2014-05-29 22:30:03 +00:00
|
|
|
|
case '<patternFill/>': case '</patternFill>': break;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
/* 18.8.3 bgColor CT_Color */
|
|
|
|
|
case '<bgColor':
|
|
|
|
|
if(!fill.bgColor) fill.bgColor = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(y.indexed) fill.bgColor.indexed = parseInt(y.indexed, 10);
|
|
|
|
|
if(y.theme) fill.bgColor.theme = parseInt(y.theme, 10);
|
|
|
|
|
if(y.tint) fill.bgColor.tint = parseFloat(y.tint);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* Excel uses ARGB strings */
|
2014-05-29 06:18:23 +00:00
|
|
|
|
if(y.rgb) fill.bgColor.rgb = y.rgb.substring(y.rgb.length - 6);
|
|
|
|
|
break;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
case '<bgColor/>': case '</bgColor>': break;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
/* 18.8.19 fgColor CT_Color */
|
|
|
|
|
case '<fgColor':
|
|
|
|
|
if(!fill.fgColor) fill.fgColor = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(y.theme) fill.fgColor.theme = parseInt(y.theme, 10);
|
|
|
|
|
if(y.tint) fill.fgColor.tint = parseFloat(y.tint);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* Excel uses ARGB strings */
|
2014-05-29 06:18:23 +00:00
|
|
|
|
if(y.rgb) fill.fgColor.rgb = y.rgb.substring(y.rgb.length - 6);
|
|
|
|
|
break;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
case '<bgColor/>': case '</fgColor>': break;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in fills';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* 18.8.31 numFmts CT_NumFmts */
|
|
|
|
|
function parse_numFmts(t, opts) {
|
|
|
|
|
styles.NumberFmt = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var k = keys(SSF._table);
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(var i=0; i < k.length; ++i) styles.NumberFmt[k[i]] = SSF._table[k[i]];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var m = t[0].match(tagregex);
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(i=0; i < m.length; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var y = parsexmltag(m[i]);
|
2012-12-04 19:27:20 +00:00
|
|
|
|
switch(y[0]) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
case '<numFmts': case '</numFmts>': case '<numFmts/>': case '<numFmts>': break;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
case '<numFmt': {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var f=unescapexml(utf8read(y.formatCode)), j=parseInt(y.numFmtId,10);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
styles.NumberFmt[j] = f; if(j>0) SSF.load(f,j);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
} break;
|
|
|
|
|
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in numFmts';
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_numFmts(NF, opts) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var o = ["<numFmts>"];
|
2014-05-16 00:33:34 +00:00
|
|
|
|
[[5,8],[23,26],[41,44],[63,66],[164,392]].forEach(function(r) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(var i = r[0]; i <= r[1]; ++i) if(NF[i] !== undefined) o[o.length] = (writextag('numFmt',null,{numFmtId:i,formatCode:escapexml(NF[i])}));
|
2014-05-16 00:33:34 +00:00
|
|
|
|
});
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(o.length === 1) return "";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = ("</numFmts>");
|
2014-05-16 00:33:34 +00:00
|
|
|
|
o[0] = writextag('numFmts', null, { count:o.length-2 }).replace("/>", ">");
|
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 18.8.10 cellXfs CT_CellXfs */
|
|
|
|
|
function parse_cellXfs(t, opts) {
|
|
|
|
|
styles.CellXf = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
t[0].match(tagregex).forEach(function(x) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
|
switch(y[0]) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
case '<cellXfs': case '<cellXfs>': case '<cellXfs/>': case '</cellXfs>': break;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
/* 18.8.45 xf CT_Xf */
|
|
|
|
|
case '<xf': delete y[0];
|
|
|
|
|
if(y.numFmtId) y.numFmtId = parseInt(y.numFmtId, 10);
|
2014-05-29 06:18:23 +00:00
|
|
|
|
if(y.fillId) y.fillId = parseInt(y.fillId, 10);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
styles.CellXf.push(y); break;
|
|
|
|
|
case '</xf>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.1 alignment CT_CellAlignment */
|
|
|
|
|
case '<alignment': case '<alignment/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.8.33 protection CT_CellProtection */
|
|
|
|
|
case '<protection': case '</protection>': case '<protection/>': break;
|
|
|
|
|
|
|
|
|
|
case '<extLst': case '</extLst>': break;
|
|
|
|
|
case '<ext': break;
|
|
|
|
|
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in cellXfs';
|
2012-12-04 19:27:20 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function write_cellXfs(cellXfs) {
|
|
|
|
|
var o = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (writextag('cellXfs',null));
|
|
|
|
|
cellXfs.forEach(function(c) { o[o.length] = (writextag('xf', null, c)); });
|
|
|
|
|
o[o.length] = ("</cellXfs>");
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(o.length === 2) return "";
|
|
|
|
|
o[0] = writextag('cellXfs',null, {count:o.length-2}).replace("/>",">");
|
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
2012-12-04 19:27:20 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* 18.8 Styles CT_Stylesheet*/
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var parse_sty_xml= (function make_pstyx() {
|
|
|
|
|
var numFmtRegex = /<numFmts([^>]*)>.*<\/numFmts>/;
|
|
|
|
|
var cellXfRegex = /<cellXfs([^>]*)>.*<\/cellXfs>/;
|
|
|
|
|
var fillsRegex = /<fills([^>]*)>.*<\/fills>/;
|
|
|
|
|
|
|
|
|
|
return function parse_sty_xml(data, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* 18.8.39 styleSheet CT_Stylesheet */
|
|
|
|
|
var t;
|
2013-03-26 23:54:14 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* numFmts CT_NumFmts ? */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if((t=data.match(numFmtRegex))) parse_numFmts(t, opts);
|
2014-01-15 07:26:00 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* fonts CT_Fonts ? */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
// if((t=data.match(/<fonts([^>]*)>.*<\/fonts>/))) parse_fonts(t, opts);
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
/* fills CT_Fills */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if((t=data.match(fillsRegex))) parse_fills(t, opts);
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
/* borders CT_Borders ? */
|
|
|
|
|
/* cellStyleXfs CT_CellStyleXfs ? */
|
|
|
|
|
|
|
|
|
|
/* cellXfs CT_CellXfs ? */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if((t=data.match(cellXfRegex))) parse_cellXfs(t, opts);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
/* dxfs CT_Dxfs ? */
|
|
|
|
|
/* tableStyles CT_TableStyles ? */
|
|
|
|
|
/* colors CT_Colors ? */
|
|
|
|
|
/* extLst CT_ExtensionList ? */
|
|
|
|
|
|
|
|
|
|
return styles;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
};
|
|
|
|
|
})();
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
var STYLES_XML_ROOT = writextag('styleSheet', null, {
|
|
|
|
|
'xmlns': XMLNS.main[0],
|
|
|
|
|
'xmlns:vt': XMLNS.vt
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
RELS.STY = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
|
|
|
|
|
|
|
|
|
|
function write_sty_xml(wb, opts) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var o = [XML_HEADER, STYLES_XML_ROOT], w;
|
|
|
|
|
if((w = write_numFmts(wb.SSF)) != null) o[o.length] = w;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = ('<fonts count="1"><font><sz val="12"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts>');
|
|
|
|
|
o[o.length] = ('<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>');
|
|
|
|
|
o[o.length] = ('<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>');
|
|
|
|
|
o[o.length] = ('<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>');
|
|
|
|
|
if((w = write_cellXfs(opts.cellXfs))) o[o.length] = (w);
|
|
|
|
|
o[o.length] = ('<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>');
|
|
|
|
|
o[o.length] = ('<dxfs count="0"/>');
|
|
|
|
|
o[o.length] = ('<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>');
|
|
|
|
|
|
|
|
|
|
if(o.length>2){ o[o.length] = ('</styleSheet>'); o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
|
|
|
|
}
|
|
|
|
|
/* [MS-XLSB] 2.4.651 BrtFmt */
|
|
|
|
|
function parse_BrtFmt(data, length) {
|
|
|
|
|
var ifmt = data.read_shift(2);
|
|
|
|
|
var stFmtCode = parse_XLWideString(data,length-2);
|
|
|
|
|
return [ifmt, stFmtCode];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.653 BrtFont TODO */
|
|
|
|
|
function parse_BrtFont(data, length) {
|
|
|
|
|
var out = {flags:{}};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out.dyHeight = data.read_shift(2);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
out.grbit = parse_FontFlags(data, 2);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out.bls = data.read_shift(2);
|
|
|
|
|
out.sss = data.read_shift(2);
|
|
|
|
|
out.uls = data.read_shift(1);
|
|
|
|
|
out.bFamily = data.read_shift(1);
|
|
|
|
|
out.bCharSet = data.read_shift(1);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
data.l++;
|
|
|
|
|
out.brtColor = parse_BrtColor(data, 8);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out.bFontScheme = data.read_shift(1);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
out.name = parse_XLWideString(data, length - 21);
|
|
|
|
|
|
|
|
|
|
out.flags.Bold = out.bls === 0x02BC;
|
|
|
|
|
out.flags.Italic = out.grbit.fItalic;
|
|
|
|
|
out.flags.Strikeout = out.grbit.fStrikeout;
|
|
|
|
|
out.flags.Outline = out.grbit.fOutline;
|
|
|
|
|
out.flags.Shadow = out.grbit.fShadow;
|
|
|
|
|
out.flags.Condense = out.grbit.fCondense;
|
|
|
|
|
out.flags.Extend = out.grbit.fExtend;
|
|
|
|
|
out.flags.Sub = out.sss & 0x2;
|
|
|
|
|
out.flags.Sup = out.sss & 0x1;
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.816 BrtXF */
|
|
|
|
|
function parse_BrtXF(data, length) {
|
|
|
|
|
var ixfeParent = data.read_shift(2);
|
|
|
|
|
var ifmt = data.read_shift(2);
|
|
|
|
|
parsenoop(data, length-4);
|
|
|
|
|
return {ixfe:ixfeParent, ifmt:ifmt };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.50 Styles */
|
|
|
|
|
function parse_sty_bin(data, opts) {
|
|
|
|
|
styles.NumberFmt = [];
|
|
|
|
|
for(var y in SSF._table) styles.NumberFmt[y] = SSF._table[y];
|
|
|
|
|
|
|
|
|
|
styles.CellXf = [];
|
|
|
|
|
var state = ""; /* TODO: this should be a stack */
|
|
|
|
|
var pass = false;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
recordhopper(data, function hopper_sty(val, R, RT) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
switch(R.n) {
|
|
|
|
|
case 'BrtFmt':
|
|
|
|
|
styles.NumberFmt[val[0]] = val[1]; SSF.load(val[1], val[0]);
|
|
|
|
|
break;
|
|
|
|
|
case 'BrtFont': break; /* TODO */
|
|
|
|
|
case 'BrtKnownFonts': break; /* TODO */
|
|
|
|
|
case 'BrtFill': break; /* TODO */
|
|
|
|
|
case 'BrtBorder': break; /* TODO */
|
|
|
|
|
case 'BrtXF':
|
|
|
|
|
if(state === "CELLXFS") {
|
|
|
|
|
styles.CellXf.push(val);
|
|
|
|
|
}
|
|
|
|
|
break; /* TODO */
|
|
|
|
|
case 'BrtStyle': break; /* TODO */
|
|
|
|
|
case 'BrtDXF': break; /* TODO */
|
|
|
|
|
case 'BrtMRUColor': break; /* TODO */
|
|
|
|
|
case 'BrtIndexedColor': break; /* TODO */
|
|
|
|
|
case 'BrtBeginStyleSheet': break;
|
|
|
|
|
case 'BrtEndStyleSheet': break;
|
|
|
|
|
case 'BrtBeginTableStyle': break;
|
|
|
|
|
case 'BrtTableStyleElement': break;
|
|
|
|
|
case 'BrtEndTableStyle': break;
|
|
|
|
|
case 'BrtBeginFmts': state = "FMTS"; break;
|
|
|
|
|
case 'BrtEndFmts': state = ""; break;
|
|
|
|
|
case 'BrtBeginFonts': state = "FONTS"; break;
|
|
|
|
|
case 'BrtEndFonts': state = ""; break;
|
|
|
|
|
case 'BrtACBegin': state = "ACFONTS"; break;
|
|
|
|
|
case 'BrtACEnd': state = ""; break;
|
|
|
|
|
case 'BrtBeginFills': state = "FILLS"; break;
|
|
|
|
|
case 'BrtEndFills': state = ""; break;
|
|
|
|
|
case 'BrtBeginBorders': state = "BORDERS"; break;
|
|
|
|
|
case 'BrtEndBorders': state = ""; break;
|
|
|
|
|
case 'BrtBeginCellStyleXFs': state = "CELLSTYLEXFS"; break;
|
|
|
|
|
case 'BrtEndCellStyleXFs': state = ""; break;
|
|
|
|
|
case 'BrtBeginCellXFs': state = "CELLXFS"; break;
|
|
|
|
|
case 'BrtEndCellXFs': state = ""; break;
|
|
|
|
|
case 'BrtBeginStyles': state = "STYLES"; break;
|
|
|
|
|
case 'BrtEndStyles': state = ""; break;
|
|
|
|
|
case 'BrtBeginDXFs': state = "DXFS"; break;
|
|
|
|
|
case 'BrtEndDXFs': state = ""; break;
|
|
|
|
|
case 'BrtBeginTableStyles': state = "TABLESTYLES"; break;
|
|
|
|
|
case 'BrtEndTableStyles': state = ""; break;
|
|
|
|
|
case 'BrtBeginColorPalette': state = "COLORPALETTE"; break;
|
|
|
|
|
case 'BrtEndColorPalette': state = ""; break;
|
|
|
|
|
case 'BrtBeginIndexedColors': state = "INDEXEDCOLORS"; break;
|
|
|
|
|
case 'BrtEndIndexedColors': state = ""; break;
|
|
|
|
|
case 'BrtBeginMRUColors': state = "MRUCOLORS"; break;
|
|
|
|
|
case 'BrtEndMRUColors': state = ""; break;
|
|
|
|
|
case 'BrtFRTBegin': pass = true; break;
|
|
|
|
|
case 'BrtFRTEnd': pass = false; break;
|
|
|
|
|
case 'BrtBeginStyleSheetExt14': break;
|
|
|
|
|
case 'BrtBeginSlicerStyles': break;
|
|
|
|
|
case 'BrtEndSlicerStyles': break;
|
|
|
|
|
case 'BrtBeginTimelineStylesheetExt15': break;
|
|
|
|
|
case 'BrtEndTimelineStylesheetExt15': break;
|
|
|
|
|
case 'BrtBeginTimelineStyles': break;
|
|
|
|
|
case 'BrtEndTimelineStyles': break;
|
|
|
|
|
case 'BrtEndStyleSheetExt14': break;
|
|
|
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R.n);
|
2014-01-15 07:26:00 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return styles;
|
2014-01-15 07:26:00 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
/* [MS-XLSB] 2.1.7.50 Styles */
|
|
|
|
|
function write_sty_bin(data, opts) {
|
|
|
|
|
var ba = buf_array();
|
|
|
|
|
write_record(ba, "BrtBeginStyleSheet");
|
|
|
|
|
/* [FMTS] */
|
|
|
|
|
/* [FONTS] */
|
|
|
|
|
/* [FILLS] */
|
|
|
|
|
/* [BORDERS] */
|
|
|
|
|
/* CELLSTYLEXFS */
|
|
|
|
|
/* CELLXFS*/
|
|
|
|
|
/* STYLES */
|
|
|
|
|
/* DXFS */
|
|
|
|
|
/* TABLESTYLES */
|
|
|
|
|
/* [COLORPALETTE] */
|
|
|
|
|
/* FRTSTYLESHEET*/
|
|
|
|
|
write_record(ba, "BrtEndStyleSheet");
|
|
|
|
|
return ba.end();
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
RELS.THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
2014-01-15 07:26:00 +00:00
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
|
/* 20.1.6.2 clrScheme CT_ColorScheme */
|
2014-05-29 06:18:23 +00:00
|
|
|
|
function parse_clrScheme(t, opts) {
|
|
|
|
|
themes.themeElements.clrScheme = [];
|
|
|
|
|
var color = {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
t[0].match(tagregex).forEach(function(x) {
|
2014-05-29 06:18:23 +00:00
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
|
switch(y[0]) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
case '<a:clrScheme': case '</a:clrScheme>': break;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
/* 20.1.2.3.32 srgbClr CT_SRgbColor */
|
|
|
|
|
case '<a:srgbClr': color.rgb = y.val; break;
|
|
|
|
|
|
|
|
|
|
/* 20.1.2.3.33 sysClr CT_SystemColor */
|
|
|
|
|
case '<a:sysClr': color.rgb = y.lastClr; break;
|
|
|
|
|
|
|
|
|
|
/* 20.1.4.1.9 dk1 (Dark 1) */
|
|
|
|
|
case '<a:dk1>':
|
|
|
|
|
case '</a:dk1>':
|
|
|
|
|
/* 20.1.4.1.10 dk2 (Dark 2) */
|
|
|
|
|
case '<a:dk2>':
|
|
|
|
|
case '</a:dk2>':
|
|
|
|
|
/* 20.1.4.1.22 lt1 (Light 1) */
|
|
|
|
|
case '<a:lt1>':
|
|
|
|
|
case '</a:lt1>':
|
|
|
|
|
/* 20.1.4.1.23 lt2 (Light 2) */
|
|
|
|
|
case '<a:lt2>':
|
|
|
|
|
case '</a:lt2>':
|
|
|
|
|
/* 20.1.4.1.1 accent1 (Accent 1) */
|
|
|
|
|
case '<a:accent1>':
|
|
|
|
|
case '</a:accent1>':
|
|
|
|
|
/* 20.1.4.1.2 accent2 (Accent 2) */
|
|
|
|
|
case '<a:accent2>':
|
|
|
|
|
case '</a:accent2>':
|
|
|
|
|
/* 20.1.4.1.3 accent3 (Accent 3) */
|
|
|
|
|
case '<a:accent3>':
|
|
|
|
|
case '</a:accent3>':
|
|
|
|
|
/* 20.1.4.1.4 accent4 (Accent 4) */
|
|
|
|
|
case '<a:accent4>':
|
|
|
|
|
case '</a:accent4>':
|
|
|
|
|
/* 20.1.4.1.5 accent5 (Accent 5) */
|
|
|
|
|
case '<a:accent5>':
|
|
|
|
|
case '</a:accent5>':
|
|
|
|
|
/* 20.1.4.1.6 accent6 (Accent 6) */
|
|
|
|
|
case '<a:accent6>':
|
|
|
|
|
case '</a:accent6>':
|
|
|
|
|
/* 20.1.4.1.19 hlink (Hyperlink) */
|
|
|
|
|
case '<a:hlink>':
|
|
|
|
|
case '</a:hlink>':
|
|
|
|
|
/* 20.1.4.1.15 folHlink (Followed Hyperlink) */
|
|
|
|
|
case '<a:folHlink>':
|
|
|
|
|
case '</a:folHlink>':
|
|
|
|
|
if (y[0][1] === '/') {
|
|
|
|
|
themes.themeElements.clrScheme.push(color);
|
|
|
|
|
color = {};
|
|
|
|
|
} else {
|
|
|
|
|
color.name = y[0].substring(3, y[0].length - 1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: if(opts.WTF) throw 'unrecognized ' + y[0] + ' in clrScheme';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var clrsregex = /<a:clrScheme([^>]*)>.*<\/a:clrScheme>/;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
/* 14.2.7 Theme Part */
|
|
|
|
|
function parse_theme_xml(data, opts) {
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(!data || data.length === 0) return themes;
|
2014-05-29 06:18:23 +00:00
|
|
|
|
themes.themeElements = {};
|
|
|
|
|
|
|
|
|
|
var t;
|
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
|
/* clrScheme CT_ColorScheme */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((t=data.match(clrsregex))) parse_clrScheme(t, opts);
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
return themes;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function write_theme() { return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeC
|
2014-03-29 22:53:15 +00:00
|
|
|
|
/* 18.6 Calculation Chain */
|
|
|
|
|
function parse_cc_xml(data, opts) {
|
|
|
|
|
var d = [];
|
|
|
|
|
var l = 0, i = 1;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
(data.match(tagregex)||[]).forEach(function(x) {
|
2014-03-29 22:53:15 +00:00
|
|
|
|
var y = parsexmltag(x);
|
|
|
|
|
switch(y[0]) {
|
|
|
|
|
case '<?xml': break;
|
|
|
|
|
/* 18.6.2 calcChain CT_CalcChain 1 */
|
|
|
|
|
case '<calcChain': case '<calcChain>': case '</calcChain>': break;
|
|
|
|
|
/* 18.6.1 c CT_CalcCell 1 */
|
|
|
|
|
case '<c': delete y[0]; if(y.i) i = y.i; else y.i = i; d.push(y); break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
function write_cc_xml(data, opts) { }
|
2014-03-29 22:53:15 +00:00
|
|
|
|
/* [MS-XLSB] 2.6.4.1 */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCalcChainItem$(data, length) {
|
2014-03-29 22:53:15 +00:00
|
|
|
|
var out = {};
|
|
|
|
|
out.i = data.read_shift(4);
|
|
|
|
|
var cell = {};
|
|
|
|
|
cell.r = data.read_shift(4);
|
|
|
|
|
cell.c = data.read_shift(4);
|
|
|
|
|
out.r = encode_cell(cell);
|
|
|
|
|
var flags = data.read_shift(1);
|
|
|
|
|
if(flags & 0x2) out.l = '1';
|
|
|
|
|
if(flags & 0x8) out.a = '1';
|
|
|
|
|
return out;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-03-29 22:53:15 +00:00
|
|
|
|
|
|
|
|
|
/* 18.6 Calculation Chain */
|
|
|
|
|
function parse_cc_bin(data, opts) {
|
|
|
|
|
var out = [];
|
|
|
|
|
var pass = false;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
recordhopper(data, function hopper_cc(val, R, RT) {
|
2014-03-29 22:53:15 +00:00
|
|
|
|
switch(R.n) {
|
|
|
|
|
case 'BrtCalcChainItem$': out.push(val); break;
|
|
|
|
|
case 'BrtBeginCalcChain$': break;
|
|
|
|
|
case 'BrtEndCalcChain$': break;
|
|
|
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R.n);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return out;
|
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
|
|
|
|
function write_cc_bin(data, opts) { }
|
2014-06-02 05:19:07 +00:00
|
|
|
|
|
|
|
|
|
function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
|
|
|
|
|
for(var i = 0; i != dirComments.length; ++i) {
|
|
|
|
|
var canonicalpath=dirComments[i];
|
|
|
|
|
var comments=parse_cmnt(getzipdata(zip, canonicalpath.replace(/^\//,''), true), canonicalpath, opts);
|
|
|
|
|
if(!comments || !comments.length) continue;
|
|
|
|
|
// find the sheets targeted by these comments
|
|
|
|
|
var sheetNames = keys(sheets);
|
|
|
|
|
for(var j = 0; j != sheetNames.length; ++j) {
|
|
|
|
|
var sheetName = sheetNames[j];
|
|
|
|
|
var rels = sheetRels[sheetName];
|
|
|
|
|
if(rels) {
|
|
|
|
|
var rel = rels[canonicalpath];
|
|
|
|
|
if(rel) insertCommentsIntoSheet(sheetName, sheets[sheetName], comments);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function insertCommentsIntoSheet(sheetName, sheet, comments) {
|
|
|
|
|
comments.forEach(function(comment) {
|
|
|
|
|
var cell = sheet[comment.ref];
|
|
|
|
|
if (!cell) {
|
|
|
|
|
cell = {};
|
|
|
|
|
sheet[comment.ref] = cell;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
|
2014-06-02 05:19:07 +00:00
|
|
|
|
var thisCell = decode_cell(comment.ref);
|
|
|
|
|
if(range.s.r > thisCell.r) range.s.r = thisCell.r;
|
|
|
|
|
if(range.e.r < thisCell.r) range.e.r = thisCell.r;
|
|
|
|
|
if(range.s.c > thisCell.c) range.s.c = thisCell.c;
|
|
|
|
|
if(range.e.c < thisCell.c) range.e.c = thisCell.c;
|
|
|
|
|
var encoded = encode_range(range);
|
|
|
|
|
if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!cell.c) cell.c = [];
|
|
|
|
|
var o = {a: comment.author, t: comment.t, r: comment.r};
|
|
|
|
|
if(comment.h) o.h = comment.h;
|
|
|
|
|
cell.c.push(o);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 07:26:00 +00:00
|
|
|
|
/* 18.7.3 CT_Comment */
|
2014-02-12 06:09:42 +00:00
|
|
|
|
function parse_comments_xml(data, opts) {
|
2014-04-03 22:51:54 +00:00
|
|
|
|
if(data.match(/<(?:\w+:)?comments *\/>/)) return [];
|
2014-01-15 07:26:00 +00:00
|
|
|
|
var authors = [];
|
|
|
|
|
var commentList = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
data.match(/<(?:\w+:)?authors>([^\u2603]*)<\/(?:\w+:)?authors>/)[1].split(/<\/\w*:?author>/).forEach(function(x) {
|
2014-01-15 07:26:00 +00:00
|
|
|
|
if(x === "" || x.trim() === "") return;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
authors.push(x.match(/<(?:\w+:)?author[^>]*>(.*)/)[1]);
|
2014-01-15 07:26:00 +00:00
|
|
|
|
});
|
2014-06-29 18:29:45 +00:00
|
|
|
|
(data.match(/<(?:\w+:)?commentList>([^\u2603]*)<\/(?:\w+:)?commentList>/)||["",""])[1].split(/<\/\w*:?comment>/).forEach(function(x, index) {
|
2014-01-15 07:26:00 +00:00
|
|
|
|
if(x === "" || x.trim() === "") return;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
var y = parsexmltag(x.match(/<(?:\w+:)?comment[^>]*>/)[0]);
|
2014-01-18 13:45:49 +00:00
|
|
|
|
var comment = { author: y.authorId && authors[y.authorId] ? authors[y.authorId] : undefined, ref: y.ref, guid: y.guid };
|
2014-02-19 03:03:28 +00:00
|
|
|
|
var cell = decode_cell(y.ref);
|
|
|
|
|
if(opts.sheetRows && opts.sheetRows <= cell.r) return;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var textMatch = x.match(/<text>([^\u2603]*)<\/text>/);
|
2014-01-18 08:29:51 +00:00
|
|
|
|
if (!textMatch || !textMatch[1]) return; // a comment may contain an empty text tag.
|
2014-01-22 04:58:26 +00:00
|
|
|
|
var rt = parse_si(textMatch[1]);
|
2014-01-18 13:45:49 +00:00
|
|
|
|
comment.r = rt.r;
|
2014-02-05 13:39:21 +00:00
|
|
|
|
comment.t = rt.t;
|
2014-02-12 06:09:42 +00:00
|
|
|
|
if(opts.cellHTML) comment.h = rt.h;
|
2014-01-15 07:26:00 +00:00
|
|
|
|
commentList.push(comment);
|
|
|
|
|
});
|
|
|
|
|
return commentList;
|
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
|
|
|
|
function write_comments_xml(data, opts) { }
|
2014-03-29 02:05:50 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.28 BrtBeginComment */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtBeginComment(data, length) {
|
2014-03-29 02:05:50 +00:00
|
|
|
|
var out = {};
|
|
|
|
|
out.iauthor = data.read_shift(4);
|
|
|
|
|
var rfx = parse_UncheckedRfX(data, 16);
|
|
|
|
|
out.rfx = rfx.s;
|
|
|
|
|
out.ref = encode_cell(rfx.s);
|
|
|
|
|
data.l += 16; /*var guid = parse_GUID(data); */
|
|
|
|
|
return out;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-03-29 02:05:50 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.324 BrtCommentAuthor */
|
|
|
|
|
var parse_BrtCommentAuthor = parse_XLWideString;
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.325 BrtCommentText */
|
|
|
|
|
var parse_BrtCommentText = parse_RichStr;
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.8 Comments */
|
|
|
|
|
function parse_comments_bin(data, opts) {
|
|
|
|
|
var out = [];
|
|
|
|
|
var authors = [];
|
|
|
|
|
var c = {};
|
|
|
|
|
var pass = false;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
recordhopper(data, function hopper_cmnt(val, R, RT) {
|
2014-03-29 02:05:50 +00:00
|
|
|
|
switch(R.n) {
|
|
|
|
|
case 'BrtCommentAuthor': authors.push(val); break;
|
|
|
|
|
case 'BrtBeginComment': c = val; break;
|
|
|
|
|
case 'BrtCommentText': c.t = val.t; c.h = val.h; c.r = val.r; break;
|
|
|
|
|
case 'BrtEndComment':
|
|
|
|
|
c.author = authors[c.iauthor];
|
|
|
|
|
delete c.iauthor;
|
|
|
|
|
if(opts.sheetRows && opts.sheetRows <= c.rfx.r) break;
|
|
|
|
|
delete c.rfx; out.push(c); break;
|
|
|
|
|
case 'BrtBeginComments': break;
|
|
|
|
|
case 'BrtEndComments': break;
|
|
|
|
|
case 'BrtBeginCommentAuthors': break;
|
|
|
|
|
case 'BrtEndCommentAuthors': break;
|
|
|
|
|
case 'BrtBeginCommentList': break;
|
|
|
|
|
case 'BrtEndCommentList': break;
|
|
|
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R.n);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return out;
|
|
|
|
|
}
|
2014-01-15 07:26:00 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
function write_comments_bin(data, opts) { }
|
2014-02-13 06:22:42 +00:00
|
|
|
|
/* [MS-XLSB] 2.5.97.4 CellParsedFormula TODO: use similar logic to js-xls */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_CellParsedFormula(data, length) {
|
2014-02-13 06:22:42 +00:00
|
|
|
|
var cce = data.read_shift(4);
|
|
|
|
|
return parsenoop(data, length-4);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var strs = {}; // shared strings
|
|
|
|
|
var _ssfopts = {}; // spreadsheet formatting options
|
2013-11-12 16:29:53 +00:00
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
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-05-16 00:33:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_cell_style(styles, cell, opts) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var z = opts.revssf[cell.z != null ? cell.z : "General"];
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(var i = 0, len = styles.length; i != len; ++i) if(styles[i].numFmtId === z) return i;
|
|
|
|
|
styles[len] = {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
numFmtId:z,
|
|
|
|
|
fontId:0,
|
|
|
|
|
fillId:0,
|
|
|
|
|
borderId:0,
|
|
|
|
|
xfId:0,
|
|
|
|
|
applyNumberFormat:1
|
|
|
|
|
};
|
2014-07-28 13:22:32 +00:00
|
|
|
|
return len;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
2014-06-02 05:19:07 +00:00
|
|
|
|
|
|
|
|
|
function safe_format(p, fmtid, fillid, opts) {
|
|
|
|
|
try {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(fmtid === 0) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
else if(p.v === undefined) return "";
|
|
|
|
|
else p.w = SSF._general(p.v,_ssfopts);
|
|
|
|
|
}
|
|
|
|
|
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; }
|
|
|
|
|
if(fillid) try {
|
|
|
|
|
p.s = styles.Fills[fillid];
|
|
|
|
|
if (p.s.fgColor && p.s.fgColor.theme) {
|
|
|
|
|
p.s.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p.s.fgColor.theme].rgb, p.s.fgColor.tint || 0);
|
|
|
|
|
if(opts.WTF) p.s.fgColor.raw_rgb = themes.themeElements.clrScheme[p.s.fgColor.theme].rgb;
|
|
|
|
|
}
|
|
|
|
|
if (p.s.bgColor && p.s.bgColor.theme) {
|
|
|
|
|
p.s.bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[p.s.bgColor.theme].rgb, p.s.bgColor.tint || 0);
|
|
|
|
|
if(opts.WTF) p.s.bgColor.raw_rgb = themes.themeElements.clrScheme[p.s.bgColor.theme].rgb;
|
|
|
|
|
}
|
|
|
|
|
} catch(e) { if(opts.WTF) throw e; }
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_ws_xml_dim(ws, s) {
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
var mergecregex = /<mergeCell ref="[A-Z0-9:]+"\s*\/>/g;
|
|
|
|
|
var sheetdataregex = /<(?:\w+:)?sheetData>([^\u2603]*)<\/(?:\w+:)?sheetData>/;
|
|
|
|
|
var hlinkregex = /<hyperlink[^>]*\/>/g;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var dimregex = /"(\w*:\w*)"/;
|
|
|
|
|
var colregex = /<col[^>]*\/>/g;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* 18.3 Worksheets */
|
2014-04-15 09:04:03 +00:00
|
|
|
|
function parse_ws_xml(data, opts, rels) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
if(!data) return data;
|
|
|
|
|
/* 18.3.1.99 worksheet CT_Worksheet */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var s = {};
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* 18.3.1.35 dimension CT_SheetDimension ? */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var ridx = data.indexOf("<dimension");
|
|
|
|
|
if(ridx > 0) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var ref = data.substr(ridx,50).match(dimregex);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(ref != null) parse_ws_xml_dim(s, ref[1]);
|
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-03-23 21:30:00 +00:00
|
|
|
|
/* 18.3.1.55 mergeCells CT_MergeCells */
|
|
|
|
|
var mergecells = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(data.indexOf("</mergeCells>")!==-1) {
|
|
|
|
|
var merges = data.match(mergecregex);
|
|
|
|
|
for(ridx = 0; ridx != merges.length; ++ridx)
|
|
|
|
|
mergecells[ridx] = safe_decode_range(merges[ridx].substr(merges[ridx].indexOf("\"")+1));
|
2014-03-23 21:30:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
|
/* 18.3.1.17 cols CT_Cols */
|
|
|
|
|
var columns = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(opts.cellStyles && data.indexOf("</cols>")!==-1) {
|
2014-06-02 05:19:07 +00:00
|
|
|
|
/* 18.3.1.13 col CT_Col */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var cols = data.match(colregex);
|
2014-06-05 07:06:20 +00:00
|
|
|
|
parse_ws_xml_cols(columns, cols);
|
2014-06-02 05:19:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var refguess = {s: {r:1000000, c:1000000}, e: {r:0, c:0} };
|
2014-03-23 21:30:00 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* 18.3.1.80 sheetData CT_SheetData ? */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var mtch=data.match(sheetdataregex);
|
|
|
|
|
if(mtch) parse_ws_xml_data(mtch[1], s, opts, refguess);
|
2014-04-15 09:04:03 +00:00
|
|
|
|
|
|
|
|
|
/* 18.3.1.48 hyperlinks CT_Hyperlinks */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(data.indexOf("</hyperlinks>")!==-1) parse_ws_xml_hlinks(s, data.match(hlinkregex), rels);
|
2014-04-15 09:04:03 +00:00
|
|
|
|
|
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"]);
|
2014-02-19 03:03:28 +00:00
|
|
|
|
if(opts.sheetRows < +tmpref.e.r) {
|
|
|
|
|
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-03-23 21:30:00 +00:00
|
|
|
|
if(mergecells.length > 0) s["!merges"] = mergecells;
|
2014-06-02 05:19:07 +00:00
|
|
|
|
if(columns.length > 0) s["!cols"] = columns;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 17:40:04 +00:00
|
|
|
|
function write_ws_xml_merges(merges) {
|
|
|
|
|
if(merges.length == 0) return "";
|
|
|
|
|
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
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_ws_xml_hlinks(s, data, rels) {
|
|
|
|
|
for(var i = 0; i != data.length; ++i) {
|
|
|
|
|
var val = parsexmltag(data[i], true);
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(!val.ref) return;
|
|
|
|
|
var rel = rels['!id'][val.id];
|
|
|
|
|
if(rel) {
|
|
|
|
|
val.Target = rel.Target;
|
|
|
|
|
if(val.location) val.Target += "#"+val.location;
|
|
|
|
|
val.Rel = rel;
|
|
|
|
|
}
|
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});
|
|
|
|
|
if(!s[addr]) s[addr] = {t:"str",v:undefined};
|
|
|
|
|
s[addr].l = val;
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-05 07:06:20 +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);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var colm=parseInt(coll.min, 10)-1, colM=parseInt(coll.max,10)-1;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
delete coll.min; delete coll.max;
|
|
|
|
|
if(!seencol && coll.width) { seencol = true; find_mdw(+coll.width, coll); }
|
|
|
|
|
if(coll.width) {
|
|
|
|
|
coll.wpx = width2px(+coll.width);
|
|
|
|
|
coll.wch = px2char(coll.wpx);
|
|
|
|
|
coll.MDW = MDW;
|
|
|
|
|
}
|
|
|
|
|
while(colm <= colM) columns[colm++] = coll;
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-06-05 07:06:20 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_ws_xml_cols(ws, cols) {
|
2014-06-05 07:06:20 +00:00
|
|
|
|
var o = ["<cols>"], col, width;
|
|
|
|
|
for(var i = 0; i != cols.length; ++i) {
|
|
|
|
|
if(!(col = cols[i])) continue;
|
|
|
|
|
var p = {min:i+1,max:i+1};
|
|
|
|
|
/* wch (chars), wpx (pixels) */
|
|
|
|
|
width = -1;
|
|
|
|
|
if(col.wpx) width = px2char(col.wpx);
|
|
|
|
|
else if(col.wch) width = col.wch;
|
|
|
|
|
if(width > -1) { p.width = char2width(width); p.customWidth= 1; }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
o[o.length] = (writextag('col', null, p));
|
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
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_ws_xml_cell(cell, ref, ws, opts, idx, wb) {
|
|
|
|
|
if(cell.v === undefined) return "";
|
|
|
|
|
var vv = "";
|
|
|
|
|
switch(cell.t) {
|
|
|
|
|
case 'b': vv = cell.v ? "1" : "0"; break;
|
|
|
|
|
case 'n': case 'e': vv = ''+cell.v; break;
|
|
|
|
|
default: vv = cell.v; break;
|
|
|
|
|
}
|
|
|
|
|
var v = writetag('v', escapexml(vv)), o = {r:ref};
|
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;
|
|
|
|
|
case 'b': o.t = "b"; break;
|
|
|
|
|
case 'e': o.t = "e"; break;
|
|
|
|
|
default:
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(opts.bookSST) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
v = writetag('v', ''+get_sst_id(opts.Strings, cell.v));
|
|
|
|
|
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-06-29 18:29:45 +00:00
|
|
|
|
return writextag('c', v, o);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var parse_ws_xml_data = (function parse_ws_xml_data_factory() {
|
2014-10-10 02:22:38 +00:00
|
|
|
|
var cellregex = /<(?:\w+:)?c[ >]/, rowregex = /<\/(?:\w+:)?row>/;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var rregex = /r=["']([^"']*)["']/, isregex = /<is>([\S\s]*?)<\/is>/;
|
|
|
|
|
var match_v = matchtag("v"), match_f = matchtag("f");
|
|
|
|
|
|
|
|
|
|
return function parse_ws_xml_data(sdata, s, opts, guess) {
|
|
|
|
|
var ri = 0, x = "", cells = [], cref = [], idx = 0, i=0, cc=0, d="", p;
|
2014-10-10 02:22:38 +00:00
|
|
|
|
var tag, tagr = 0, tagc = 0;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var sstr;
|
|
|
|
|
var fmtid = 0, fillid = 0, do_format = Array.isArray(styles.CellXf), cf;
|
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-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;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
tag = parsexmltag(x.substr(0,ri), true);
|
2014-10-10 02:22:38 +00:00
|
|
|
|
/* SpreadSheetGear uses implicit r/c */
|
|
|
|
|
tagr = typeof tag.r !== 'undefined' ? 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
|
|
|
|
|
|
|
|
|
/* 18.3.1.4 c CT_Cell */
|
|
|
|
|
cells = x.substr(ri).split(cellregex);
|
2014-10-10 02:22:38 +00:00
|
|
|
|
for(ri = typeof tag.r === 'undefined' ? 0 : 1; 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;
|
2014-10-10 02:22:38 +00:00
|
|
|
|
x = "<c " + (x.substr(0,1)=="<"?">":"") + x;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(cref !== null && cref.length === 2) {
|
|
|
|
|
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;
|
|
|
|
|
tag = parsexmltag(x.substr(0,i), true);
|
2014-10-10 02:22:38 +00:00
|
|
|
|
if(!tag.r) tag.r = utils.encode_cell({r:tagr-1, c:tagc});
|
2014-06-29 18:29:45 +00:00
|
|
|
|
d = x.substr(i);
|
|
|
|
|
p = {t:""};
|
|
|
|
|
|
2014-08-26 17:40:04 +00:00
|
|
|
|
if((cref=d.match(match_v))!== null && cref[1] !== '') p.v=unescapexml(cref[1]);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(opts.cellFormula && (cref=d.match(match_f))!== null) p.f=unescapexml(cref[1]);
|
|
|
|
|
|
|
|
|
|
/* SCHEMA IS ACTUALLY INCORRECT HERE. IF A CELL HAS NO T, EMIT "" */
|
|
|
|
|
if(tag.t === undefined && p.v === undefined) {
|
|
|
|
|
if(!opts.sheetStubs) continue;
|
|
|
|
|
p.t = "str";
|
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
case 'n': p.v = parseFloat(p.v); break;
|
|
|
|
|
case 's':
|
|
|
|
|
sstr = strs[parseInt(p.v, 10)];
|
|
|
|
|
p.v = sstr.t;
|
|
|
|
|
p.r = sstr.r;
|
|
|
|
|
if(opts.cellHTML) p.h = sstr.h;
|
|
|
|
|
break;
|
|
|
|
|
case 'str': if(p.v != null) p.v = utf8read(p.v); else p.v = ""; break;
|
|
|
|
|
case 'inlineStr':
|
|
|
|
|
cref = d.match(isregex);
|
|
|
|
|
p.t = 'str';
|
|
|
|
|
if(cref !== null) { sstr = parse_si(cref[1]); p.v = sstr.t; } else p.v = "";
|
|
|
|
|
break; // inline string
|
|
|
|
|
case 'b': p.v = parsexmlbool(p.v); break;
|
|
|
|
|
case 'd':
|
|
|
|
|
p.v = datenum(p.v);
|
|
|
|
|
p.t = 'n';
|
|
|
|
|
break;
|
|
|
|
|
/* in case of error, stick value in .raw */
|
|
|
|
|
case 'e': p.raw = RBErr[p.v]; break;
|
|
|
|
|
}
|
|
|
|
|
/* 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;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(opts.cellStyles && cf.fillId != null) fillid = cf.fillId;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
safe_format(p, fmtid, fillid, opts);
|
|
|
|
|
s[tag.r] = p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}; })();
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_ws_xml_data(ws, opts, idx, wb) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var o = [], r = [], range = safe_decode_range(ws['!ref']), cell, ref, rr = "", cols = [], R, C;
|
|
|
|
|
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;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(ws[ref] === undefined) continue;
|
|
|
|
|
if((cell = write_ws_xml_cell(ws[ref], ref, ws, opts, idx, wb)) != null) r.push(cell);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(r.length > 0) o[o.length] = (writextag('row', r.join(""), {r:rr}));
|
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
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_ws_xml(idx, opts, wb) {
|
|
|
|
|
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];
|
|
|
|
|
if(ws === undefined) ws = {};
|
|
|
|
|
var ref = ws['!ref']; if(ref === undefined) ref = 'A1';
|
|
|
|
|
o[o.length] = (writextag('dimension', null, {'ref': ref}));
|
|
|
|
|
|
|
|
|
|
if(ws['!cols'] !== undefined && ws['!cols'].length > 0) o[o.length] = (write_ws_xml_cols(ws, ws['!cols']));
|
|
|
|
|
o[sidx = o.length] = '<sheetData/>';
|
|
|
|
|
if(ws['!ref'] !== undefined) {
|
|
|
|
|
rdata = write_ws_xml_data(ws, opts, idx, wb);
|
|
|
|
|
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
|
|
|
|
|
2014-08-26 17:40:04 +00:00
|
|
|
|
if(ws['!merges'] !== undefined && ws['!merges'].length > 0) o[o.length] = (write_ws_xml_merges(ws['!merges']));
|
|
|
|
|
|
2014-06-29 18:29:45 +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
|
|
|
|
}
|
2014-02-13 06:22:42 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.718 BrtRowHdr */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtRowHdr(data, length) {
|
|
|
|
|
var z = [];
|
2014-01-28 16:38:02 +00:00
|
|
|
|
z.r = data.read_shift(4);
|
|
|
|
|
data.l += length-4;
|
|
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.812 BrtWsDim */
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.815 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;
|
|
|
|
|
z.name = parse_CodeName(data, length - 19);
|
|
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-02-13 06:22:42 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.303 BrtCellBlank */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellBlank(data, length) {
|
2014-03-29 22:53:15 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
return [cell];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
function write_BrtCellBlank(cell, val, o) {
|
|
|
|
|
if(o == null) o = new_buf(8);
|
|
|
|
|
return write_Cell(val, o);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-13 06:22:42 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.304 BrtCellBool */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellBool(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var fBool = data.read_shift(1);
|
|
|
|
|
return [cell, fBool, 'b'];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.305 BrtCellError */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellError(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var fBool = data.read_shift(1);
|
|
|
|
|
return [cell, fBool, 'e'];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.308 BrtCellIsst */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellIsst(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var isst = data.read_shift(4);
|
|
|
|
|
return [cell, isst, 's'];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.310 BrtCellReal */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellReal(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var value = parse_Xnum(data);
|
|
|
|
|
return [cell, value, 'n'];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.311 BrtCellRk */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellRk(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var value = parse_RkNumber(data);
|
|
|
|
|
return [cell, value, 'n'];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-02-13 06:22:42 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.314 BrtCellSt */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtCellSt(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var value = parse_XLWideString(data);
|
|
|
|
|
return [cell, value, 'str'];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-02-12 06:09:42 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.647 BrtFmlaBool */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtFmlaBool(data, length, opts) {
|
2014-02-12 06:09:42 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var value = data.read_shift(1);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
var o = [cell, value, 'b'];
|
|
|
|
|
if(opts.cellFormula) {
|
|
|
|
|
var formula = parse_CellParsedFormula(data, length-9);
|
|
|
|
|
o[3] = ""; /* TODO */
|
|
|
|
|
}
|
|
|
|
|
else data.l += length-9;
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
|
2014-01-29 06:00:09 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.648 BrtFmlaError */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtFmlaError(data, length, opts) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
var value = data.read_shift(1);
|
|
|
|
|
var o = [cell, value, 'e'];
|
|
|
|
|
if(opts.cellFormula) {
|
|
|
|
|
var formula = parse_CellParsedFormula(data, length-9);
|
|
|
|
|
o[3] = ""; /* TODO */
|
|
|
|
|
}
|
|
|
|
|
else data.l += length-9;
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.649 BrtFmlaNum */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtFmlaNum(data, length, opts) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var value = parse_Xnum(data);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
var o = [cell, value, 'n'];
|
|
|
|
|
if(opts.cellFormula) {
|
|
|
|
|
var formula = parse_CellParsedFormula(data, length - 16);
|
|
|
|
|
o[3] = ""; /* TODO */
|
|
|
|
|
}
|
|
|
|
|
else data.l += length-16;
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-02-12 06:09:42 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.650 BrtFmlaString */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtFmlaString(data, length, opts) {
|
2014-02-12 06:09:42 +00:00
|
|
|
|
var start = data.l;
|
|
|
|
|
var cell = parse_Cell(data);
|
|
|
|
|
var value = parse_XLWideString(data);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
var o = [cell, value, 'str'];
|
|
|
|
|
if(opts.cellFormula) {
|
|
|
|
|
var formula = parse_CellParsedFormula(data, start + length - data.l);
|
|
|
|
|
}
|
|
|
|
|
else data.l = start + length;
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
|
2014-03-23 21:30:00 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.676 BrtMergeCell */
|
|
|
|
|
var parse_BrtMergeCell = parse_UncheckedRfX;
|
|
|
|
|
|
2014-04-15 09:04:03 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.656 BrtHLink */
|
2014-06-29 18:29:45 +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;
|
|
|
|
|
return {rfx:rfx, relId:relId, loc:loc, tooltip:tooltip, display:display};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-04-15 09:04:03 +00:00
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.1.7.61 Worksheet */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_ws_bin(data, opts, rels) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
if(!data) return data;
|
2014-04-15 09:04:03 +00:00
|
|
|
|
if(!rels) rels = {'!id':{}};
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var s = {};
|
|
|
|
|
|
|
|
|
|
var ref;
|
2014-02-19 03:03:28 +00:00
|
|
|
|
var refguess = {s: {r:1000000, c:1000000}, e: {r:0, c:0} };
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-02-19 03:03:28 +00:00
|
|
|
|
var pass = false, end = false;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var row, p, cf, R, C, addr, sstr, rr;
|
2014-03-23 21:30:00 +00:00
|
|
|
|
var mergecells = [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
recordhopper(data, function ws_parse(val, R) {
|
2014-02-19 03:03:28 +00:00
|
|
|
|
if(end) return;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
switch(R.n) {
|
|
|
|
|
case 'BrtWsDim': ref = val; break;
|
2014-02-19 03:03:28 +00:00
|
|
|
|
case 'BrtRowHdr':
|
|
|
|
|
row = val;
|
|
|
|
|
if(opts.sheetRows && opts.sheetRows <= row.r) end=true;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
rr = encode_row(row.r);
|
2014-02-19 03:03:28 +00:00
|
|
|
|
break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-02-12 06:09:42 +00:00
|
|
|
|
case 'BrtFmlaBool':
|
|
|
|
|
case 'BrtFmlaError':
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtFmlaNum':
|
2014-02-12 06:09:42 +00:00
|
|
|
|
case 'BrtFmlaString':
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtCellBool':
|
|
|
|
|
case 'BrtCellError':
|
|
|
|
|
case 'BrtCellIsst':
|
|
|
|
|
case 'BrtCellReal':
|
|
|
|
|
case 'BrtCellRk':
|
2014-03-19 17:53:20 +00:00
|
|
|
|
case 'BrtCellSt':
|
2014-01-28 16:38:02 +00:00
|
|
|
|
p = {t:val[2]};
|
|
|
|
|
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;
|
|
|
|
|
case 'e': p.raw = val[1]; p.v = BErr[p.raw]; break;
|
2014-02-12 06:09:42 +00:00
|
|
|
|
case 'str': p.v = utf8read(val[1]); break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
2014-02-13 06:22:42 +00:00
|
|
|
|
if(opts.cellFormula && val.length > 3) p.f = val[3];
|
2014-06-02 05:19:07 +00:00
|
|
|
|
if((cf = styles.CellXf[val[0].iStyleRef])) safe_format(p,cf.ifmt,null,opts);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
s[encode_col(C=val[0].c) + rr] = p;
|
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;
|
2014-02-19 03:03:28 +00:00
|
|
|
|
break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-03-29 22:53:15 +00:00
|
|
|
|
case 'BrtCellBlank': if(!opts.sheetStubs) break;
|
|
|
|
|
p = {t:'str',v:undefined};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
s[encode_col(C=val[0].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
|
|
|
|
|
2014-03-23 21:30:00 +00:00
|
|
|
|
/* Merge Cells */
|
|
|
|
|
case 'BrtBeginMergeCells': break;
|
|
|
|
|
case 'BrtEndMergeCells': break;
|
|
|
|
|
case 'BrtMergeCell': mergecells.push(val); break;
|
2014-04-15 09:04:03 +00:00
|
|
|
|
|
|
|
|
|
case 'BrtHLink':
|
|
|
|
|
var rel = rels['!id'][val.relId];
|
|
|
|
|
if(rel) {
|
|
|
|
|
val.Target = rel.Target;
|
|
|
|
|
if(val.loc) val.Target += "#"+val.loc;
|
|
|
|
|
val.Rel = rel;
|
|
|
|
|
}
|
|
|
|
|
for(R=val.rfx.s.r;R<=val.rfx.e.r;++R) for(C=val.rfx.s.c;C<=val.rfx.e.c;++C) {
|
|
|
|
|
addr = encode_cell({c:C,r:R});
|
|
|
|
|
if(!s[addr]) s[addr] = {t:"str",v:undefined};
|
|
|
|
|
s[addr].l = val;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtArrFmla': break; // TODO
|
|
|
|
|
case 'BrtShrFmla': break; // TODO
|
|
|
|
|
case 'BrtBeginSheet': break;
|
|
|
|
|
case 'BrtWsProp': break; // TODO
|
|
|
|
|
case 'BrtSheetCalcProp': break; // TODO
|
|
|
|
|
case 'BrtBeginWsViews': break; // TODO
|
|
|
|
|
case 'BrtBeginWsView': break; // TODO
|
2014-03-19 17:53:20 +00:00
|
|
|
|
case 'BrtPane': break; // TODO
|
|
|
|
|
case 'BrtSel': break; // TODO
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtEndWsView': break; // TODO
|
|
|
|
|
case 'BrtEndWsViews': break; // TODO
|
|
|
|
|
case 'BrtACBegin': break; // TODO
|
2014-03-19 17:53:20 +00:00
|
|
|
|
case 'BrtRwDescent': break; // TODO
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtACEnd': break; // TODO
|
|
|
|
|
case 'BrtWsFmtInfoEx14': break; // TODO
|
|
|
|
|
case 'BrtWsFmtInfo': break; // TODO
|
|
|
|
|
case 'BrtBeginColInfos': break; // TODO
|
|
|
|
|
case 'BrtColInfo': break; // TODO
|
|
|
|
|
case 'BrtEndColInfos': break; // TODO
|
|
|
|
|
case 'BrtBeginSheetData': break; // TODO
|
|
|
|
|
case 'BrtEndSheetData': break; // TODO
|
|
|
|
|
case 'BrtSheetProtection': break; // TODO
|
|
|
|
|
case 'BrtPrintOptions': break; // TODO
|
|
|
|
|
case 'BrtMargins': break; // TODO
|
|
|
|
|
case 'BrtPageSetup': break; // TODO
|
2014-01-31 11:52:18 +00:00
|
|
|
|
case 'BrtFRTBegin': pass = true; break;
|
|
|
|
|
case 'BrtFRTEnd': pass = false; break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtEndSheet': break; // TODO
|
2014-03-19 17:53:20 +00:00
|
|
|
|
case 'BrtDrawing': break; // TODO
|
2014-02-13 06:22:42 +00:00
|
|
|
|
case 'BrtLegacyDrawing': break; // TODO
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case 'BrtLegacyDrawingHF': break; // TODO
|
2014-03-19 17:53:20 +00:00
|
|
|
|
case 'BrtPhoneticInfo': break; // TODO
|
|
|
|
|
case 'BrtBeginHeaderFooter': break; // TODO
|
|
|
|
|
case 'BrtEndHeaderFooter': break; // TODO
|
|
|
|
|
case 'BrtBrk': break; // TODO
|
|
|
|
|
case 'BrtBeginRwBrk': break; // TODO
|
|
|
|
|
case 'BrtEndRwBrk': break; // TODO
|
|
|
|
|
case 'BrtBeginColBrk': break; // TODO
|
|
|
|
|
case 'BrtEndColBrk': break; // TODO
|
|
|
|
|
case 'BrtBeginUserShViews': break; // TODO
|
|
|
|
|
case 'BrtBeginUserShView': break; // TODO
|
|
|
|
|
case 'BrtEndUserShView': break; // TODO
|
|
|
|
|
case 'BrtEndUserShViews': break; // TODO
|
|
|
|
|
case 'BrtBkHim': break; // TODO
|
|
|
|
|
case 'BrtBeginOleObjects': break; // TODO
|
|
|
|
|
case 'BrtOleObject': break; // TODO
|
|
|
|
|
case 'BrtEndOleObjects': break; // TODO
|
|
|
|
|
case 'BrtBeginListParts': break; // TODO
|
|
|
|
|
case 'BrtListPart': break; // TODO
|
|
|
|
|
case 'BrtEndListParts': break; // TODO
|
|
|
|
|
case 'BrtBeginSortState': break; // TODO
|
|
|
|
|
case 'BrtBeginSortCond': break; // TODO
|
|
|
|
|
case 'BrtEndSortCond': break; // TODO
|
|
|
|
|
case 'BrtEndSortState': break; // TODO
|
|
|
|
|
case 'BrtBeginConditionalFormatting': break; // TODO
|
|
|
|
|
case 'BrtEndConditionalFormatting': break; // TODO
|
|
|
|
|
case 'BrtBeginCFRule': break; // TODO
|
|
|
|
|
case 'BrtEndCFRule': break; // TODO
|
|
|
|
|
case 'BrtBeginDVals': break; // TODO
|
|
|
|
|
case 'BrtDVal': break; // TODO
|
|
|
|
|
case 'BrtEndDVals': break; // TODO
|
|
|
|
|
case 'BrtRangeProtection': break; // TODO
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case 'BrtBeginDCon': break; // TODO
|
|
|
|
|
case 'BrtEndDCon': break; // TODO
|
|
|
|
|
case 'BrtBeginDRefs': break;
|
|
|
|
|
case 'BrtDRef': break;
|
|
|
|
|
case 'BrtEndDRefs': break;
|
2014-03-21 02:44:27 +00:00
|
|
|
|
|
|
|
|
|
/* ActiveX */
|
|
|
|
|
case 'BrtBeginActiveXControls': break;
|
|
|
|
|
case 'BrtActiveX': break;
|
|
|
|
|
case 'BrtEndActiveXControls': break;
|
|
|
|
|
|
|
|
|
|
/* AutoFilter */
|
|
|
|
|
case 'BrtBeginAFilter': break;
|
|
|
|
|
case 'BrtEndAFilter': break;
|
|
|
|
|
case 'BrtBeginFilterColumn': break;
|
|
|
|
|
case 'BrtBeginFilters': break;
|
2014-04-15 09:04:03 +00:00
|
|
|
|
case 'BrtFilter': break;
|
2014-03-21 02:44:27 +00:00
|
|
|
|
case 'BrtEndFilters': break;
|
|
|
|
|
case 'BrtEndFilterColumn': break;
|
|
|
|
|
case 'BrtDynamicFilter': break;
|
|
|
|
|
case 'BrtTop10Filter': break;
|
|
|
|
|
case 'BrtBeginCustomFilters': break;
|
|
|
|
|
case 'BrtCustomFilter': break;
|
|
|
|
|
case 'BrtEndCustomFilters': break;
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
/* Smart Tags */
|
|
|
|
|
case 'BrtBeginSmartTags': break;
|
|
|
|
|
case 'BrtBeginCellSmartTags': break;
|
|
|
|
|
case 'BrtBeginCellSmartTag': break;
|
|
|
|
|
case 'BrtCellSmartTagProperty': break;
|
|
|
|
|
case 'BrtEndCellSmartTag': break;
|
|
|
|
|
case 'BrtEndCellSmartTags': break;
|
|
|
|
|
case 'BrtEndSmartTags': break;
|
|
|
|
|
|
2014-03-29 02:05:50 +00:00
|
|
|
|
/* Cell Watch */
|
|
|
|
|
case 'BrtBeginCellWatches': break;
|
|
|
|
|
case 'BrtCellWatch': break;
|
|
|
|
|
case 'BrtEndCellWatches': break;
|
|
|
|
|
|
|
|
|
|
/* Table */
|
|
|
|
|
case 'BrtTable': break;
|
|
|
|
|
|
|
|
|
|
/* Ignore Cell Errors */
|
|
|
|
|
case 'BrtBeginCellIgnoreECs': break;
|
|
|
|
|
case 'BrtCellIgnoreEC': break;
|
|
|
|
|
case 'BrtEndCellIgnoreECs': break;
|
|
|
|
|
|
2014-03-23 21:30:00 +00:00
|
|
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + R.n);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
2014-02-13 06:22:42 +00:00
|
|
|
|
}, opts);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(!s["!ref"] && (refguess.s.r < 1000000 || ref.e.r > 0 || ref.e.c > 0 || ref.s.r > 0 || ref.s.c > 0)) s["!ref"] = encode_range(ref);
|
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"]);
|
2014-02-19 03:03:28 +00:00
|
|
|
|
if(opts.sheetRows < +tmpref.e.r) {
|
|
|
|
|
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-03-23 21:30:00 +00:00
|
|
|
|
if(mergecells.length > 0) s["!merges"] = mergecells;
|
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 */
|
|
|
|
|
function write_ws_bin_cell(ba, cell, R, C, opts) {
|
|
|
|
|
if(cell.v === undefined) return "";
|
|
|
|
|
var vv = "";
|
|
|
|
|
switch(cell.t) {
|
|
|
|
|
case 'b': vv = cell.v ? "1" : "0"; break;
|
|
|
|
|
case 'n': case 'e': vv = ''+cell.v; break;
|
|
|
|
|
default: vv = cell.v; break;
|
|
|
|
|
}
|
|
|
|
|
var o = {r:R, c:C};
|
|
|
|
|
/* TODO: cell style */
|
|
|
|
|
o.s = get_cell_style(opts.cellXfs, cell, opts);
|
|
|
|
|
switch(cell.t) {
|
|
|
|
|
case 's': case 'str':
|
|
|
|
|
if(opts.bookSST) {
|
|
|
|
|
vv = get_sst_id(opts.Strings, cell.v);
|
|
|
|
|
o.t = "s"; break;
|
|
|
|
|
}
|
|
|
|
|
o.t = "str"; break;
|
|
|
|
|
case 'n': break;
|
|
|
|
|
case 'b': o.t = "b"; break;
|
|
|
|
|
case 'e': o.t = "e"; break;
|
|
|
|
|
}
|
|
|
|
|
write_record(ba, "BrtCellBlank", write_BrtCellBlank(cell, o));
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
function write_CELLTABLE(ba, ws, idx, opts, wb) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var range = safe_decode_range(ws['!ref'] || "A1"), ref, rr = "", cols = [];
|
2014-05-29 22:30:03 +00:00
|
|
|
|
write_record(ba, 'BrtBeginSheetData');
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(var R = range.s.r; R <= range.e.r; ++R) {
|
|
|
|
|
rr = encode_row(R);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* [ACCELLTABLE] */
|
|
|
|
|
/* BrtRowHdr */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(var C = range.s.c; C <= range.e.c; ++C) {
|
|
|
|
|
/* *16384CELL */
|
|
|
|
|
if(R === range.s.r) cols[C] = encode_col(C);
|
|
|
|
|
ref = cols[C] + rr;
|
|
|
|
|
if(!ws[ref]) continue;
|
|
|
|
|
/* write cell */
|
|
|
|
|
write_ws_bin_cell(ba, ws[ref], R, C, opts);
|
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
}
|
|
|
|
|
write_record(ba, 'BrtEndSheetData');
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_ws_bin(idx, opts, wb) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var ba = buf_array();
|
|
|
|
|
var s = wb.SheetNames[idx], ws = wb.Sheets[s] || {};
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var r = safe_decode_range(ws['!ref'] || "A1");
|
2014-05-29 22:30:03 +00:00
|
|
|
|
write_record(ba, "BrtBeginSheet");
|
|
|
|
|
/* [BrtWsProp] */
|
|
|
|
|
write_record(ba, "BrtWsDim", write_BrtWsDim(r));
|
|
|
|
|
/* [WSVIEWS2] */
|
|
|
|
|
/* [WSFMTINFO] */
|
|
|
|
|
/* *COLINFOS */
|
|
|
|
|
write_CELLTABLE(ba, ws, idx, opts, wb);
|
|
|
|
|
/* [BrtSheetCalcProp] */
|
|
|
|
|
/* [[BrtSheetProtectionIso] BrtSheetProtection] */
|
|
|
|
|
/* *([BrtRangeProtectionIso] BrtRangeProtection) */
|
|
|
|
|
/* [SCENMAN] */
|
|
|
|
|
/* [AUTOFILTER] */
|
|
|
|
|
/* [SORTSTATE] */
|
|
|
|
|
/* [DCON] */
|
|
|
|
|
/* [USERSHVIEWS] */
|
|
|
|
|
/* [MERGECELLS] */
|
|
|
|
|
/* [BrtPhoneticInfo] */
|
|
|
|
|
/* *CONDITIONALFORMATTING */
|
|
|
|
|
/* [DVALS] */
|
|
|
|
|
/* *BrtHLink */
|
|
|
|
|
/* [BrtPrintOptions] */
|
|
|
|
|
/* [BrtMargins] */
|
|
|
|
|
/* [BrtPageSetup] */
|
|
|
|
|
/* [HEADERFOOTER] */
|
|
|
|
|
/* [RWBRK] */
|
|
|
|
|
/* [COLBRK] */
|
|
|
|
|
/* *BrtBigName */
|
|
|
|
|
/* [CELLWATCHES] */
|
|
|
|
|
/* [IGNOREECS] */
|
|
|
|
|
/* [SMARTTAGS] */
|
|
|
|
|
/* [BrtDrawing] */
|
|
|
|
|
/* [BrtLegacyDrawing] */
|
|
|
|
|
/* [BrtLegacyDrawingHF] */
|
|
|
|
|
/* [BrtBkHim] */
|
|
|
|
|
/* [OLEOBJECTS] */
|
|
|
|
|
/* [ACTIVEXCONTROLS] */
|
|
|
|
|
/* [WEBPUBITEMS] */
|
|
|
|
|
/* [LISTPARTS] */
|
|
|
|
|
/* FRTWORKSHEET */
|
|
|
|
|
write_record(ba, "BrtEndSheet");
|
|
|
|
|
return ba.end();
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* 18.2.28 (CT_WorkbookProtection) Defaults */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var WBPropsDef = [
|
|
|
|
|
['allowRefreshQuery', '0'],
|
|
|
|
|
['autoCompressPictures', '1'],
|
|
|
|
|
['backupFile', '0'],
|
|
|
|
|
['checkCompatibility', '0'],
|
|
|
|
|
['codeName', ''],
|
|
|
|
|
['date1904', '0'],
|
|
|
|
|
['dateCompatibility', '1'],
|
|
|
|
|
//['defaultThemeVersion', '0'],
|
|
|
|
|
['filterPrivacy', '0'],
|
|
|
|
|
['hidePivotFieldList', '0'],
|
|
|
|
|
['promptedSolutions', '0'],
|
|
|
|
|
['publishItems', '0'],
|
|
|
|
|
['refreshAllConnections', false],
|
|
|
|
|
['saveExternalLinkValues', '1'],
|
|
|
|
|
['showBorderUnselectedTables', '1'],
|
|
|
|
|
['showInkAnnotation', '1'],
|
|
|
|
|
['showObjects', 'all'],
|
|
|
|
|
['showPivotChartFilter', '0']
|
|
|
|
|
//['updateLinks', 'userSet']
|
|
|
|
|
];
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* 18.2.30 (CT_BookView) Defaults */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var WBViewDef = [
|
|
|
|
|
['activeTab', '0'],
|
|
|
|
|
['autoFilterDateGrouping', '1'],
|
|
|
|
|
['firstSheet', '0'],
|
|
|
|
|
['minimized', '0'],
|
|
|
|
|
['showHorizontalScroll', '1'],
|
|
|
|
|
['showSheetTabs', '1'],
|
|
|
|
|
['showVerticalScroll', '1'],
|
|
|
|
|
['tabRatio', '600'],
|
|
|
|
|
['visibility', 'visible']
|
2014-01-28 16:38:02 +00:00
|
|
|
|
//window{Height,Width}, {x,y}Window
|
2014-06-29 18:29:45 +00:00
|
|
|
|
];
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* 18.2.19 (CT_Sheet) Defaults */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var SheetDef = [
|
|
|
|
|
['state', 'visible']
|
|
|
|
|
];
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* 18.2.2 (CT_CalcPr) Defaults */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var CalcPrDef = [
|
|
|
|
|
['calcCompleted', 'true'],
|
|
|
|
|
['calcMode', 'auto'],
|
|
|
|
|
['calcOnSave', 'true'],
|
|
|
|
|
['concurrentCalc', 'true'],
|
|
|
|
|
['fullCalcOnLoad', 'false'],
|
|
|
|
|
['fullPrecision', 'true'],
|
|
|
|
|
['iterate', 'false'],
|
|
|
|
|
['iterateCount', '100'],
|
|
|
|
|
['iterateDelta', '0.001'],
|
|
|
|
|
['refMode', 'A1']
|
|
|
|
|
];
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* 18.2.3 (CT_CustomWorkbookView) Defaults */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var CustomWBViewDef = [
|
|
|
|
|
['autoUpdate', 'false'],
|
|
|
|
|
['changesSavedWin', 'false'],
|
|
|
|
|
['includeHiddenRowCol', 'true'],
|
|
|
|
|
['includePrintSettings', 'true'],
|
|
|
|
|
['maximized', 'false'],
|
|
|
|
|
['minimized', 'false'],
|
|
|
|
|
['onlySync', 'false'],
|
|
|
|
|
['personalView', 'false'],
|
|
|
|
|
['showComments', 'commIndicator'],
|
|
|
|
|
['showFormulaBar', 'true'],
|
|
|
|
|
['showHorizontalScroll', 'true'],
|
|
|
|
|
['showObjects', 'all'],
|
|
|
|
|
['showSheetTabs', 'true'],
|
|
|
|
|
['showStatusbar', 'true'],
|
|
|
|
|
['showVerticalScroll', 'true'],
|
|
|
|
|
['tabRatio', '600'],
|
|
|
|
|
['xWindow', '0'],
|
|
|
|
|
['yWindow', '0']
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function push_defaults_array(target, defaults) {
|
|
|
|
|
for(var j = 0; j != target.length; ++j) { var w = target[j];
|
|
|
|
|
for(var i=0; i != defaults.length; ++i) { var z = defaults[i];
|
|
|
|
|
if(w[z[0]] == null) w[z[0]] = z[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function push_defaults(target, defaults) {
|
|
|
|
|
for(var i = 0; i != defaults.length; ++i) { var z = defaults[i];
|
|
|
|
|
if(target[z[0]] == null) target[z[0]] = z[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parse_wb_defaults(wb) {
|
|
|
|
|
push_defaults(wb.WBProps, WBPropsDef);
|
|
|
|
|
push_defaults(wb.CalcPr, CalcPrDef);
|
|
|
|
|
|
|
|
|
|
push_defaults_array(wb.WBView, WBViewDef);
|
|
|
|
|
push_defaults_array(wb.Sheets, SheetDef);
|
|
|
|
|
|
|
|
|
|
_ssfopts.date1904 = parsexmlbool(wb.WBProps.date1904, 'date1904');
|
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* 18.2 Workbook */
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var wbnsregex = /<\w+:workbook/;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
function parse_wb_xml(data, opts) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
|
2014-04-03 22:51:54 +00:00
|
|
|
|
var pass = false, xmlns = "xmlns";
|
2014-06-29 18:29:45 +00:00
|
|
|
|
data.match(tagregex).forEach(function xml_wb(x) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var y = parsexmltag(x);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
switch(strip_ns(y[0])) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case '<?xml': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.27 workbook CT_Workbook 1 */
|
2014-04-03 22:51:54 +00:00
|
|
|
|
case '<workbook':
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(x.match(wbnsregex)) xmlns = "xmlns" + x.match(/<(\w+):/)[1];
|
2014-04-03 22:51:54 +00:00
|
|
|
|
wb.xmlns = y[xmlns];
|
|
|
|
|
break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case '</workbook>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.13 fileVersion CT_FileVersion ? */
|
|
|
|
|
case '<fileVersion': delete y[0]; wb.AppVersion = y; break;
|
|
|
|
|
case '<fileVersion/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.12 fileSharing CT_FileSharing ? */
|
|
|
|
|
case '<fileSharing': case '<fileSharing/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.28 workbookPr CT_WorkbookPr ? */
|
|
|
|
|
case '<workbookPr': delete y[0]; wb.WBProps = y; break;
|
|
|
|
|
case '<workbookPr/>': delete y[0]; wb.WBProps = y; break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.29 workbookProtection CT_WorkbookProtection ? */
|
2014-06-05 07:06:20 +00:00
|
|
|
|
case '<workbookProtection': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case '<workbookProtection/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.1 bookViews CT_BookViews ? */
|
|
|
|
|
case '<bookViews>': case '</bookViews>': break;
|
|
|
|
|
/* 18.2.30 workbookView CT_BookView + */
|
|
|
|
|
case '<workbookView': delete y[0]; wb.WBView.push(y); break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.20 sheets CT_Sheets 1 */
|
|
|
|
|
case '<sheets>': case '</sheets>': break; // aggregate sheet
|
|
|
|
|
/* 18.2.19 sheet CT_Sheet + */
|
|
|
|
|
case '<sheet': delete y[0]; y.name = utf8read(y.name); wb.Sheets.push(y); break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.15 functionGroups CT_FunctionGroups ? */
|
|
|
|
|
case '<functionGroups': case '<functionGroups/>': break;
|
|
|
|
|
/* 18.2.14 functionGroup CT_FunctionGroup + */
|
|
|
|
|
case '<functionGroup': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.9 externalReferences CT_ExternalReferences ? */
|
2014-06-05 07:06:20 +00:00
|
|
|
|
case '<externalReferences': case '</externalReferences>': case '<externalReferences>': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* 18.2.8 externalReference CT_ExternalReference + */
|
|
|
|
|
case '<externalReference': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.6 definedNames CT_DefinedNames ? */
|
|
|
|
|
case '<definedNames/>': break;
|
2014-06-05 07:06:20 +00:00
|
|
|
|
case '<definedNames>': case '<definedNames': pass=true; break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case '</definedNames>': pass=false; break;
|
|
|
|
|
/* 18.2.5 definedName CT_DefinedName + */
|
|
|
|
|
case '<definedName': case '<definedName/>': case '</definedName>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.2 calcPr CT_CalcPr ? */
|
|
|
|
|
case '<calcPr': delete y[0]; wb.CalcPr = y; break;
|
|
|
|
|
case '<calcPr/>': delete y[0]; wb.CalcPr = y; break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.16 oleSize CT_OleSize ? (ref required) */
|
|
|
|
|
case '<oleSize': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.4 customWorkbookViews CT_CustomWorkbookViews ? */
|
|
|
|
|
case '<customWorkbookViews>': case '</customWorkbookViews>': case '<customWorkbookViews': break;
|
|
|
|
|
/* 18.2.3 customWorkbookView CT_CustomWorkbookView + */
|
|
|
|
|
case '<customWorkbookView': case '</customWorkbookView>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.18 pivotCaches CT_PivotCaches ? */
|
|
|
|
|
case '<pivotCaches>': case '</pivotCaches>': case '<pivotCaches': break;
|
|
|
|
|
/* 18.2.17 pivotCache CT_PivotCache ? */
|
|
|
|
|
case '<pivotCache': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.21 smartTagPr CT_SmartTagPr ? */
|
|
|
|
|
case '<smartTagPr': case '<smartTagPr/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.23 smartTagTypes CT_SmartTagTypes ? */
|
|
|
|
|
case '<smartTagTypes': case '<smartTagTypes>': case '</smartTagTypes>': break;
|
|
|
|
|
/* 18.2.22 smartTagType CT_SmartTagType ? */
|
|
|
|
|
case '<smartTagType': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.24 webPublishing CT_WebPublishing ? */
|
|
|
|
|
case '<webPublishing': case '<webPublishing/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.11 fileRecoveryPr CT_FileRecoveryPr ? */
|
|
|
|
|
case '<fileRecoveryPr': case '<fileRecoveryPr/>': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.26 webPublishObjects CT_WebPublishObjects ? */
|
|
|
|
|
case '<webPublishObjects>': case '<webPublishObjects': case '</webPublishObjects>': break;
|
|
|
|
|
/* 18.2.25 webPublishObject CT_WebPublishObject ? */
|
|
|
|
|
case '<webPublishObject': break;
|
|
|
|
|
|
|
|
|
|
/* 18.2.10 extLst CT_ExtensionList ? */
|
|
|
|
|
case '<extLst>': case '</extLst>': case '<extLst/>': break;
|
|
|
|
|
/* 18.2.7 ext CT_Extension + */
|
|
|
|
|
case '<ext': pass=true; break; //TODO: check with versions of excel
|
|
|
|
|
case '</ext>': pass=false; break;
|
|
|
|
|
|
|
|
|
|
/* Others */
|
2014-06-05 07:06:20 +00:00
|
|
|
|
case '<ArchID': break;
|
|
|
|
|
case '<AlternateContent': pass=true; break;
|
|
|
|
|
case '</AlternateContent>': pass=false; break;
|
|
|
|
|
|
|
|
|
|
default: if(!pass && opts.WTF) throw 'unrecognized ' + y[0] + ' in workbook';
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(XMLNS.main.indexOf(wb.xmlns) === -1) throw new Error("Unknown Namespace: " + wb.xmlns);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
parse_wb_defaults(wb);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
return wb;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var WB_XML_ROOT = writextag('workbook', null, {
|
|
|
|
|
'xmlns': XMLNS.main[0],
|
|
|
|
|
//'xmlns:mx': XMLNS.mx,
|
|
|
|
|
//'xmlns:s': XMLNS.main[0],
|
|
|
|
|
'xmlns:r': XMLNS.r
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-02 05:19:07 +00:00
|
|
|
|
function safe1904(wb) {
|
|
|
|
|
/* TODO: store date1904 somewhere else */
|
|
|
|
|
try { return parsexmlbool(wb.Workbook.WBProps.date1904) ? "true" : "false"; } catch(e) { return "false"; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_wb_xml(wb, opts) {
|
|
|
|
|
var o = [XML_HEADER];
|
|
|
|
|
o[o.length] = WB_XML_ROOT;
|
|
|
|
|
o[o.length] = (writextag('workbookPr', null, {date1904:safe1904(wb)}));
|
|
|
|
|
o[o.length] = "<sheets>";
|
|
|
|
|
for(var i = 0; i != wb.SheetNames.length; ++i)
|
|
|
|
|
o[o.length] = (writextag('sheet',null,{name:wb.SheetNames[i].substr(0,31), sheetId:""+(i+1), "r:id":"rId"+(i+1)}));
|
|
|
|
|
o[o.length] = "</sheets>";
|
|
|
|
|
if(o.length>2){ o[o.length] = '</workbook>'; o[1]=o[1].replace("/>",">"); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return o.join("");
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.4.301 BrtBundleSh */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtBundleSh(data, length) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var z = {};
|
|
|
|
|
z.hsState = data.read_shift(4); //ST_SheetState
|
|
|
|
|
z.iTabID = data.read_shift(4);
|
|
|
|
|
z.strRelID = parse_RelID(data,length-8);
|
|
|
|
|
z.name = parse_XLWideString(data);
|
|
|
|
|
return z;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
function write_BrtBundleSh(data, o) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
if(!o) o = new_buf(127);
|
|
|
|
|
o.write_shift(4, data.hsState);
|
|
|
|
|
o.write_shift(4, data.iTabID);
|
|
|
|
|
write_RelID(data.strRelID, o);
|
2014-05-31 15:44:56 +00:00
|
|
|
|
write_XLWideString(data.name.substr(0,31), o);
|
2014-05-29 22:30:03 +00:00
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.807 BrtWbProp */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtWbProp(data, length) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
data.read_shift(4);
|
|
|
|
|
var dwThemeVersion = data.read_shift(4);
|
|
|
|
|
var strName = (length > 8) ? parse_XLWideString(data) : "";
|
|
|
|
|
return [dwThemeVersion, strName];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
|
|
|
|
function write_BrtWbProp(data, o) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
if(!o) o = new_buf(8);
|
|
|
|
|
o.write_shift(4, 0);
|
|
|
|
|
o.write_shift(4, 0);
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_BrtFRTArchID$(data, length) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var o = {};
|
|
|
|
|
data.read_shift(4);
|
|
|
|
|
o.ArchID = data.read_shift(4);
|
|
|
|
|
data.l += length - 8;
|
|
|
|
|
return o;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.60 Workbook */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function parse_wb_bin(data, opts) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
|
2014-01-29 06:00:09 +00:00
|
|
|
|
var pass = false, z;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
recordhopper(data, function hopper_wb(val, R) {
|
2014-01-28 16:38:02 +00:00
|
|
|
|
switch(R.n) {
|
|
|
|
|
case 'BrtBundleSh': wb.Sheets.push(val); break;
|
|
|
|
|
|
|
|
|
|
case 'BrtBeginBook': break;
|
|
|
|
|
case 'BrtFileVersion': break;
|
|
|
|
|
case 'BrtWbProp': break;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
case 'BrtACBegin': break;
|
|
|
|
|
case 'BrtAbsPath15': break;
|
|
|
|
|
case 'BrtACEnd': break;
|
2014-07-14 15:52:48 +00:00
|
|
|
|
case 'BrtWbFactoid': break;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
/*case 'BrtBookProtectionIso': break;*/
|
|
|
|
|
case 'BrtBookProtection': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtBeginBookViews': break;
|
|
|
|
|
case 'BrtBookView': break;
|
|
|
|
|
case 'BrtEndBookViews': break;
|
|
|
|
|
case 'BrtBeginBundleShs': break;
|
|
|
|
|
case 'BrtEndBundleShs': break;
|
2014-02-14 06:25:46 +00:00
|
|
|
|
case 'BrtBeginFnGroup': break;
|
|
|
|
|
case 'BrtEndFnGroup': break;
|
|
|
|
|
case 'BrtBeginExternals': break;
|
|
|
|
|
case 'BrtSupSelf': break;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
case 'BrtSupBookSrc': break;
|
2014-02-14 06:25:46 +00:00
|
|
|
|
case 'BrtExternSheet': break;
|
|
|
|
|
case 'BrtEndExternals': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtName': break;
|
|
|
|
|
case 'BrtCalcProp': break;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
case 'BrtUserBookView': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtBeginPivotCacheIDs': break;
|
|
|
|
|
case 'BrtBeginPivotCacheID': break;
|
|
|
|
|
case 'BrtEndPivotCacheID': break;
|
|
|
|
|
case 'BrtEndPivotCacheIDs': break;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
case 'BrtWebOpt': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtFileRecover': break;
|
2014-03-29 02:05:50 +00:00
|
|
|
|
case 'BrtFileSharing': break;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
/*case 'BrtBeginWebPubItems': break;
|
|
|
|
|
case 'BrtBeginWebPubItem': break;
|
|
|
|
|
case 'BrtEndWebPubItem': break;
|
|
|
|
|
case 'BrtEndWebPubItems': break;*/
|
2014-07-28 13:22:32 +00:00
|
|
|
|
|
|
|
|
|
/* Smart Tags */
|
|
|
|
|
case 'BrtBeginSmartTagTypes': break;
|
|
|
|
|
case 'BrtSmartTagType': break;
|
|
|
|
|
case 'BrtEndSmartTagTypes': break;
|
|
|
|
|
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtFRTBegin': pass = true; break;
|
2014-05-29 22:30:03 +00:00
|
|
|
|
case 'BrtFRTArchID$': break;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
case 'BrtWorkBookPr15': break;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
case 'BrtFRTEnd': pass = false; break;
|
|
|
|
|
case 'BrtEndBook': break;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
default: if(!pass || opts.WTF) throw new Error("Unexpected record " + R.n);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
parse_wb_defaults(wb);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
return wb;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* [MS-XLSB] 2.1.7.60 Workbook */
|
|
|
|
|
function write_BUNDLESHS(ba, wb, opts) {
|
|
|
|
|
write_record(ba, "BrtBeginBundleShs");
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(var idx = 0; idx != wb.SheetNames.length; ++idx) {
|
|
|
|
|
var d = { hsState: 0, iTabID: idx+1, strRelID: 'rId' + (idx+1), name: wb.SheetNames[idx] };
|
2014-05-29 22:30:03 +00:00
|
|
|
|
write_record(ba, "BrtBundleSh", write_BrtBundleSh(d));
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
write_record(ba, "BrtEndBundleShs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.643 BrtFileVersion */
|
|
|
|
|
function write_BrtFileVersion(data, o) {
|
|
|
|
|
if(!o) o = new_buf(127);
|
|
|
|
|
for(var i = 0; i != 4; ++i) o.write_shift(4, 0);
|
|
|
|
|
write_XLWideString("SheetJS", o);
|
|
|
|
|
write_XLWideString(XLSX.version, o);
|
|
|
|
|
write_XLWideString(XLSX.version, o);
|
|
|
|
|
write_XLWideString("7262", o);
|
|
|
|
|
o.length = o.l;
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.60 Workbook */
|
|
|
|
|
function write_BOOKVIEWS(ba, wb, opts) {
|
|
|
|
|
write_record(ba, "BrtBeginBookViews");
|
|
|
|
|
/* 1*(BrtBookView *FRT) */
|
|
|
|
|
write_record(ba, "BrtEndBookViews");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.302 BrtCalcProp */
|
|
|
|
|
function write_BrtCalcProp(data, o) {
|
|
|
|
|
if(!o) o = new_buf(26);
|
|
|
|
|
o.write_shift(4,0); /* force recalc */
|
|
|
|
|
o.write_shift(4,1);
|
|
|
|
|
o.write_shift(4,0);
|
|
|
|
|
write_Xnum(0, o);
|
|
|
|
|
o.write_shift(-4, 1023);
|
|
|
|
|
o.write_shift(1, 0x33);
|
|
|
|
|
o.write_shift(1, 0x00);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_BrtFileRecover(data, o) {
|
|
|
|
|
if(!o) o = new_buf(1);
|
|
|
|
|
o.write_shift(1,0);
|
|
|
|
|
return o;
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
/* [MS-XLSB] 2.1.7.60 Workbook */
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function write_wb_bin(wb, opts) {
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var ba = buf_array();
|
|
|
|
|
write_record(ba, "BrtBeginBook");
|
|
|
|
|
write_record(ba, "BrtFileVersion", write_BrtFileVersion());
|
|
|
|
|
/* [[BrtFileSharingIso] BrtFileSharing] */
|
|
|
|
|
write_record(ba, "BrtWbProp", write_BrtWbProp());
|
|
|
|
|
/* [ACABSPATH] */
|
|
|
|
|
/* [[BrtBookProtectionIso] BrtBookProtection] */
|
|
|
|
|
write_BOOKVIEWS(ba, wb, opts);
|
|
|
|
|
write_BUNDLESHS(ba, wb, opts);
|
|
|
|
|
/* [FNGROUP] */
|
|
|
|
|
/* [EXTERNALS] */
|
|
|
|
|
/* *BrtName */
|
|
|
|
|
write_record(ba, "BrtCalcProp", write_BrtCalcProp());
|
|
|
|
|
/* [BrtOleSize] */
|
|
|
|
|
/* *(BrtUserBookView *FRT) */
|
|
|
|
|
/* [PIVOTCACHEIDS] */
|
|
|
|
|
/* [BrtWbFactoid] */
|
|
|
|
|
/* [SMARTTAGTYPES] */
|
|
|
|
|
/* [BrtWebOpt] */
|
|
|
|
|
write_record(ba, "BrtFileRecover", write_BrtFileRecover());
|
|
|
|
|
/* [WEBPUBITEMS] */
|
|
|
|
|
/* [CRERRS] */
|
|
|
|
|
/* FRTWORKBOOK */
|
|
|
|
|
write_record(ba, "BrtEndBook");
|
|
|
|
|
|
|
|
|
|
return ba.end();
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-02-07 10:53:40 +00:00
|
|
|
|
function parse_wb(data, name, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return (name.substr(-4)===".bin" ? parse_wb_bin : parse_wb_xml)(data, opts);
|
2013-11-06 06:05:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-15 09:04:03 +00:00
|
|
|
|
function parse_ws(data, name, opts, rels) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return (name.substr(-4)===".bin" ? parse_ws_bin : parse_ws_xml)(data, opts, rels);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 10:53:40 +00:00
|
|
|
|
function parse_sty(data, name, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return (name.substr(-4)===".bin" ? parse_sty_bin : parse_sty_xml)(data, opts);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
}
|
2014-02-12 06:09:42 +00:00
|
|
|
|
|
2014-05-29 06:18:23 +00:00
|
|
|
|
function parse_theme(data, name, opts) {
|
|
|
|
|
return parse_theme_xml(data, opts);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 06:09:42 +00:00
|
|
|
|
function parse_sst(data, name, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return (name.substr(-4)===".bin" ? parse_sst_bin : parse_sst_xml)(data, opts);
|
2014-02-12 06:09:42 +00:00
|
|
|
|
}
|
2014-03-29 02:05:50 +00:00
|
|
|
|
|
|
|
|
|
function parse_cmnt(data, name, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return (name.substr(-4)===".bin" ? parse_comments_bin : parse_comments_xml)(data, opts);
|
2014-03-29 02:05:50 +00:00
|
|
|
|
}
|
2014-03-29 22:53:15 +00:00
|
|
|
|
|
|
|
|
|
function parse_cc(data, name, opts) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return (name.substr(-4)===".bin" ? parse_cc_bin : parse_cc_xml)(data, opts);
|
2014-03-29 22:53:15 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
function write_wb(wb, name, opts) {
|
|
|
|
|
return (name.substr(-4)===".bin" ? write_wb_bin : write_wb_xml)(wb, opts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_ws(data, name, opts, wb) {
|
|
|
|
|
return (name.substr(-4)===".bin" ? write_ws_bin : write_ws_xml)(data, opts, wb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_sty(data, name, opts) {
|
|
|
|
|
return (name.substr(-4)===".bin" ? write_sty_bin : write_sty_xml)(data, opts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_sst(data, name, opts) {
|
|
|
|
|
return (name.substr(-4)===".bin" ? write_sst_bin : write_sst_xml)(data, opts);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
function write_cmnt(data, name, opts) {
|
|
|
|
|
return (name.substr(-4)===".bin" ? write_comments_bin : write_comments_xml)(data, opts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_cc(data, name, opts) {
|
|
|
|
|
return (name.substr(-4)===".bin" ? write_cc_bin : write_cc_xml)(data, opts);
|
|
|
|
|
}
|
|
|
|
|
*/
|
2014-01-28 16:38:02 +00:00
|
|
|
|
/* [MS-XLSB] 2.3 Record Enumeration */
|
|
|
|
|
var RecordEnum = {
|
|
|
|
|
0x0000: { n:"BrtRowHdr", f:parse_BrtRowHdr },
|
|
|
|
|
0x0001: { n:"BrtCellBlank", f:parse_BrtCellBlank },
|
|
|
|
|
0x0002: { n:"BrtCellRk", f:parse_BrtCellRk },
|
|
|
|
|
0x0003: { n:"BrtCellError", f:parse_BrtCellError },
|
|
|
|
|
0x0004: { n:"BrtCellBool", f:parse_BrtCellBool },
|
|
|
|
|
0x0005: { n:"BrtCellReal", f:parse_BrtCellReal },
|
|
|
|
|
0x0006: { n:"BrtCellSt", f:parse_BrtCellSt },
|
|
|
|
|
0x0007: { n:"BrtCellIsst", f:parse_BrtCellIsst },
|
|
|
|
|
0x0008: { n:"BrtFmlaString", f:parse_BrtFmlaString },
|
|
|
|
|
0x0009: { n:"BrtFmlaNum", f:parse_BrtFmlaNum },
|
|
|
|
|
0x000A: { n:"BrtFmlaBool", f:parse_BrtFmlaBool },
|
|
|
|
|
0x000B: { n:"BrtFmlaError", f:parse_BrtFmlaError },
|
2014-05-29 22:30:03 +00:00
|
|
|
|
0x0010: { n:"BrtFRTArchID$", f:parse_BrtFRTArchID$ },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0013: { n:"BrtSSTItem", f:parse_RichStr },
|
|
|
|
|
0x0014: { n:"BrtPCDIMissing", f:parsenoop },
|
|
|
|
|
0x0015: { n:"BrtPCDINumber", f:parsenoop },
|
|
|
|
|
0x0016: { n:"BrtPCDIBoolean", f:parsenoop },
|
|
|
|
|
0x0017: { n:"BrtPCDIError", f:parsenoop },
|
|
|
|
|
0x0018: { n:"BrtPCDIString", f:parsenoop },
|
|
|
|
|
0x0019: { n:"BrtPCDIDatetime", f:parsenoop },
|
|
|
|
|
0x001A: { n:"BrtPCDIIndex", f:parsenoop },
|
|
|
|
|
0x001B: { n:"BrtPCDIAMissing", f:parsenoop },
|
|
|
|
|
0x001C: { n:"BrtPCDIANumber", f:parsenoop },
|
|
|
|
|
0x001D: { n:"BrtPCDIABoolean", f:parsenoop },
|
|
|
|
|
0x001E: { n:"BrtPCDIAError", f:parsenoop },
|
|
|
|
|
0x001F: { n:"BrtPCDIAString", f:parsenoop },
|
|
|
|
|
0x0020: { n:"BrtPCDIADatetime", f:parsenoop },
|
|
|
|
|
0x0021: { n:"BrtPCRRecord", f:parsenoop },
|
|
|
|
|
0x0022: { n:"BrtPCRRecordDt", f:parsenoop },
|
|
|
|
|
0x0023: { n:"BrtFRTBegin", f:parsenoop },
|
|
|
|
|
0x0024: { n:"BrtFRTEnd", f:parsenoop },
|
|
|
|
|
0x0025: { n:"BrtACBegin", f:parsenoop },
|
|
|
|
|
0x0026: { n:"BrtACEnd", f:parsenoop },
|
|
|
|
|
0x0027: { n:"BrtName", f:parsenoop },
|
|
|
|
|
0x0028: { n:"BrtIndexRowBlock", f:parsenoop },
|
|
|
|
|
0x002A: { n:"BrtIndexBlock", f:parsenoop },
|
2014-03-29 02:05:50 +00:00
|
|
|
|
0x002B: { n:"BrtFont", f:parse_BrtFont },
|
2014-01-31 11:52:18 +00:00
|
|
|
|
0x002C: { n:"BrtFmt", f:parse_BrtFmt },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x002D: { n:"BrtFill", f:parsenoop },
|
|
|
|
|
0x002E: { n:"BrtBorder", f:parsenoop },
|
2014-01-31 11:52:18 +00:00
|
|
|
|
0x002F: { n:"BrtXF", f:parse_BrtXF },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0030: { n:"BrtStyle", f:parsenoop },
|
|
|
|
|
0x0031: { n:"BrtCellMeta", f:parsenoop },
|
|
|
|
|
0x0032: { n:"BrtValueMeta", f:parsenoop },
|
|
|
|
|
0x0033: { n:"BrtMdb", f:parsenoop },
|
|
|
|
|
0x0034: { n:"BrtBeginFmd", f:parsenoop },
|
|
|
|
|
0x0035: { n:"BrtEndFmd", f:parsenoop },
|
|
|
|
|
0x0036: { n:"BrtBeginMdx", f:parsenoop },
|
|
|
|
|
0x0037: { n:"BrtEndMdx", f:parsenoop },
|
|
|
|
|
0x0038: { n:"BrtBeginMdxTuple", f:parsenoop },
|
|
|
|
|
0x0039: { n:"BrtEndMdxTuple", f:parsenoop },
|
|
|
|
|
0x003A: { n:"BrtMdxMbrIstr", f:parsenoop },
|
|
|
|
|
0x003B: { n:"BrtStr", f:parsenoop },
|
|
|
|
|
0x003C: { n:"BrtColInfo", f:parsenoop },
|
|
|
|
|
0x003E: { n:"BrtCellRString", f:parsenoop },
|
2014-03-29 22:53:15 +00:00
|
|
|
|
0x003F: { n:"BrtCalcChainItem$", f:parse_BrtCalcChainItem$ },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0040: { n:"BrtDVal", f:parsenoop },
|
|
|
|
|
0x0041: { n:"BrtSxvcellNum", f:parsenoop },
|
|
|
|
|
0x0042: { n:"BrtSxvcellStr", f:parsenoop },
|
|
|
|
|
0x0043: { n:"BrtSxvcellBool", f:parsenoop },
|
|
|
|
|
0x0044: { n:"BrtSxvcellErr", f:parsenoop },
|
|
|
|
|
0x0045: { n:"BrtSxvcellDate", f:parsenoop },
|
|
|
|
|
0x0046: { n:"BrtSxvcellNil", f:parsenoop },
|
|
|
|
|
0x0080: { n:"BrtFileVersion", f:parsenoop },
|
|
|
|
|
0x0081: { n:"BrtBeginSheet", f:parsenoop },
|
|
|
|
|
0x0082: { n:"BrtEndSheet", f:parsenoop },
|
2014-05-29 22:30:03 +00:00
|
|
|
|
0x0083: { n:"BrtBeginBook", f:parsenoop, p:0 },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0084: { n:"BrtEndBook", f:parsenoop },
|
|
|
|
|
0x0085: { n:"BrtBeginWsViews", f:parsenoop },
|
|
|
|
|
0x0086: { n:"BrtEndWsViews", f:parsenoop },
|
|
|
|
|
0x0087: { n:"BrtBeginBookViews", f:parsenoop },
|
|
|
|
|
0x0088: { n:"BrtEndBookViews", f:parsenoop },
|
|
|
|
|
0x0089: { n:"BrtBeginWsView", f:parsenoop },
|
|
|
|
|
0x008A: { n:"BrtEndWsView", f:parsenoop },
|
|
|
|
|
0x008B: { n:"BrtBeginCsViews", f:parsenoop },
|
|
|
|
|
0x008C: { n:"BrtEndCsViews", f:parsenoop },
|
|
|
|
|
0x008D: { n:"BrtBeginCsView", f:parsenoop },
|
|
|
|
|
0x008E: { n:"BrtEndCsView", f:parsenoop },
|
|
|
|
|
0x008F: { n:"BrtBeginBundleShs", f:parsenoop },
|
|
|
|
|
0x0090: { n:"BrtEndBundleShs", f:parsenoop },
|
|
|
|
|
0x0091: { n:"BrtBeginSheetData", f:parsenoop },
|
|
|
|
|
0x0092: { n:"BrtEndSheetData", f:parsenoop },
|
|
|
|
|
0x0093: { n:"BrtWsProp", f:parse_BrtWsProp },
|
2014-05-29 22:30:03 +00:00
|
|
|
|
0x0094: { n:"BrtWsDim", f:parse_BrtWsDim, p:16 },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0097: { n:"BrtPane", f:parsenoop },
|
|
|
|
|
0x0098: { n:"BrtSel", f:parsenoop },
|
2014-05-29 22:30:03 +00:00
|
|
|
|
0x0099: { n:"BrtWbProp", f:parse_BrtWbProp },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x009A: { n:"BrtWbFactoid", f:parsenoop },
|
|
|
|
|
0x009B: { n:"BrtFileRecover", f:parsenoop },
|
|
|
|
|
0x009C: { n:"BrtBundleSh", f:parse_BrtBundleSh },
|
|
|
|
|
0x009D: { n:"BrtCalcProp", f:parsenoop },
|
|
|
|
|
0x009E: { n:"BrtBookView", f:parsenoop },
|
|
|
|
|
0x009F: { n:"BrtBeginSst", f:parse_BrtBeginSst },
|
|
|
|
|
0x00A0: { n:"BrtEndSst", f:parsenoop },
|
|
|
|
|
0x00A1: { n:"BrtBeginAFilter", f:parsenoop },
|
|
|
|
|
0x00A2: { n:"BrtEndAFilter", f:parsenoop },
|
|
|
|
|
0x00A3: { n:"BrtBeginFilterColumn", f:parsenoop },
|
|
|
|
|
0x00A4: { n:"BrtEndFilterColumn", f:parsenoop },
|
|
|
|
|
0x00A5: { n:"BrtBeginFilters", f:parsenoop },
|
|
|
|
|
0x00A6: { n:"BrtEndFilters", f:parsenoop },
|
|
|
|
|
0x00A7: { n:"BrtFilter", f:parsenoop },
|
|
|
|
|
0x00A8: { n:"BrtColorFilter", f:parsenoop },
|
|
|
|
|
0x00A9: { n:"BrtIconFilter", f:parsenoop },
|
|
|
|
|
0x00AA: { n:"BrtTop10Filter", f:parsenoop },
|
|
|
|
|
0x00AB: { n:"BrtDynamicFilter", f:parsenoop },
|
|
|
|
|
0x00AC: { n:"BrtBeginCustomFilters", f:parsenoop },
|
|
|
|
|
0x00AD: { n:"BrtEndCustomFilters", f:parsenoop },
|
|
|
|
|
0x00AE: { n:"BrtCustomFilter", f:parsenoop },
|
|
|
|
|
0x00AF: { n:"BrtAFilterDateGroupItem", f:parsenoop },
|
2014-03-23 21:30:00 +00:00
|
|
|
|
0x00B0: { n:"BrtMergeCell", f:parse_BrtMergeCell },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x00B1: { n:"BrtBeginMergeCells", f:parsenoop },
|
|
|
|
|
0x00B2: { n:"BrtEndMergeCells", f:parsenoop },
|
|
|
|
|
0x00B3: { n:"BrtBeginPivotCacheDef", f:parsenoop },
|
|
|
|
|
0x00B4: { n:"BrtEndPivotCacheDef", f:parsenoop },
|
|
|
|
|
0x00B5: { n:"BrtBeginPCDFields", f:parsenoop },
|
|
|
|
|
0x00B6: { n:"BrtEndPCDFields", f:parsenoop },
|
|
|
|
|
0x00B7: { n:"BrtBeginPCDField", f:parsenoop },
|
|
|
|
|
0x00B8: { n:"BrtEndPCDField", f:parsenoop },
|
|
|
|
|
0x00B9: { n:"BrtBeginPCDSource", f:parsenoop },
|
|
|
|
|
0x00BA: { n:"BrtEndPCDSource", f:parsenoop },
|
|
|
|
|
0x00BB: { n:"BrtBeginPCDSRange", f:parsenoop },
|
|
|
|
|
0x00BC: { n:"BrtEndPCDSRange", f:parsenoop },
|
|
|
|
|
0x00BD: { n:"BrtBeginPCDFAtbl", f:parsenoop },
|
|
|
|
|
0x00BE: { n:"BrtEndPCDFAtbl", f:parsenoop },
|
|
|
|
|
0x00BF: { n:"BrtBeginPCDIRun", f:parsenoop },
|
|
|
|
|
0x00C0: { n:"BrtEndPCDIRun", f:parsenoop },
|
|
|
|
|
0x00C1: { n:"BrtBeginPivotCacheRecords", f:parsenoop },
|
|
|
|
|
0x00C2: { n:"BrtEndPivotCacheRecords", f:parsenoop },
|
|
|
|
|
0x00C3: { n:"BrtBeginPCDHierarchies", f:parsenoop },
|
|
|
|
|
0x00C4: { n:"BrtEndPCDHierarchies", f:parsenoop },
|
|
|
|
|
0x00C5: { n:"BrtBeginPCDHierarchy", f:parsenoop },
|
|
|
|
|
0x00C6: { n:"BrtEndPCDHierarchy", f:parsenoop },
|
|
|
|
|
0x00C7: { n:"BrtBeginPCDHFieldsUsage", f:parsenoop },
|
|
|
|
|
0x00C8: { n:"BrtEndPCDHFieldsUsage", f:parsenoop },
|
|
|
|
|
0x00C9: { n:"BrtBeginExtConnection", f:parsenoop },
|
|
|
|
|
0x00CA: { n:"BrtEndExtConnection", f:parsenoop },
|
|
|
|
|
0x00CB: { n:"BrtBeginECDbProps", f:parsenoop },
|
|
|
|
|
0x00CC: { n:"BrtEndECDbProps", f:parsenoop },
|
|
|
|
|
0x00CD: { n:"BrtBeginECOlapProps", f:parsenoop },
|
|
|
|
|
0x00CE: { n:"BrtEndECOlapProps", f:parsenoop },
|
|
|
|
|
0x00CF: { n:"BrtBeginPCDSConsol", f:parsenoop },
|
|
|
|
|
0x00D0: { n:"BrtEndPCDSConsol", f:parsenoop },
|
|
|
|
|
0x00D1: { n:"BrtBeginPCDSCPages", f:parsenoop },
|
|
|
|
|
0x00D2: { n:"BrtEndPCDSCPages", f:parsenoop },
|
|
|
|
|
0x00D3: { n:"BrtBeginPCDSCPage", f:parsenoop },
|
|
|
|
|
0x00D4: { n:"BrtEndPCDSCPage", f:parsenoop },
|
|
|
|
|
0x00D5: { n:"BrtBeginPCDSCPItem", f:parsenoop },
|
|
|
|
|
0x00D6: { n:"BrtEndPCDSCPItem", f:parsenoop },
|
|
|
|
|
0x00D7: { n:"BrtBeginPCDSCSets", f:parsenoop },
|
|
|
|
|
0x00D8: { n:"BrtEndPCDSCSets", f:parsenoop },
|
|
|
|
|
0x00D9: { n:"BrtBeginPCDSCSet", f:parsenoop },
|
|
|
|
|
0x00DA: { n:"BrtEndPCDSCSet", f:parsenoop },
|
|
|
|
|
0x00DB: { n:"BrtBeginPCDFGroup", f:parsenoop },
|
|
|
|
|
0x00DC: { n:"BrtEndPCDFGroup", f:parsenoop },
|
|
|
|
|
0x00DD: { n:"BrtBeginPCDFGItems", f:parsenoop },
|
|
|
|
|
0x00DE: { n:"BrtEndPCDFGItems", f:parsenoop },
|
|
|
|
|
0x00DF: { n:"BrtBeginPCDFGRange", f:parsenoop },
|
|
|
|
|
0x00E0: { n:"BrtEndPCDFGRange", f:parsenoop },
|
|
|
|
|
0x00E1: { n:"BrtBeginPCDFGDiscrete", f:parsenoop },
|
|
|
|
|
0x00E2: { n:"BrtEndPCDFGDiscrete", f:parsenoop },
|
|
|
|
|
0x00E3: { n:"BrtBeginPCDSDTupleCache", f:parsenoop },
|
|
|
|
|
0x00E4: { n:"BrtEndPCDSDTupleCache", f:parsenoop },
|
|
|
|
|
0x00E5: { n:"BrtBeginPCDSDTCEntries", f:parsenoop },
|
|
|
|
|
0x00E6: { n:"BrtEndPCDSDTCEntries", f:parsenoop },
|
|
|
|
|
0x00E7: { n:"BrtBeginPCDSDTCEMembers", f:parsenoop },
|
|
|
|
|
0x00E8: { n:"BrtEndPCDSDTCEMembers", f:parsenoop },
|
|
|
|
|
0x00E9: { n:"BrtBeginPCDSDTCEMember", f:parsenoop },
|
|
|
|
|
0x00EA: { n:"BrtEndPCDSDTCEMember", f:parsenoop },
|
|
|
|
|
0x00EB: { n:"BrtBeginPCDSDTCQueries", f:parsenoop },
|
|
|
|
|
0x00EC: { n:"BrtEndPCDSDTCQueries", f:parsenoop },
|
|
|
|
|
0x00ED: { n:"BrtBeginPCDSDTCQuery", f:parsenoop },
|
|
|
|
|
0x00EE: { n:"BrtEndPCDSDTCQuery", f:parsenoop },
|
|
|
|
|
0x00EF: { n:"BrtBeginPCDSDTCSets", f:parsenoop },
|
|
|
|
|
0x00F0: { n:"BrtEndPCDSDTCSets", f:parsenoop },
|
|
|
|
|
0x00F1: { n:"BrtBeginPCDSDTCSet", f:parsenoop },
|
|
|
|
|
0x00F2: { n:"BrtEndPCDSDTCSet", f:parsenoop },
|
|
|
|
|
0x00F3: { n:"BrtBeginPCDCalcItems", f:parsenoop },
|
|
|
|
|
0x00F4: { n:"BrtEndPCDCalcItems", f:parsenoop },
|
|
|
|
|
0x00F5: { n:"BrtBeginPCDCalcItem", f:parsenoop },
|
|
|
|
|
0x00F6: { n:"BrtEndPCDCalcItem", f:parsenoop },
|
|
|
|
|
0x00F7: { n:"BrtBeginPRule", f:parsenoop },
|
|
|
|
|
0x00F8: { n:"BrtEndPRule", f:parsenoop },
|
|
|
|
|
0x00F9: { n:"BrtBeginPRFilters", f:parsenoop },
|
|
|
|
|
0x00FA: { n:"BrtEndPRFilters", f:parsenoop },
|
|
|
|
|
0x00FB: { n:"BrtBeginPRFilter", f:parsenoop },
|
|
|
|
|
0x00FC: { n:"BrtEndPRFilter", f:parsenoop },
|
|
|
|
|
0x00FD: { n:"BrtBeginPNames", f:parsenoop },
|
|
|
|
|
0x00FE: { n:"BrtEndPNames", f:parsenoop },
|
|
|
|
|
0x00FF: { n:"BrtBeginPName", f:parsenoop },
|
|
|
|
|
0x0100: { n:"BrtEndPName", f:parsenoop },
|
|
|
|
|
0x0101: { n:"BrtBeginPNPairs", f:parsenoop },
|
|
|
|
|
0x0102: { n:"BrtEndPNPairs", f:parsenoop },
|
|
|
|
|
0x0103: { n:"BrtBeginPNPair", f:parsenoop },
|
|
|
|
|
0x0104: { n:"BrtEndPNPair", f:parsenoop },
|
|
|
|
|
0x0105: { n:"BrtBeginECWebProps", f:parsenoop },
|
|
|
|
|
0x0106: { n:"BrtEndECWebProps", f:parsenoop },
|
|
|
|
|
0x0107: { n:"BrtBeginEcWpTables", f:parsenoop },
|
|
|
|
|
0x0108: { n:"BrtEndECWPTables", f:parsenoop },
|
|
|
|
|
0x0109: { n:"BrtBeginECParams", f:parsenoop },
|
|
|
|
|
0x010A: { n:"BrtEndECParams", f:parsenoop },
|
|
|
|
|
0x010B: { n:"BrtBeginECParam", f:parsenoop },
|
|
|
|
|
0x010C: { n:"BrtEndECParam", f:parsenoop },
|
|
|
|
|
0x010D: { n:"BrtBeginPCDKPIs", f:parsenoop },
|
|
|
|
|
0x010E: { n:"BrtEndPCDKPIs", f:parsenoop },
|
|
|
|
|
0x010F: { n:"BrtBeginPCDKPI", f:parsenoop },
|
|
|
|
|
0x0110: { n:"BrtEndPCDKPI", f:parsenoop },
|
|
|
|
|
0x0111: { n:"BrtBeginDims", f:parsenoop },
|
|
|
|
|
0x0112: { n:"BrtEndDims", f:parsenoop },
|
|
|
|
|
0x0113: { n:"BrtBeginDim", f:parsenoop },
|
|
|
|
|
0x0114: { n:"BrtEndDim", f:parsenoop },
|
|
|
|
|
0x0115: { n:"BrtIndexPartEnd", f:parsenoop },
|
|
|
|
|
0x0116: { n:"BrtBeginStyleSheet", f:parsenoop },
|
|
|
|
|
0x0117: { n:"BrtEndStyleSheet", f:parsenoop },
|
|
|
|
|
0x0118: { n:"BrtBeginSXView", f:parsenoop },
|
|
|
|
|
0x0119: { n:"BrtEndSXVI", f:parsenoop },
|
|
|
|
|
0x011A: { n:"BrtBeginSXVI", f:parsenoop },
|
|
|
|
|
0x011B: { n:"BrtBeginSXVIs", f:parsenoop },
|
|
|
|
|
0x011C: { n:"BrtEndSXVIs", f:parsenoop },
|
|
|
|
|
0x011D: { n:"BrtBeginSXVD", f:parsenoop },
|
|
|
|
|
0x011E: { n:"BrtEndSXVD", f:parsenoop },
|
|
|
|
|
0x011F: { n:"BrtBeginSXVDs", f:parsenoop },
|
|
|
|
|
0x0120: { n:"BrtEndSXVDs", f:parsenoop },
|
|
|
|
|
0x0121: { n:"BrtBeginSXPI", f:parsenoop },
|
|
|
|
|
0x0122: { n:"BrtEndSXPI", f:parsenoop },
|
|
|
|
|
0x0123: { n:"BrtBeginSXPIs", f:parsenoop },
|
|
|
|
|
0x0124: { n:"BrtEndSXPIs", f:parsenoop },
|
|
|
|
|
0x0125: { n:"BrtBeginSXDI", f:parsenoop },
|
|
|
|
|
0x0126: { n:"BrtEndSXDI", f:parsenoop },
|
|
|
|
|
0x0127: { n:"BrtBeginSXDIs", f:parsenoop },
|
|
|
|
|
0x0128: { n:"BrtEndSXDIs", f:parsenoop },
|
|
|
|
|
0x0129: { n:"BrtBeginSXLI", f:parsenoop },
|
|
|
|
|
0x012A: { n:"BrtEndSXLI", f:parsenoop },
|
|
|
|
|
0x012B: { n:"BrtBeginSXLIRws", f:parsenoop },
|
|
|
|
|
0x012C: { n:"BrtEndSXLIRws", f:parsenoop },
|
|
|
|
|
0x012D: { n:"BrtBeginSXLICols", f:parsenoop },
|
|
|
|
|
0x012E: { n:"BrtEndSXLICols", f:parsenoop },
|
|
|
|
|
0x012F: { n:"BrtBeginSXFormat", f:parsenoop },
|
|
|
|
|
0x0130: { n:"BrtEndSXFormat", f:parsenoop },
|
|
|
|
|
0x0131: { n:"BrtBeginSXFormats", f:parsenoop },
|
|
|
|
|
0x0132: { n:"BrtEndSxFormats", f:parsenoop },
|
|
|
|
|
0x0133: { n:"BrtBeginSxSelect", f:parsenoop },
|
|
|
|
|
0x0134: { n:"BrtEndSxSelect", f:parsenoop },
|
|
|
|
|
0x0135: { n:"BrtBeginISXVDRws", f:parsenoop },
|
|
|
|
|
0x0136: { n:"BrtEndISXVDRws", f:parsenoop },
|
|
|
|
|
0x0137: { n:"BrtBeginISXVDCols", f:parsenoop },
|
|
|
|
|
0x0138: { n:"BrtEndISXVDCols", f:parsenoop },
|
|
|
|
|
0x0139: { n:"BrtEndSXLocation", f:parsenoop },
|
|
|
|
|
0x013A: { n:"BrtBeginSXLocation", f:parsenoop },
|
|
|
|
|
0x013B: { n:"BrtEndSXView", f:parsenoop },
|
|
|
|
|
0x013C: { n:"BrtBeginSXTHs", f:parsenoop },
|
|
|
|
|
0x013D: { n:"BrtEndSXTHs", f:parsenoop },
|
|
|
|
|
0x013E: { n:"BrtBeginSXTH", f:parsenoop },
|
|
|
|
|
0x013F: { n:"BrtEndSXTH", f:parsenoop },
|
|
|
|
|
0x0140: { n:"BrtBeginISXTHRws", f:parsenoop },
|
|
|
|
|
0x0141: { n:"BrtEndISXTHRws", f:parsenoop },
|
|
|
|
|
0x0142: { n:"BrtBeginISXTHCols", f:parsenoop },
|
|
|
|
|
0x0143: { n:"BrtEndISXTHCols", f:parsenoop },
|
|
|
|
|
0x0144: { n:"BrtBeginSXTDMPS", f:parsenoop },
|
|
|
|
|
0x0145: { n:"BrtEndSXTDMPs", f:parsenoop },
|
|
|
|
|
0x0146: { n:"BrtBeginSXTDMP", f:parsenoop },
|
|
|
|
|
0x0147: { n:"BrtEndSXTDMP", f:parsenoop },
|
|
|
|
|
0x0148: { n:"BrtBeginSXTHItems", f:parsenoop },
|
|
|
|
|
0x0149: { n:"BrtEndSXTHItems", f:parsenoop },
|
|
|
|
|
0x014A: { n:"BrtBeginSXTHItem", f:parsenoop },
|
|
|
|
|
0x014B: { n:"BrtEndSXTHItem", f:parsenoop },
|
|
|
|
|
0x014C: { n:"BrtBeginMetadata", f:parsenoop },
|
|
|
|
|
0x014D: { n:"BrtEndMetadata", f:parsenoop },
|
|
|
|
|
0x014E: { n:"BrtBeginEsmdtinfo", f:parsenoop },
|
|
|
|
|
0x014F: { n:"BrtMdtinfo", f:parsenoop },
|
|
|
|
|
0x0150: { n:"BrtEndEsmdtinfo", f:parsenoop },
|
|
|
|
|
0x0151: { n:"BrtBeginEsmdb", f:parsenoop },
|
|
|
|
|
0x0152: { n:"BrtEndEsmdb", f:parsenoop },
|
|
|
|
|
0x0153: { n:"BrtBeginEsfmd", f:parsenoop },
|
|
|
|
|
0x0154: { n:"BrtEndEsfmd", f:parsenoop },
|
|
|
|
|
0x0155: { n:"BrtBeginSingleCells", f:parsenoop },
|
|
|
|
|
0x0156: { n:"BrtEndSingleCells", f:parsenoop },
|
|
|
|
|
0x0157: { n:"BrtBeginList", f:parsenoop },
|
|
|
|
|
0x0158: { n:"BrtEndList", f:parsenoop },
|
|
|
|
|
0x0159: { n:"BrtBeginListCols", f:parsenoop },
|
|
|
|
|
0x015A: { n:"BrtEndListCols", f:parsenoop },
|
|
|
|
|
0x015B: { n:"BrtBeginListCol", f:parsenoop },
|
|
|
|
|
0x015C: { n:"BrtEndListCol", f:parsenoop },
|
|
|
|
|
0x015D: { n:"BrtBeginListXmlCPr", f:parsenoop },
|
|
|
|
|
0x015E: { n:"BrtEndListXmlCPr", f:parsenoop },
|
|
|
|
|
0x015F: { n:"BrtListCCFmla", f:parsenoop },
|
|
|
|
|
0x0160: { n:"BrtListTrFmla", f:parsenoop },
|
|
|
|
|
0x0161: { n:"BrtBeginExternals", f:parsenoop },
|
|
|
|
|
0x0162: { n:"BrtEndExternals", f:parsenoop },
|
|
|
|
|
0x0163: { n:"BrtSupBookSrc", f:parsenoop },
|
|
|
|
|
0x0165: { n:"BrtSupSelf", f:parsenoop },
|
|
|
|
|
0x0166: { n:"BrtSupSame", f:parsenoop },
|
|
|
|
|
0x0167: { n:"BrtSupTabs", f:parsenoop },
|
|
|
|
|
0x0168: { n:"BrtBeginSupBook", f:parsenoop },
|
|
|
|
|
0x0169: { n:"BrtPlaceholderName", f:parsenoop },
|
|
|
|
|
0x016A: { n:"BrtExternSheet", f:parsenoop },
|
|
|
|
|
0x016B: { n:"BrtExternTableStart", f:parsenoop },
|
|
|
|
|
0x016C: { n:"BrtExternTableEnd", f:parsenoop },
|
|
|
|
|
0x016E: { n:"BrtExternRowHdr", f:parsenoop },
|
|
|
|
|
0x016F: { n:"BrtExternCellBlank", f:parsenoop },
|
|
|
|
|
0x0170: { n:"BrtExternCellReal", f:parsenoop },
|
|
|
|
|
0x0171: { n:"BrtExternCellBool", f:parsenoop },
|
|
|
|
|
0x0172: { n:"BrtExternCellError", f:parsenoop },
|
|
|
|
|
0x0173: { n:"BrtExternCellString", f:parsenoop },
|
|
|
|
|
0x0174: { n:"BrtBeginEsmdx", f:parsenoop },
|
|
|
|
|
0x0175: { n:"BrtEndEsmdx", f:parsenoop },
|
|
|
|
|
0x0176: { n:"BrtBeginMdxSet", f:parsenoop },
|
|
|
|
|
0x0177: { n:"BrtEndMdxSet", f:parsenoop },
|
|
|
|
|
0x0178: { n:"BrtBeginMdxMbrProp", f:parsenoop },
|
|
|
|
|
0x0179: { n:"BrtEndMdxMbrProp", f:parsenoop },
|
|
|
|
|
0x017A: { n:"BrtBeginMdxKPI", f:parsenoop },
|
|
|
|
|
0x017B: { n:"BrtEndMdxKPI", f:parsenoop },
|
|
|
|
|
0x017C: { n:"BrtBeginEsstr", f:parsenoop },
|
|
|
|
|
0x017D: { n:"BrtEndEsstr", f:parsenoop },
|
|
|
|
|
0x017E: { n:"BrtBeginPRFItem", f:parsenoop },
|
|
|
|
|
0x017F: { n:"BrtEndPRFItem", f:parsenoop },
|
|
|
|
|
0x0180: { n:"BrtBeginPivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x0181: { n:"BrtEndPivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x0182: { n:"BrtBeginPivotCacheID", f:parsenoop },
|
|
|
|
|
0x0183: { n:"BrtEndPivotCacheID", f:parsenoop },
|
|
|
|
|
0x0184: { n:"BrtBeginISXVIs", f:parsenoop },
|
|
|
|
|
0x0185: { n:"BrtEndISXVIs", f:parsenoop },
|
|
|
|
|
0x0186: { n:"BrtBeginColInfos", f:parsenoop },
|
|
|
|
|
0x0187: { n:"BrtEndColInfos", f:parsenoop },
|
|
|
|
|
0x0188: { n:"BrtBeginRwBrk", f:parsenoop },
|
|
|
|
|
0x0189: { n:"BrtEndRwBrk", f:parsenoop },
|
|
|
|
|
0x018A: { n:"BrtBeginColBrk", f:parsenoop },
|
|
|
|
|
0x018B: { n:"BrtEndColBrk", f:parsenoop },
|
|
|
|
|
0x018C: { n:"BrtBrk", f:parsenoop },
|
|
|
|
|
0x018D: { n:"BrtUserBookView", f:parsenoop },
|
|
|
|
|
0x018E: { n:"BrtInfo", f:parsenoop },
|
|
|
|
|
0x018F: { n:"BrtCUsr", f:parsenoop },
|
|
|
|
|
0x0190: { n:"BrtUsr", f:parsenoop },
|
|
|
|
|
0x0191: { n:"BrtBeginUsers", f:parsenoop },
|
|
|
|
|
0x0193: { n:"BrtEOF", f:parsenoop },
|
|
|
|
|
0x0194: { n:"BrtUCR", f:parsenoop },
|
|
|
|
|
0x0195: { n:"BrtRRInsDel", f:parsenoop },
|
|
|
|
|
0x0196: { n:"BrtRREndInsDel", f:parsenoop },
|
|
|
|
|
0x0197: { n:"BrtRRMove", f:parsenoop },
|
|
|
|
|
0x0198: { n:"BrtRREndMove", f:parsenoop },
|
|
|
|
|
0x0199: { n:"BrtRRChgCell", f:parsenoop },
|
|
|
|
|
0x019A: { n:"BrtRREndChgCell", f:parsenoop },
|
|
|
|
|
0x019B: { n:"BrtRRHeader", f:parsenoop },
|
|
|
|
|
0x019C: { n:"BrtRRUserView", f:parsenoop },
|
|
|
|
|
0x019D: { n:"BrtRRRenSheet", f:parsenoop },
|
|
|
|
|
0x019E: { n:"BrtRRInsertSh", f:parsenoop },
|
|
|
|
|
0x019F: { n:"BrtRRDefName", f:parsenoop },
|
|
|
|
|
0x01A0: { n:"BrtRRNote", f:parsenoop },
|
|
|
|
|
0x01A1: { n:"BrtRRConflict", f:parsenoop },
|
|
|
|
|
0x01A2: { n:"BrtRRTQSIF", f:parsenoop },
|
|
|
|
|
0x01A3: { n:"BrtRRFormat", f:parsenoop },
|
|
|
|
|
0x01A4: { n:"BrtRREndFormat", f:parsenoop },
|
|
|
|
|
0x01A5: { n:"BrtRRAutoFmt", f:parsenoop },
|
|
|
|
|
0x01A6: { n:"BrtBeginUserShViews", f:parsenoop },
|
|
|
|
|
0x01A7: { n:"BrtBeginUserShView", f:parsenoop },
|
|
|
|
|
0x01A8: { n:"BrtEndUserShView", f:parsenoop },
|
|
|
|
|
0x01A9: { n:"BrtEndUserShViews", f:parsenoop },
|
|
|
|
|
0x01AA: { n:"BrtArrFmla", f:parsenoop },
|
|
|
|
|
0x01AB: { n:"BrtShrFmla", f:parsenoop },
|
|
|
|
|
0x01AC: { n:"BrtTable", f:parsenoop },
|
|
|
|
|
0x01AD: { n:"BrtBeginExtConnections", f:parsenoop },
|
|
|
|
|
0x01AE: { n:"BrtEndExtConnections", f:parsenoop },
|
|
|
|
|
0x01AF: { n:"BrtBeginPCDCalcMems", f:parsenoop },
|
|
|
|
|
0x01B0: { n:"BrtEndPCDCalcMems", f:parsenoop },
|
|
|
|
|
0x01B1: { n:"BrtBeginPCDCalcMem", f:parsenoop },
|
|
|
|
|
0x01B2: { n:"BrtEndPCDCalcMem", f:parsenoop },
|
|
|
|
|
0x01B3: { n:"BrtBeginPCDHGLevels", f:parsenoop },
|
|
|
|
|
0x01B4: { n:"BrtEndPCDHGLevels", f:parsenoop },
|
|
|
|
|
0x01B5: { n:"BrtBeginPCDHGLevel", f:parsenoop },
|
|
|
|
|
0x01B6: { n:"BrtEndPCDHGLevel", f:parsenoop },
|
|
|
|
|
0x01B7: { n:"BrtBeginPCDHGLGroups", f:parsenoop },
|
|
|
|
|
0x01B8: { n:"BrtEndPCDHGLGroups", f:parsenoop },
|
|
|
|
|
0x01B9: { n:"BrtBeginPCDHGLGroup", f:parsenoop },
|
|
|
|
|
0x01BA: { n:"BrtEndPCDHGLGroup", f:parsenoop },
|
|
|
|
|
0x01BB: { n:"BrtBeginPCDHGLGMembers", f:parsenoop },
|
|
|
|
|
0x01BC: { n:"BrtEndPCDHGLGMembers", f:parsenoop },
|
|
|
|
|
0x01BD: { n:"BrtBeginPCDHGLGMember", f:parsenoop },
|
|
|
|
|
0x01BE: { n:"BrtEndPCDHGLGMember", f:parsenoop },
|
|
|
|
|
0x01BF: { n:"BrtBeginQSI", f:parsenoop },
|
|
|
|
|
0x01C0: { n:"BrtEndQSI", f:parsenoop },
|
|
|
|
|
0x01C1: { n:"BrtBeginQSIR", f:parsenoop },
|
|
|
|
|
0x01C2: { n:"BrtEndQSIR", f:parsenoop },
|
|
|
|
|
0x01C3: { n:"BrtBeginDeletedNames", f:parsenoop },
|
|
|
|
|
0x01C4: { n:"BrtEndDeletedNames", f:parsenoop },
|
|
|
|
|
0x01C5: { n:"BrtBeginDeletedName", f:parsenoop },
|
|
|
|
|
0x01C6: { n:"BrtEndDeletedName", f:parsenoop },
|
|
|
|
|
0x01C7: { n:"BrtBeginQSIFs", f:parsenoop },
|
|
|
|
|
0x01C8: { n:"BrtEndQSIFs", f:parsenoop },
|
|
|
|
|
0x01C9: { n:"BrtBeginQSIF", f:parsenoop },
|
|
|
|
|
0x01CA: { n:"BrtEndQSIF", f:parsenoop },
|
|
|
|
|
0x01CB: { n:"BrtBeginAutoSortScope", f:parsenoop },
|
|
|
|
|
0x01CC: { n:"BrtEndAutoSortScope", f:parsenoop },
|
|
|
|
|
0x01CD: { n:"BrtBeginConditionalFormatting", f:parsenoop },
|
|
|
|
|
0x01CE: { n:"BrtEndConditionalFormatting", f:parsenoop },
|
|
|
|
|
0x01CF: { n:"BrtBeginCFRule", f:parsenoop },
|
|
|
|
|
0x01D0: { n:"BrtEndCFRule", f:parsenoop },
|
|
|
|
|
0x01D1: { n:"BrtBeginIconSet", f:parsenoop },
|
|
|
|
|
0x01D2: { n:"BrtEndIconSet", f:parsenoop },
|
|
|
|
|
0x01D3: { n:"BrtBeginDatabar", f:parsenoop },
|
|
|
|
|
0x01D4: { n:"BrtEndDatabar", f:parsenoop },
|
|
|
|
|
0x01D5: { n:"BrtBeginColorScale", f:parsenoop },
|
|
|
|
|
0x01D6: { n:"BrtEndColorScale", f:parsenoop },
|
|
|
|
|
0x01D7: { n:"BrtCFVO", f:parsenoop },
|
|
|
|
|
0x01D8: { n:"BrtExternValueMeta", f:parsenoop },
|
|
|
|
|
0x01D9: { n:"BrtBeginColorPalette", f:parsenoop },
|
|
|
|
|
0x01DA: { n:"BrtEndColorPalette", f:parsenoop },
|
|
|
|
|
0x01DB: { n:"BrtIndexedColor", f:parsenoop },
|
|
|
|
|
0x01DC: { n:"BrtMargins", f:parsenoop },
|
|
|
|
|
0x01DD: { n:"BrtPrintOptions", f:parsenoop },
|
|
|
|
|
0x01DE: { n:"BrtPageSetup", f:parsenoop },
|
|
|
|
|
0x01DF: { n:"BrtBeginHeaderFooter", f:parsenoop },
|
|
|
|
|
0x01E0: { n:"BrtEndHeaderFooter", f:parsenoop },
|
|
|
|
|
0x01E1: { n:"BrtBeginSXCrtFormat", f:parsenoop },
|
|
|
|
|
0x01E2: { n:"BrtEndSXCrtFormat", f:parsenoop },
|
|
|
|
|
0x01E3: { n:"BrtBeginSXCrtFormats", f:parsenoop },
|
|
|
|
|
0x01E4: { n:"BrtEndSXCrtFormats", f:parsenoop },
|
|
|
|
|
0x01E5: { n:"BrtWsFmtInfo", f:parsenoop },
|
|
|
|
|
0x01E6: { n:"BrtBeginMgs", f:parsenoop },
|
|
|
|
|
0x01E7: { n:"BrtEndMGs", f:parsenoop },
|
|
|
|
|
0x01E8: { n:"BrtBeginMGMaps", f:parsenoop },
|
|
|
|
|
0x01E9: { n:"BrtEndMGMaps", f:parsenoop },
|
|
|
|
|
0x01EA: { n:"BrtBeginMG", f:parsenoop },
|
|
|
|
|
0x01EB: { n:"BrtEndMG", f:parsenoop },
|
|
|
|
|
0x01EC: { n:"BrtBeginMap", f:parsenoop },
|
|
|
|
|
0x01ED: { n:"BrtEndMap", f:parsenoop },
|
2014-04-15 09:04:03 +00:00
|
|
|
|
0x01EE: { n:"BrtHLink", f:parse_BrtHLink },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x01EF: { n:"BrtBeginDCon", f:parsenoop },
|
|
|
|
|
0x01F0: { n:"BrtEndDCon", f:parsenoop },
|
|
|
|
|
0x01F1: { n:"BrtBeginDRefs", f:parsenoop },
|
|
|
|
|
0x01F2: { n:"BrtEndDRefs", f:parsenoop },
|
|
|
|
|
0x01F3: { n:"BrtDRef", f:parsenoop },
|
|
|
|
|
0x01F4: { n:"BrtBeginScenMan", f:parsenoop },
|
|
|
|
|
0x01F5: { n:"BrtEndScenMan", f:parsenoop },
|
|
|
|
|
0x01F6: { n:"BrtBeginSct", f:parsenoop },
|
|
|
|
|
0x01F7: { n:"BrtEndSct", f:parsenoop },
|
|
|
|
|
0x01F8: { n:"BrtSlc", f:parsenoop },
|
|
|
|
|
0x01F9: { n:"BrtBeginDXFs", f:parsenoop },
|
|
|
|
|
0x01FA: { n:"BrtEndDXFs", f:parsenoop },
|
|
|
|
|
0x01FB: { n:"BrtDXF", f:parsenoop },
|
|
|
|
|
0x01FC: { n:"BrtBeginTableStyles", f:parsenoop },
|
|
|
|
|
0x01FD: { n:"BrtEndTableStyles", f:parsenoop },
|
|
|
|
|
0x01FE: { n:"BrtBeginTableStyle", f:parsenoop },
|
|
|
|
|
0x01FF: { n:"BrtEndTableStyle", f:parsenoop },
|
|
|
|
|
0x0200: { n:"BrtTableStyleElement", f:parsenoop },
|
|
|
|
|
0x0201: { n:"BrtTableStyleClient", f:parsenoop },
|
|
|
|
|
0x0202: { n:"BrtBeginVolDeps", f:parsenoop },
|
|
|
|
|
0x0203: { n:"BrtEndVolDeps", f:parsenoop },
|
|
|
|
|
0x0204: { n:"BrtBeginVolType", f:parsenoop },
|
|
|
|
|
0x0205: { n:"BrtEndVolType", f:parsenoop },
|
|
|
|
|
0x0206: { n:"BrtBeginVolMain", f:parsenoop },
|
|
|
|
|
0x0207: { n:"BrtEndVolMain", f:parsenoop },
|
|
|
|
|
0x0208: { n:"BrtBeginVolTopic", f:parsenoop },
|
|
|
|
|
0x0209: { n:"BrtEndVolTopic", f:parsenoop },
|
|
|
|
|
0x020A: { n:"BrtVolSubtopic", f:parsenoop },
|
|
|
|
|
0x020B: { n:"BrtVolRef", f:parsenoop },
|
|
|
|
|
0x020C: { n:"BrtVolNum", f:parsenoop },
|
|
|
|
|
0x020D: { n:"BrtVolErr", f:parsenoop },
|
|
|
|
|
0x020E: { n:"BrtVolStr", f:parsenoop },
|
|
|
|
|
0x020F: { n:"BrtVolBool", f:parsenoop },
|
2014-03-29 22:53:15 +00:00
|
|
|
|
0x0210: { n:"BrtBeginCalcChain$", f:parsenoop },
|
|
|
|
|
0x0211: { n:"BrtEndCalcChain$", f:parsenoop },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0212: { n:"BrtBeginSortState", f:parsenoop },
|
|
|
|
|
0x0213: { n:"BrtEndSortState", f:parsenoop },
|
|
|
|
|
0x0214: { n:"BrtBeginSortCond", f:parsenoop },
|
|
|
|
|
0x0215: { n:"BrtEndSortCond", f:parsenoop },
|
|
|
|
|
0x0216: { n:"BrtBookProtection", f:parsenoop },
|
|
|
|
|
0x0217: { n:"BrtSheetProtection", f:parsenoop },
|
|
|
|
|
0x0218: { n:"BrtRangeProtection", f:parsenoop },
|
|
|
|
|
0x0219: { n:"BrtPhoneticInfo", f:parsenoop },
|
|
|
|
|
0x021A: { n:"BrtBeginECTxtWiz", f:parsenoop },
|
|
|
|
|
0x021B: { n:"BrtEndECTxtWiz", f:parsenoop },
|
|
|
|
|
0x021C: { n:"BrtBeginECTWFldInfoLst", f:parsenoop },
|
|
|
|
|
0x021D: { n:"BrtEndECTWFldInfoLst", f:parsenoop },
|
|
|
|
|
0x021E: { n:"BrtBeginECTwFldInfo", f:parsenoop },
|
|
|
|
|
0x0224: { n:"BrtFileSharing", f:parsenoop },
|
|
|
|
|
0x0225: { n:"BrtOleSize", f:parsenoop },
|
|
|
|
|
0x0226: { n:"BrtDrawing", f:parsenoop },
|
|
|
|
|
0x0227: { n:"BrtLegacyDrawing", f:parsenoop },
|
|
|
|
|
0x0228: { n:"BrtLegacyDrawingHF", f:parsenoop },
|
|
|
|
|
0x0229: { n:"BrtWebOpt", f:parsenoop },
|
|
|
|
|
0x022A: { n:"BrtBeginWebPubItems", f:parsenoop },
|
|
|
|
|
0x022B: { n:"BrtEndWebPubItems", f:parsenoop },
|
|
|
|
|
0x022C: { n:"BrtBeginWebPubItem", f:parsenoop },
|
|
|
|
|
0x022D: { n:"BrtEndWebPubItem", f:parsenoop },
|
|
|
|
|
0x022E: { n:"BrtBeginSXCondFmt", f:parsenoop },
|
|
|
|
|
0x022F: { n:"BrtEndSXCondFmt", f:parsenoop },
|
|
|
|
|
0x0230: { n:"BrtBeginSXCondFmts", f:parsenoop },
|
|
|
|
|
0x0231: { n:"BrtEndSXCondFmts", f:parsenoop },
|
|
|
|
|
0x0232: { n:"BrtBkHim", f:parsenoop },
|
|
|
|
|
0x0234: { n:"BrtColor", f:parsenoop },
|
|
|
|
|
0x0235: { n:"BrtBeginIndexedColors", f:parsenoop },
|
|
|
|
|
0x0236: { n:"BrtEndIndexedColors", f:parsenoop },
|
|
|
|
|
0x0239: { n:"BrtBeginMRUColors", f:parsenoop },
|
|
|
|
|
0x023A: { n:"BrtEndMRUColors", f:parsenoop },
|
|
|
|
|
0x023C: { n:"BrtMRUColor", f:parsenoop },
|
|
|
|
|
0x023D: { n:"BrtBeginDVals", f:parsenoop },
|
|
|
|
|
0x023E: { n:"BrtEndDVals", f:parsenoop },
|
|
|
|
|
0x0241: { n:"BrtSupNameStart", f:parsenoop },
|
|
|
|
|
0x0242: { n:"BrtSupNameValueStart", f:parsenoop },
|
|
|
|
|
0x0243: { n:"BrtSupNameValueEnd", f:parsenoop },
|
|
|
|
|
0x0244: { n:"BrtSupNameNum", f:parsenoop },
|
|
|
|
|
0x0245: { n:"BrtSupNameErr", f:parsenoop },
|
|
|
|
|
0x0246: { n:"BrtSupNameSt", f:parsenoop },
|
|
|
|
|
0x0247: { n:"BrtSupNameNil", f:parsenoop },
|
|
|
|
|
0x0248: { n:"BrtSupNameBool", f:parsenoop },
|
|
|
|
|
0x0249: { n:"BrtSupNameFmla", f:parsenoop },
|
|
|
|
|
0x024A: { n:"BrtSupNameBits", f:parsenoop },
|
|
|
|
|
0x024B: { n:"BrtSupNameEnd", f:parsenoop },
|
|
|
|
|
0x024C: { n:"BrtEndSupBook", f:parsenoop },
|
|
|
|
|
0x024D: { n:"BrtCellSmartTagProperty", f:parsenoop },
|
|
|
|
|
0x024E: { n:"BrtBeginCellSmartTag", f:parsenoop },
|
|
|
|
|
0x024F: { n:"BrtEndCellSmartTag", f:parsenoop },
|
|
|
|
|
0x0250: { n:"BrtBeginCellSmartTags", f:parsenoop },
|
|
|
|
|
0x0251: { n:"BrtEndCellSmartTags", f:parsenoop },
|
|
|
|
|
0x0252: { n:"BrtBeginSmartTags", f:parsenoop },
|
|
|
|
|
0x0253: { n:"BrtEndSmartTags", f:parsenoop },
|
|
|
|
|
0x0254: { n:"BrtSmartTagType", f:parsenoop },
|
|
|
|
|
0x0255: { n:"BrtBeginSmartTagTypes", f:parsenoop },
|
|
|
|
|
0x0256: { n:"BrtEndSmartTagTypes", f:parsenoop },
|
|
|
|
|
0x0257: { n:"BrtBeginSXFilters", f:parsenoop },
|
|
|
|
|
0x0258: { n:"BrtEndSXFilters", f:parsenoop },
|
|
|
|
|
0x0259: { n:"BrtBeginSXFILTER", f:parsenoop },
|
|
|
|
|
0x025A: { n:"BrtEndSXFilter", f:parsenoop },
|
|
|
|
|
0x025B: { n:"BrtBeginFills", f:parsenoop },
|
|
|
|
|
0x025C: { n:"BrtEndFills", f:parsenoop },
|
|
|
|
|
0x025D: { n:"BrtBeginCellWatches", f:parsenoop },
|
|
|
|
|
0x025E: { n:"BrtEndCellWatches", f:parsenoop },
|
|
|
|
|
0x025F: { n:"BrtCellWatch", f:parsenoop },
|
|
|
|
|
0x0260: { n:"BrtBeginCRErrs", f:parsenoop },
|
|
|
|
|
0x0261: { n:"BrtEndCRErrs", f:parsenoop },
|
|
|
|
|
0x0262: { n:"BrtCrashRecErr", f:parsenoop },
|
|
|
|
|
0x0263: { n:"BrtBeginFonts", f:parsenoop },
|
|
|
|
|
0x0264: { n:"BrtEndFonts", f:parsenoop },
|
|
|
|
|
0x0265: { n:"BrtBeginBorders", f:parsenoop },
|
|
|
|
|
0x0266: { n:"BrtEndBorders", f:parsenoop },
|
|
|
|
|
0x0267: { n:"BrtBeginFmts", f:parsenoop },
|
|
|
|
|
0x0268: { n:"BrtEndFmts", f:parsenoop },
|
|
|
|
|
0x0269: { n:"BrtBeginCellXFs", f:parsenoop },
|
|
|
|
|
0x026A: { n:"BrtEndCellXFs", f:parsenoop },
|
|
|
|
|
0x026B: { n:"BrtBeginStyles", f:parsenoop },
|
|
|
|
|
0x026C: { n:"BrtEndStyles", f:parsenoop },
|
|
|
|
|
0x0271: { n:"BrtBigName", f:parsenoop },
|
|
|
|
|
0x0272: { n:"BrtBeginCellStyleXFs", f:parsenoop },
|
|
|
|
|
0x0273: { n:"BrtEndCellStyleXFs", f:parsenoop },
|
|
|
|
|
0x0274: { n:"BrtBeginComments", f:parsenoop },
|
|
|
|
|
0x0275: { n:"BrtEndComments", f:parsenoop },
|
|
|
|
|
0x0276: { n:"BrtBeginCommentAuthors", f:parsenoop },
|
|
|
|
|
0x0277: { n:"BrtEndCommentAuthors", f:parsenoop },
|
2014-03-29 02:05:50 +00:00
|
|
|
|
0x0278: { n:"BrtCommentAuthor", f:parse_BrtCommentAuthor },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x0279: { n:"BrtBeginCommentList", f:parsenoop },
|
|
|
|
|
0x027A: { n:"BrtEndCommentList", f:parsenoop },
|
2014-03-29 02:05:50 +00:00
|
|
|
|
0x027B: { n:"BrtBeginComment", f:parse_BrtBeginComment},
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x027C: { n:"BrtEndComment", f:parsenoop },
|
2014-03-29 02:05:50 +00:00
|
|
|
|
0x027D: { n:"BrtCommentText", f:parse_BrtCommentText },
|
2014-01-28 16:38:02 +00:00
|
|
|
|
0x027E: { n:"BrtBeginOleObjects", f:parsenoop },
|
|
|
|
|
0x027F: { n:"BrtOleObject", f:parsenoop },
|
|
|
|
|
0x0280: { n:"BrtEndOleObjects", f:parsenoop },
|
|
|
|
|
0x0281: { n:"BrtBeginSxrules", f:parsenoop },
|
|
|
|
|
0x0282: { n:"BrtEndSxRules", f:parsenoop },
|
|
|
|
|
0x0283: { n:"BrtBeginActiveXControls", f:parsenoop },
|
|
|
|
|
0x0284: { n:"BrtActiveX", f:parsenoop },
|
|
|
|
|
0x0285: { n:"BrtEndActiveXControls", f:parsenoop },
|
|
|
|
|
0x0286: { n:"BrtBeginPCDSDTCEMembersSortBy", f:parsenoop },
|
|
|
|
|
0x0288: { n:"BrtBeginCellIgnoreECs", f:parsenoop },
|
|
|
|
|
0x0289: { n:"BrtCellIgnoreEC", f:parsenoop },
|
|
|
|
|
0x028A: { n:"BrtEndCellIgnoreECs", f:parsenoop },
|
|
|
|
|
0x028B: { n:"BrtCsProp", f:parsenoop },
|
|
|
|
|
0x028C: { n:"BrtCsPageSetup", f:parsenoop },
|
|
|
|
|
0x028D: { n:"BrtBeginUserCsViews", f:parsenoop },
|
|
|
|
|
0x028E: { n:"BrtEndUserCsViews", f:parsenoop },
|
|
|
|
|
0x028F: { n:"BrtBeginUserCsView", f:parsenoop },
|
|
|
|
|
0x0290: { n:"BrtEndUserCsView", f:parsenoop },
|
|
|
|
|
0x0291: { n:"BrtBeginPcdSFCIEntries", f:parsenoop },
|
|
|
|
|
0x0292: { n:"BrtEndPCDSFCIEntries", f:parsenoop },
|
|
|
|
|
0x0293: { n:"BrtPCDSFCIEntry", f:parsenoop },
|
|
|
|
|
0x0294: { n:"BrtBeginListParts", f:parsenoop },
|
|
|
|
|
0x0295: { n:"BrtListPart", f:parsenoop },
|
|
|
|
|
0x0296: { n:"BrtEndListParts", f:parsenoop },
|
|
|
|
|
0x0297: { n:"BrtSheetCalcProp", f:parsenoop },
|
|
|
|
|
0x0298: { n:"BrtBeginFnGroup", f:parsenoop },
|
|
|
|
|
0x0299: { n:"BrtFnGroup", f:parsenoop },
|
|
|
|
|
0x029A: { n:"BrtEndFnGroup", f:parsenoop },
|
|
|
|
|
0x029B: { n:"BrtSupAddin", f:parsenoop },
|
|
|
|
|
0x029C: { n:"BrtSXTDMPOrder", f:parsenoop },
|
|
|
|
|
0x029D: { n:"BrtCsProtection", f:parsenoop },
|
|
|
|
|
0x029F: { n:"BrtBeginWsSortMap", f:parsenoop },
|
|
|
|
|
0x02A0: { n:"BrtEndWsSortMap", f:parsenoop },
|
|
|
|
|
0x02A1: { n:"BrtBeginRRSort", f:parsenoop },
|
|
|
|
|
0x02A2: { n:"BrtEndRRSort", f:parsenoop },
|
|
|
|
|
0x02A3: { n:"BrtRRSortItem", f:parsenoop },
|
|
|
|
|
0x02A4: { n:"BrtFileSharingIso", f:parsenoop },
|
|
|
|
|
0x02A5: { n:"BrtBookProtectionIso", f:parsenoop },
|
|
|
|
|
0x02A6: { n:"BrtSheetProtectionIso", f:parsenoop },
|
|
|
|
|
0x02A7: { n:"BrtCsProtectionIso", f:parsenoop },
|
|
|
|
|
0x02A8: { n:"BrtRangeProtectionIso", f:parsenoop },
|
|
|
|
|
0x0400: { n:"BrtRwDescent", f:parsenoop },
|
|
|
|
|
0x0401: { n:"BrtKnownFonts", f:parsenoop },
|
|
|
|
|
0x0402: { n:"BrtBeginSXTupleSet", f:parsenoop },
|
|
|
|
|
0x0403: { n:"BrtEndSXTupleSet", f:parsenoop },
|
|
|
|
|
0x0404: { n:"BrtBeginSXTupleSetHeader", f:parsenoop },
|
|
|
|
|
0x0405: { n:"BrtEndSXTupleSetHeader", f:parsenoop },
|
|
|
|
|
0x0406: { n:"BrtSXTupleSetHeaderItem", f:parsenoop },
|
|
|
|
|
0x0407: { n:"BrtBeginSXTupleSetData", f:parsenoop },
|
|
|
|
|
0x0408: { n:"BrtEndSXTupleSetData", f:parsenoop },
|
|
|
|
|
0x0409: { n:"BrtBeginSXTupleSetRow", f:parsenoop },
|
|
|
|
|
0x040A: { n:"BrtEndSXTupleSetRow", f:parsenoop },
|
|
|
|
|
0x040B: { n:"BrtSXTupleSetRowItem", f:parsenoop },
|
|
|
|
|
0x040C: { n:"BrtNameExt", f:parsenoop },
|
|
|
|
|
0x040D: { n:"BrtPCDH14", f:parsenoop },
|
|
|
|
|
0x040E: { n:"BrtBeginPCDCalcMem14", f:parsenoop },
|
|
|
|
|
0x040F: { n:"BrtEndPCDCalcMem14", f:parsenoop },
|
|
|
|
|
0x0410: { n:"BrtSXTH14", f:parsenoop },
|
|
|
|
|
0x0411: { n:"BrtBeginSparklineGroup", f:parsenoop },
|
|
|
|
|
0x0412: { n:"BrtEndSparklineGroup", f:parsenoop },
|
|
|
|
|
0x0413: { n:"BrtSparkline", f:parsenoop },
|
|
|
|
|
0x0414: { n:"BrtSXDI14", f:parsenoop },
|
|
|
|
|
0x0415: { n:"BrtWsFmtInfoEx14", f:parsenoop },
|
|
|
|
|
0x0416: { n:"BrtBeginConditionalFormatting14", f:parsenoop },
|
|
|
|
|
0x0417: { n:"BrtEndConditionalFormatting14", f:parsenoop },
|
|
|
|
|
0x0418: { n:"BrtBeginCFRule14", f:parsenoop },
|
|
|
|
|
0x0419: { n:"BrtEndCFRule14", f:parsenoop },
|
|
|
|
|
0x041A: { n:"BrtCFVO14", f:parsenoop },
|
|
|
|
|
0x041B: { n:"BrtBeginDatabar14", f:parsenoop },
|
|
|
|
|
0x041C: { n:"BrtBeginIconSet14", f:parsenoop },
|
|
|
|
|
0x041D: { n:"BrtDVal14", f:parsenoop },
|
|
|
|
|
0x041E: { n:"BrtBeginDVals14", f:parsenoop },
|
|
|
|
|
0x041F: { n:"BrtColor14", f:parsenoop },
|
|
|
|
|
0x0420: { n:"BrtBeginSparklines", f:parsenoop },
|
|
|
|
|
0x0421: { n:"BrtEndSparklines", f:parsenoop },
|
|
|
|
|
0x0422: { n:"BrtBeginSparklineGroups", f:parsenoop },
|
|
|
|
|
0x0423: { n:"BrtEndSparklineGroups", f:parsenoop },
|
|
|
|
|
0x0425: { n:"BrtSXVD14", f:parsenoop },
|
|
|
|
|
0x0426: { n:"BrtBeginSxview14", f:parsenoop },
|
|
|
|
|
0x0427: { n:"BrtEndSxview14", f:parsenoop },
|
|
|
|
|
0x042A: { n:"BrtBeginPCD14", f:parsenoop },
|
|
|
|
|
0x042B: { n:"BrtEndPCD14", f:parsenoop },
|
|
|
|
|
0x042C: { n:"BrtBeginExtConn14", f:parsenoop },
|
|
|
|
|
0x042D: { n:"BrtEndExtConn14", f:parsenoop },
|
|
|
|
|
0x042E: { n:"BrtBeginSlicerCacheIDs", f:parsenoop },
|
|
|
|
|
0x042F: { n:"BrtEndSlicerCacheIDs", f:parsenoop },
|
|
|
|
|
0x0430: { n:"BrtBeginSlicerCacheID", f:parsenoop },
|
|
|
|
|
0x0431: { n:"BrtEndSlicerCacheID", f:parsenoop },
|
|
|
|
|
0x0433: { n:"BrtBeginSlicerCache", f:parsenoop },
|
|
|
|
|
0x0434: { n:"BrtEndSlicerCache", f:parsenoop },
|
|
|
|
|
0x0435: { n:"BrtBeginSlicerCacheDef", f:parsenoop },
|
|
|
|
|
0x0436: { n:"BrtEndSlicerCacheDef", f:parsenoop },
|
|
|
|
|
0x0437: { n:"BrtBeginSlicersEx", f:parsenoop },
|
|
|
|
|
0x0438: { n:"BrtEndSlicersEx", f:parsenoop },
|
|
|
|
|
0x0439: { n:"BrtBeginSlicerEx", f:parsenoop },
|
|
|
|
|
0x043A: { n:"BrtEndSlicerEx", f:parsenoop },
|
|
|
|
|
0x043B: { n:"BrtBeginSlicer", f:parsenoop },
|
|
|
|
|
0x043C: { n:"BrtEndSlicer", f:parsenoop },
|
|
|
|
|
0x043D: { n:"BrtSlicerCachePivotTables", f:parsenoop },
|
|
|
|
|
0x043E: { n:"BrtBeginSlicerCacheOlapImpl", f:parsenoop },
|
|
|
|
|
0x043F: { n:"BrtEndSlicerCacheOlapImpl", f:parsenoop },
|
|
|
|
|
0x0440: { n:"BrtBeginSlicerCacheLevelsData", f:parsenoop },
|
|
|
|
|
0x0441: { n:"BrtEndSlicerCacheLevelsData", f:parsenoop },
|
|
|
|
|
0x0442: { n:"BrtBeginSlicerCacheLevelData", f:parsenoop },
|
|
|
|
|
0x0443: { n:"BrtEndSlicerCacheLevelData", f:parsenoop },
|
|
|
|
|
0x0444: { n:"BrtBeginSlicerCacheSiRanges", f:parsenoop },
|
|
|
|
|
0x0445: { n:"BrtEndSlicerCacheSiRanges", f:parsenoop },
|
|
|
|
|
0x0446: { n:"BrtBeginSlicerCacheSiRange", f:parsenoop },
|
|
|
|
|
0x0447: { n:"BrtEndSlicerCacheSiRange", f:parsenoop },
|
|
|
|
|
0x0448: { n:"BrtSlicerCacheOlapItem", f:parsenoop },
|
|
|
|
|
0x0449: { n:"BrtBeginSlicerCacheSelections", f:parsenoop },
|
|
|
|
|
0x044A: { n:"BrtSlicerCacheSelection", f:parsenoop },
|
|
|
|
|
0x044B: { n:"BrtEndSlicerCacheSelections", f:parsenoop },
|
|
|
|
|
0x044C: { n:"BrtBeginSlicerCacheNative", f:parsenoop },
|
|
|
|
|
0x044D: { n:"BrtEndSlicerCacheNative", f:parsenoop },
|
|
|
|
|
0x044E: { n:"BrtSlicerCacheNativeItem", f:parsenoop },
|
|
|
|
|
0x044F: { n:"BrtRangeProtection14", f:parsenoop },
|
|
|
|
|
0x0450: { n:"BrtRangeProtectionIso14", f:parsenoop },
|
|
|
|
|
0x0451: { n:"BrtCellIgnoreEC14", f:parsenoop },
|
|
|
|
|
0x0457: { n:"BrtList14", f:parsenoop },
|
|
|
|
|
0x0458: { n:"BrtCFIcon", f:parsenoop },
|
|
|
|
|
0x0459: { n:"BrtBeginSlicerCachesPivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x045A: { n:"BrtEndSlicerCachesPivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x045B: { n:"BrtBeginSlicers", f:parsenoop },
|
|
|
|
|
0x045C: { n:"BrtEndSlicers", f:parsenoop },
|
|
|
|
|
0x045D: { n:"BrtWbProp14", f:parsenoop },
|
|
|
|
|
0x045E: { n:"BrtBeginSXEdit", f:parsenoop },
|
|
|
|
|
0x045F: { n:"BrtEndSXEdit", f:parsenoop },
|
|
|
|
|
0x0460: { n:"BrtBeginSXEdits", f:parsenoop },
|
|
|
|
|
0x0461: { n:"BrtEndSXEdits", f:parsenoop },
|
|
|
|
|
0x0462: { n:"BrtBeginSXChange", f:parsenoop },
|
|
|
|
|
0x0463: { n:"BrtEndSXChange", f:parsenoop },
|
|
|
|
|
0x0464: { n:"BrtBeginSXChanges", f:parsenoop },
|
|
|
|
|
0x0465: { n:"BrtEndSXChanges", f:parsenoop },
|
|
|
|
|
0x0466: { n:"BrtSXTupleItems", f:parsenoop },
|
|
|
|
|
0x0468: { n:"BrtBeginSlicerStyle", f:parsenoop },
|
|
|
|
|
0x0469: { n:"BrtEndSlicerStyle", f:parsenoop },
|
|
|
|
|
0x046A: { n:"BrtSlicerStyleElement", f:parsenoop },
|
|
|
|
|
0x046B: { n:"BrtBeginStyleSheetExt14", f:parsenoop },
|
|
|
|
|
0x046C: { n:"BrtEndStyleSheetExt14", f:parsenoop },
|
|
|
|
|
0x046D: { n:"BrtBeginSlicerCachesPivotCacheID", f:parsenoop },
|
|
|
|
|
0x046E: { n:"BrtEndSlicerCachesPivotCacheID", f:parsenoop },
|
|
|
|
|
0x046F: { n:"BrtBeginConditionalFormattings", f:parsenoop },
|
|
|
|
|
0x0470: { n:"BrtEndConditionalFormattings", f:parsenoop },
|
|
|
|
|
0x0471: { n:"BrtBeginPCDCalcMemExt", f:parsenoop },
|
|
|
|
|
0x0472: { n:"BrtEndPCDCalcMemExt", f:parsenoop },
|
|
|
|
|
0x0473: { n:"BrtBeginPCDCalcMemsExt", f:parsenoop },
|
|
|
|
|
0x0474: { n:"BrtEndPCDCalcMemsExt", f:parsenoop },
|
|
|
|
|
0x0475: { n:"BrtPCDField14", f:parsenoop },
|
|
|
|
|
0x0476: { n:"BrtBeginSlicerStyles", f:parsenoop },
|
|
|
|
|
0x0477: { n:"BrtEndSlicerStyles", f:parsenoop },
|
|
|
|
|
0x0478: { n:"BrtBeginSlicerStyleElements", f:parsenoop },
|
|
|
|
|
0x0479: { n:"BrtEndSlicerStyleElements", f:parsenoop },
|
|
|
|
|
0x047A: { n:"BrtCFRuleExt", f:parsenoop },
|
|
|
|
|
0x047B: { n:"BrtBeginSXCondFmt14", f:parsenoop },
|
|
|
|
|
0x047C: { n:"BrtEndSXCondFmt14", f:parsenoop },
|
|
|
|
|
0x047D: { n:"BrtBeginSXCondFmts14", f:parsenoop },
|
|
|
|
|
0x047E: { n:"BrtEndSXCondFmts14", f:parsenoop },
|
|
|
|
|
0x0480: { n:"BrtBeginSortCond14", f:parsenoop },
|
|
|
|
|
0x0481: { n:"BrtEndSortCond14", f:parsenoop },
|
|
|
|
|
0x0482: { n:"BrtEndDVals14", f:parsenoop },
|
|
|
|
|
0x0483: { n:"BrtEndIconSet14", f:parsenoop },
|
|
|
|
|
0x0484: { n:"BrtEndDatabar14", f:parsenoop },
|
|
|
|
|
0x0485: { n:"BrtBeginColorScale14", f:parsenoop },
|
|
|
|
|
0x0486: { n:"BrtEndColorScale14", f:parsenoop },
|
|
|
|
|
0x0487: { n:"BrtBeginSxrules14", f:parsenoop },
|
|
|
|
|
0x0488: { n:"BrtEndSxrules14", f:parsenoop },
|
|
|
|
|
0x0489: { n:"BrtBeginPRule14", f:parsenoop },
|
|
|
|
|
0x048A: { n:"BrtEndPRule14", f:parsenoop },
|
|
|
|
|
0x048B: { n:"BrtBeginPRFilters14", f:parsenoop },
|
|
|
|
|
0x048C: { n:"BrtEndPRFilters14", f:parsenoop },
|
|
|
|
|
0x048D: { n:"BrtBeginPRFilter14", f:parsenoop },
|
|
|
|
|
0x048E: { n:"BrtEndPRFilter14", f:parsenoop },
|
|
|
|
|
0x048F: { n:"BrtBeginPRFItem14", f:parsenoop },
|
|
|
|
|
0x0490: { n:"BrtEndPRFItem14", f:parsenoop },
|
|
|
|
|
0x0491: { n:"BrtBeginCellIgnoreECs14", f:parsenoop },
|
|
|
|
|
0x0492: { n:"BrtEndCellIgnoreECs14", f:parsenoop },
|
|
|
|
|
0x0493: { n:"BrtDxf14", f:parsenoop },
|
|
|
|
|
0x0494: { n:"BrtBeginDxF14s", f:parsenoop },
|
|
|
|
|
0x0495: { n:"BrtEndDxf14s", f:parsenoop },
|
|
|
|
|
0x0499: { n:"BrtFilter14", f:parsenoop },
|
|
|
|
|
0x049A: { n:"BrtBeginCustomFilters14", f:parsenoop },
|
|
|
|
|
0x049C: { n:"BrtCustomFilter14", f:parsenoop },
|
|
|
|
|
0x049D: { n:"BrtIconFilter14", f:parsenoop },
|
|
|
|
|
0x049E: { n:"BrtPivotCacheConnectionName", f:parsenoop },
|
|
|
|
|
0x0800: { n:"BrtBeginDecoupledPivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x0801: { n:"BrtEndDecoupledPivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x0802: { n:"BrtDecoupledPivotCacheID", f:parsenoop },
|
|
|
|
|
0x0803: { n:"BrtBeginPivotTableRefs", f:parsenoop },
|
|
|
|
|
0x0804: { n:"BrtEndPivotTableRefs", f:parsenoop },
|
|
|
|
|
0x0805: { n:"BrtPivotTableRef", f:parsenoop },
|
|
|
|
|
0x0806: { n:"BrtSlicerCacheBookPivotTables", f:parsenoop },
|
|
|
|
|
0x0807: { n:"BrtBeginSxvcells", f:parsenoop },
|
|
|
|
|
0x0808: { n:"BrtEndSxvcells", f:parsenoop },
|
|
|
|
|
0x0809: { n:"BrtBeginSxRow", f:parsenoop },
|
|
|
|
|
0x080A: { n:"BrtEndSxRow", f:parsenoop },
|
|
|
|
|
0x080C: { n:"BrtPcdCalcMem15", f:parsenoop },
|
|
|
|
|
0x0813: { n:"BrtQsi15", f:parsenoop },
|
|
|
|
|
0x0814: { n:"BrtBeginWebExtensions", f:parsenoop },
|
|
|
|
|
0x0815: { n:"BrtEndWebExtensions", f:parsenoop },
|
|
|
|
|
0x0816: { n:"BrtWebExtension", f:parsenoop },
|
|
|
|
|
0x0817: { n:"BrtAbsPath15", f:parsenoop },
|
|
|
|
|
0x0818: { n:"BrtBeginPivotTableUISettings", f:parsenoop },
|
|
|
|
|
0x0819: { n:"BrtEndPivotTableUISettings", f:parsenoop },
|
|
|
|
|
0x081B: { n:"BrtTableSlicerCacheIDs", f:parsenoop },
|
|
|
|
|
0x081C: { n:"BrtTableSlicerCacheID", f:parsenoop },
|
|
|
|
|
0x081D: { n:"BrtBeginTableSlicerCache", f:parsenoop },
|
|
|
|
|
0x081E: { n:"BrtEndTableSlicerCache", f:parsenoop },
|
|
|
|
|
0x081F: { n:"BrtSxFilter15", f:parsenoop },
|
|
|
|
|
0x0820: { n:"BrtBeginTimelineCachePivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x0821: { n:"BrtEndTimelineCachePivotCacheIDs", f:parsenoop },
|
|
|
|
|
0x0822: { n:"BrtTimelineCachePivotCacheID", f:parsenoop },
|
|
|
|
|
0x0823: { n:"BrtBeginTimelineCacheIDs", f:parsenoop },
|
|
|
|
|
0x0824: { n:"BrtEndTimelineCacheIDs", f:parsenoop },
|
|
|
|
|
0x0825: { n:"BrtBeginTimelineCacheID", f:parsenoop },
|
|
|
|
|
0x0826: { n:"BrtEndTimelineCacheID", f:parsenoop },
|
|
|
|
|
0x0827: { n:"BrtBeginTimelinesEx", f:parsenoop },
|
|
|
|
|
0x0828: { n:"BrtEndTimelinesEx", f:parsenoop },
|
|
|
|
|
0x0829: { n:"BrtBeginTimelineEx", f:parsenoop },
|
|
|
|
|
0x082A: { n:"BrtEndTimelineEx", f:parsenoop },
|
|
|
|
|
0x082B: { n:"BrtWorkBookPr15", f:parsenoop },
|
|
|
|
|
0x082C: { n:"BrtPCDH15", f:parsenoop },
|
|
|
|
|
0x082D: { n:"BrtBeginTimelineStyle", f:parsenoop },
|
|
|
|
|
0x082E: { n:"BrtEndTimelineStyle", f:parsenoop },
|
|
|
|
|
0x082F: { n:"BrtTimelineStyleElement", f:parsenoop },
|
|
|
|
|
0x0830: { n:"BrtBeginTimelineStylesheetExt15", f:parsenoop },
|
|
|
|
|
0x0831: { n:"BrtEndTimelineStylesheetExt15", f:parsenoop },
|
|
|
|
|
0x0832: { n:"BrtBeginTimelineStyles", f:parsenoop },
|
|
|
|
|
0x0833: { n:"BrtEndTimelineStyles", f:parsenoop },
|
|
|
|
|
0x0834: { n:"BrtBeginTimelineStyleElements", f:parsenoop },
|
|
|
|
|
0x0835: { n:"BrtEndTimelineStyleElements", f:parsenoop },
|
|
|
|
|
0x0836: { n:"BrtDxf15", f:parsenoop },
|
|
|
|
|
0x0837: { n:"BrtBeginDxfs15", f:parsenoop },
|
|
|
|
|
0x0838: { n:"brtEndDxfs15", f:parsenoop },
|
|
|
|
|
0x0839: { n:"BrtSlicerCacheHideItemsWithNoData", f:parsenoop },
|
|
|
|
|
0x083A: { n:"BrtBeginItemUniqueNames", f:parsenoop },
|
|
|
|
|
0x083B: { n:"BrtEndItemUniqueNames", f:parsenoop },
|
|
|
|
|
0x083C: { n:"BrtItemUniqueName", f:parsenoop },
|
|
|
|
|
0x083D: { n:"BrtBeginExtConn15", f:parsenoop },
|
|
|
|
|
0x083E: { n:"BrtEndExtConn15", f:parsenoop },
|
|
|
|
|
0x083F: { n:"BrtBeginOledbPr15", f:parsenoop },
|
|
|
|
|
0x0840: { n:"BrtEndOledbPr15", f:parsenoop },
|
|
|
|
|
0x0841: { n:"BrtBeginDataFeedPr15", f:parsenoop },
|
|
|
|
|
0x0842: { n:"BrtEndDataFeedPr15", f:parsenoop },
|
|
|
|
|
0x0843: { n:"BrtTextPr15", f:parsenoop },
|
|
|
|
|
0x0844: { n:"BrtRangePr15", f:parsenoop },
|
|
|
|
|
0x0845: { n:"BrtDbCommand15", f:parsenoop },
|
|
|
|
|
0x0846: { n:"BrtBeginDbTables15", f:parsenoop },
|
|
|
|
|
0x0847: { n:"BrtEndDbTables15", f:parsenoop },
|
|
|
|
|
0x0848: { n:"BrtDbTable15", f:parsenoop },
|
|
|
|
|
0x0849: { n:"BrtBeginDataModel", f:parsenoop },
|
|
|
|
|
0x084A: { n:"BrtEndDataModel", f:parsenoop },
|
|
|
|
|
0x084B: { n:"BrtBeginModelTables", f:parsenoop },
|
|
|
|
|
0x084C: { n:"BrtEndModelTables", f:parsenoop },
|
|
|
|
|
0x084D: { n:"BrtModelTable", f:parsenoop },
|
|
|
|
|
0x084E: { n:"BrtBeginModelRelationships", f:parsenoop },
|
|
|
|
|
0x084F: { n:"BrtEndModelRelationships", f:parsenoop },
|
|
|
|
|
0x0850: { n:"BrtModelRelationship", f:parsenoop },
|
|
|
|
|
0x0851: { n:"BrtBeginECTxtWiz15", f:parsenoop },
|
|
|
|
|
0x0852: { n:"BrtEndECTxtWiz15", f:parsenoop },
|
|
|
|
|
0x0853: { n:"BrtBeginECTWFldInfoLst15", f:parsenoop },
|
|
|
|
|
0x0854: { n:"BrtEndECTWFldInfoLst15", f:parsenoop },
|
|
|
|
|
0x0855: { n:"BrtBeginECTWFldInfo15", f:parsenoop },
|
|
|
|
|
0x0856: { n:"BrtFieldListActiveItem", f:parsenoop },
|
|
|
|
|
0x0857: { n:"BrtPivotCacheIdVersion", f:parsenoop },
|
|
|
|
|
0x0858: { n:"BrtSXDI15", f:parsenoop },
|
|
|
|
|
0xFFFF: { n:"", f:parsenoop }
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var evert_RE = evert_key(RecordEnum, 'n');
|
2014-10-10 02:22:38 +00:00
|
|
|
|
/* Helper function to call out to ODS parser */
|
|
|
|
|
function parse_ods(zip, opts) {
|
|
|
|
|
if(typeof module !== "undefined" && typeof require !== 'undefined' && typeof ODS === 'undefined') ODS = require('./dist/od' + 's');
|
|
|
|
|
if(typeof ODS === 'undefined' || !ODS.parse_ods) throw new Error("Unsupported ODS");
|
|
|
|
|
return ODS.parse_ods(zip, opts);
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function fix_opts_func(defaults) {
|
|
|
|
|
return function fix_opts(opts) {
|
|
|
|
|
for(var i = 0; i != defaults.length; ++i) {
|
|
|
|
|
var d = defaults[i];
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(opts[d[0]] === undefined) opts[d[0]] = d[1];
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(d[2] === 'n') opts[d[0]] = Number(opts[d[0]]);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
};
|
2014-02-07 10:53:40 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var fix_read_opts = fix_opts_func([
|
2014-05-16 00:33:34 +00:00
|
|
|
|
['cellNF', false], /* emit cell number format string as .z */
|
|
|
|
|
['cellHTML', true], /* emit html string as .h */
|
|
|
|
|
['cellFormula', true], /* emit formulae as .f */
|
2014-05-29 06:18:23 +00:00
|
|
|
|
['cellStyles', false], /* emits style/theme as .s */
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
['sheetStubs', false], /* emit empty cells */
|
|
|
|
|
['sheetRows', 0, 'n'], /* read n rows (0 = read all rows) */
|
|
|
|
|
|
|
|
|
|
['bookDeps', false], /* parse calculation chains */
|
|
|
|
|
['bookSheets', false], /* only try to get sheet names (no Sheets) */
|
|
|
|
|
['bookProps', false], /* only try to get properties (no Sheets) */
|
|
|
|
|
['bookFiles', false], /* include raw file structure (keys, files) */
|
|
|
|
|
['bookVBA', false], /* include vba raw data (vbaraw) */
|
|
|
|
|
|
|
|
|
|
['WTF', false] /* WTF mode (throws errors) */
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var fix_write_opts = fix_opts_func([
|
2014-05-16 00:33:34 +00:00
|
|
|
|
['bookSST', false], /* Generate Shared String Table */
|
|
|
|
|
|
|
|
|
|
['bookType', 'xlsx'], /* Type of workbook (xlsx/m/b) */
|
|
|
|
|
|
|
|
|
|
['WTF', false] /* WTF mode (throws errors) */
|
|
|
|
|
]);
|
2014-06-05 07:06:20 +00:00
|
|
|
|
function safe_parse_wbrels(wbrels, sheets) {
|
|
|
|
|
if(!wbrels) return 0;
|
|
|
|
|
try {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
wbrels = sheets.map(function pwbr(w) { return [w.name, wbrels['!id'][w.id].Target]; });
|
2014-06-05 07:06:20 +00:00
|
|
|
|
} catch(e) { return null; }
|
|
|
|
|
return !wbrels || wbrels.length === 0 ? null : wbrels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function safe_parse_ws(zip, path, relsPath, sheet, sheetRels, sheets, opts) {
|
|
|
|
|
try {
|
|
|
|
|
sheetRels[sheet]=parse_rels(getzipdata(zip, relsPath, true), path);
|
|
|
|
|
sheets[sheet]=parse_ws(getzipdata(zip, path),path,opts,sheetRels[sheet]);
|
|
|
|
|
} catch(e) { if(opts.WTF) throw e; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var nodirs = function nodirs(x){return x.substr(-1) != '/';};
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function parse_zip(zip, opts) {
|
|
|
|
|
make_ssf(SSF);
|
2014-02-07 10:53:40 +00:00
|
|
|
|
opts = opts || {};
|
2014-05-16 00:33:34 +00:00
|
|
|
|
fix_read_opts(opts);
|
2014-02-05 13:39:21 +00:00
|
|
|
|
reset_cp();
|
2014-10-10 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
/* OpenDocument Part 3 Section 2.2.1 OpenDocument Package */
|
|
|
|
|
if(safegetzipfile(zip, 'META-INF/manifest.xml')) return parse_ods(zip, opts);
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var entries = keys(zip.files).filter(nodirs).sort();
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var dir = parse_ct(getzipdata(zip, '[Content_Types].xml'), opts);
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var xlsb = false;
|
2014-04-03 22:51:54 +00:00
|
|
|
|
var sheets, binname;
|
|
|
|
|
if(dir.workbooks.length === 0) {
|
|
|
|
|
binname = "xl/workbook.xml";
|
|
|
|
|
if(getzipdata(zip,binname, true)) dir.workbooks.push(binname);
|
|
|
|
|
}
|
2014-01-28 16:38:02 +00:00
|
|
|
|
if(dir.workbooks.length === 0) {
|
2014-04-03 22:51:54 +00:00
|
|
|
|
binname = "xl/workbook.bin";
|
|
|
|
|
if(!getzipfile(zip,binname,true)) throw new Error("Could not find workbook");
|
2014-01-28 16:38:02 +00:00
|
|
|
|
dir.workbooks.push(binname);
|
|
|
|
|
xlsb = true;
|
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
if(dir.workbooks[0].substr(-3) == "bin") xlsb = true;
|
2014-05-22 12:16:51 +00:00
|
|
|
|
if(xlsb) set_cp(1200);
|
2013-03-26 23:54:14 +00:00
|
|
|
|
|
2014-02-14 06:25:46 +00:00
|
|
|
|
if(!opts.bookSheets && !opts.bookProps) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
strs = [];
|
2014-02-15 05:08:18 +00:00
|
|
|
|
if(dir.sst) strs=parse_sst(getzipdata(zip, dir.sst.replace(/^\//,'')), dir.sst, opts);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
|
|
|
|
|
styles = {};
|
2014-03-23 21:30:00 +00:00
|
|
|
|
if(dir.style) styles = parse_sty(getzipdata(zip, dir.style.replace(/^\//,'')),dir.style, opts);
|
2014-05-29 06:18:23 +00:00
|
|
|
|
|
|
|
|
|
themes = {};
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(opts.cellStyles && dir.themes.length) themes = parse_theme(getzipdata(zip, dir.themes[0].replace(/^\//,''), true),dir.themes[0], opts);
|
2014-02-13 06:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-15 05:08:18 +00:00
|
|
|
|
var wb = parse_wb(getzipdata(zip, dir.workbooks[0].replace(/^\//,'')), dir.workbooks[0], opts);
|
2013-03-26 23:54:14 +00:00
|
|
|
|
|
2014-02-04 00:00:44 +00:00
|
|
|
|
var props = {}, propdata = "";
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
if(dir.coreprops.length !== 0) {
|
|
|
|
|
propdata = getzipdata(zip, dir.coreprops[0].replace(/^\//,''), true);
|
|
|
|
|
if(propdata) props = parse_core_props(propdata);
|
|
|
|
|
if(dir.extprops.length !== 0) {
|
|
|
|
|
propdata = getzipdata(zip, dir.extprops[0].replace(/^\//,''), true);
|
|
|
|
|
if(propdata) parse_ext_props(propdata, props);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-14 06:25:46 +00:00
|
|
|
|
|
2014-02-14 03:39:03 +00:00
|
|
|
|
var custprops = {};
|
2014-02-14 06:25:46 +00:00
|
|
|
|
if(!opts.bookSheets || opts.bookProps) {
|
2014-02-15 05:08:18 +00:00
|
|
|
|
if (dir.custprops.length !== 0) {
|
|
|
|
|
propdata = getzipdata(zip, dir.custprops[0].replace(/^\//,''), true);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(propdata) custprops = parse_cust_props(propdata, opts);
|
2014-02-15 05:08:18 +00:00
|
|
|
|
}
|
2014-02-14 03:39:03 +00:00
|
|
|
|
}
|
2014-02-13 06:22:42 +00:00
|
|
|
|
|
2014-02-14 06:25:46 +00:00
|
|
|
|
var out = {};
|
|
|
|
|
if(opts.bookSheets || opts.bookProps) {
|
|
|
|
|
if(props.Worksheets && props.SheetNames.length > 0) sheets=props.SheetNames;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
else if(wb.Sheets) sheets = wb.Sheets.map(function pluck(x){ return x.name; });
|
2014-02-14 06:25:46 +00:00
|
|
|
|
if(opts.bookProps) { out.Props = props; out.Custprops = custprops; }
|
|
|
|
|
if(typeof sheets !== 'undefined') out.SheetNames = sheets;
|
|
|
|
|
if(opts.bookSheets ? out.SheetNames : opts.bookProps) return out;
|
2014-02-13 06:22:42 +00:00
|
|
|
|
}
|
2014-02-15 05:08:18 +00:00
|
|
|
|
sheets = {};
|
2014-02-13 06:22:42 +00:00
|
|
|
|
|
2012-12-04 19:27:20 +00:00
|
|
|
|
var deps = {};
|
2014-03-29 22:53:15 +00:00
|
|
|
|
if(opts.bookDeps && dir.calcchain) deps=parse_cc(getzipdata(zip, dir.calcchain.replace(/^\//,'')),dir.calcchain,opts);
|
2014-02-15 05:08:18 +00:00
|
|
|
|
|
|
|
|
|
var i=0;
|
2014-01-28 16:38:02 +00:00
|
|
|
|
var sheetRels = {};
|
2014-01-29 06:00:09 +00:00
|
|
|
|
var path, relsPath;
|
2013-02-20 16:02:00 +00:00
|
|
|
|
if(!props.Worksheets) {
|
2014-01-22 04:58:26 +00:00
|
|
|
|
var wbsheets = wb.Sheets;
|
|
|
|
|
props.Worksheets = wbsheets.length;
|
|
|
|
|
props.SheetNames = [];
|
|
|
|
|
for(var j = 0; j != wbsheets.length; ++j) {
|
|
|
|
|
props.SheetNames[j] = wbsheets[j].name;
|
|
|
|
|
}
|
2014-02-21 16:41:37 +00:00
|
|
|
|
}
|
2014-05-22 12:16:51 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
var wbext = xlsb ? "bin" : "xml";
|
|
|
|
|
var wbrelsfile = 'xl/_rels/workbook.' + wbext + '.rels';
|
2014-05-22 12:16:51 +00:00
|
|
|
|
var wbrels = parse_rels(getzipdata(zip, wbrelsfile, true), wbrelsfile);
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(wbrels) wbrels = safe_parse_wbrels(wbrels, wb.Sheets);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
/* Numbers iOS hack */
|
2014-02-21 16:41:37 +00:00
|
|
|
|
var nmode = (getzipdata(zip,"xl/worksheets/sheet.xml",true))?1:0;
|
|
|
|
|
for(i = 0; i != props.Worksheets; ++i) {
|
2014-06-05 07:06:20 +00:00
|
|
|
|
if(wbrels) path = 'xl/' + (wbrels[i][1]).replace(/[\/]?xl\//, "");
|
|
|
|
|
else {
|
|
|
|
|
path = 'xl/worksheets/sheet'+(i+1-nmode)+"." + wbext;
|
|
|
|
|
path = path.replace(/sheet0\./,"sheet.");
|
|
|
|
|
}
|
|
|
|
|
relsPath = path.replace(/^(.*)(\/)([^\/]*)$/, "$1/_rels/$3.rels");
|
|
|
|
|
safe_parse_ws(zip, path, relsPath, props.SheetNames[i], sheetRels, sheets, opts);
|
2012-12-04 19:27:20 +00:00
|
|
|
|
}
|
2014-01-22 04:58:26 +00:00
|
|
|
|
|
2014-02-12 06:09:42 +00:00
|
|
|
|
if(dir.comments) parse_comments(zip, dir.comments, sheets, sheetRels, opts);
|
2014-01-22 04:58:26 +00:00
|
|
|
|
|
2014-02-17 08:44:22 +00:00
|
|
|
|
out = {
|
2012-12-04 19:27:20 +00:00
|
|
|
|
Directory: dir,
|
|
|
|
|
Workbook: wb,
|
|
|
|
|
Props: props,
|
2014-02-14 03:39:03 +00:00
|
|
|
|
Custprops: custprops,
|
2012-12-04 19:27:20 +00:00
|
|
|
|
Deps: deps,
|
|
|
|
|
Sheets: sheets,
|
|
|
|
|
SheetNames: props.SheetNames,
|
|
|
|
|
Strings: strs,
|
2013-03-26 23:54:14 +00:00
|
|
|
|
Styles: styles,
|
2014-05-29 06:18:23 +00:00
|
|
|
|
Themes: themes,
|
2014-05-16 00:33:34 +00:00
|
|
|
|
SSF: SSF.get_table()
|
2012-12-04 19:27:20 +00:00
|
|
|
|
};
|
2014-02-17 08:44:22 +00:00
|
|
|
|
if(opts.bookFiles) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
out.keys = entries;
|
2014-02-21 16:41:37 +00:00
|
|
|
|
out.files = zip.files;
|
2014-02-17 08:44:22 +00:00
|
|
|
|
}
|
2014-04-03 22:51:54 +00:00
|
|
|
|
if(opts.bookVBA) {
|
|
|
|
|
if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,dir.vba[0],true);
|
|
|
|
|
else if(dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true);
|
|
|
|
|
}
|
2014-02-17 08:44:22 +00:00
|
|
|
|
return out;
|
2012-12-04 19:27:20 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function add_rels(rels, rId, f, type, relobj) {
|
|
|
|
|
if(!relobj) relobj = {};
|
|
|
|
|
if(!rels['!id']) rels['!id'] = {};
|
|
|
|
|
relobj.Id = 'rId' + rId;
|
2014-05-16 00:50:55 +00:00
|
|
|
|
relobj.Type = type;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
relobj.Target = f;
|
|
|
|
|
if(rels['!id'][relobj.Id]) throw new Error("Cannot rewrite rId " + rId);
|
|
|
|
|
rels['!id'][relobj.Id] = relobj;
|
|
|
|
|
rels[('/' + relobj.Target).replace("//","/")] = relobj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function write_zip(wb, opts) {
|
2014-05-22 12:16:51 +00:00
|
|
|
|
if(wb && !wb.SSF) {
|
|
|
|
|
wb.SSF = SSF.get_table();
|
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
if(wb && wb.SSF) {
|
|
|
|
|
make_ssf(SSF); SSF.load_table(wb.SSF);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
opts.revssf = evert_num(wb.SSF); opts.revssf[wb.SSF[65535]] = 0;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
|
|
|
|
opts.rels = {}; opts.wbrels = {};
|
|
|
|
|
opts.Strings = []; opts.Strings.Count = 0; opts.Strings.Unique = 0;
|
|
|
|
|
var wbext = opts.bookType == "xlsb" ? "bin" : "xml";
|
|
|
|
|
var ct = { workbooks: [], sheets: [], calcchains: [], themes: [], styles: [],
|
|
|
|
|
coreprops: [], extprops: [], custprops: [], strs:[], comments: [], vba: [],
|
|
|
|
|
TODO:[], rels:[], xmlns: "" };
|
|
|
|
|
fix_write_opts(opts = opts || {});
|
|
|
|
|
var zip = new jszip();
|
|
|
|
|
var f = "", rId = 0;
|
|
|
|
|
|
|
|
|
|
opts.cellXfs = [];
|
2014-05-22 12:16:51 +00:00
|
|
|
|
get_cell_style(opts.cellXfs, {}, {revssf:{"General":0}});
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
f = "docProps/core.xml";
|
|
|
|
|
zip.file(f, write_core_props(wb.Props, opts));
|
|
|
|
|
ct.coreprops.push(f);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
add_rels(opts.rels, 2, f, RELS.CORE_PROPS);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
f = "docProps/app.xml";
|
2014-05-22 12:16:51 +00:00
|
|
|
|
if(!wb.Props) wb.Props = {};
|
2014-05-16 00:33:34 +00:00
|
|
|
|
wb.Props.SheetNames = wb.SheetNames;
|
|
|
|
|
wb.Props.Worksheets = wb.SheetNames.length;
|
|
|
|
|
zip.file(f, write_ext_props(wb.Props, opts));
|
|
|
|
|
ct.extprops.push(f);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
add_rels(opts.rels, 3, f, RELS.EXT_PROPS);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
if(wb.Custprops !== wb.Props && keys(wb.Custprops||{}).length > 0) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
f = "docProps/custom.xml";
|
|
|
|
|
zip.file(f, write_cust_props(wb.Custprops, opts));
|
|
|
|
|
ct.custprops.push(f);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
add_rels(opts.rels, 4, f, RELS.CUST_PROPS);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
f = "xl/workbook." + wbext;
|
|
|
|
|
zip.file(f, write_wb(wb, f, opts));
|
|
|
|
|
ct.workbooks.push(f);
|
|
|
|
|
add_rels(opts.rels, 1, f, RELS.WB);
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(rId=1;rId <= wb.SheetNames.length; ++rId) {
|
|
|
|
|
f = "xl/worksheets/sheet" + rId + "." + wbext;
|
|
|
|
|
zip.file(f, write_ws(rId-1, f, opts, wb));
|
2014-05-16 00:33:34 +00:00
|
|
|
|
ct.sheets.push(f);
|
|
|
|
|
add_rels(opts.wbrels, rId, "worksheets/sheet" + rId + "." + wbext, RELS.WS);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(opts.Strings != null && opts.Strings.length > 0) {
|
2014-05-16 00:33:34 +00:00
|
|
|
|
f = "xl/sharedStrings." + wbext;
|
|
|
|
|
zip.file(f, write_sst(opts.Strings, f, opts));
|
|
|
|
|
ct.strs.push(f);
|
|
|
|
|
add_rels(opts.wbrels, ++rId, "sharedStrings." + wbext, RELS.SST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* TODO: something more intelligent with themes */
|
2014-05-16 00:50:55 +00:00
|
|
|
|
|
2014-05-22 12:16:51 +00:00
|
|
|
|
f = "xl/theme/theme1.xml";
|
2014-05-16 00:33:34 +00:00
|
|
|
|
zip.file(f, write_theme());
|
|
|
|
|
ct.themes.push(f);
|
2014-05-22 12:16:51 +00:00
|
|
|
|
add_rels(opts.wbrels, ++rId, "theme/theme1.xml", RELS.THEME);
|
2014-05-16 00:33:34 +00:00
|
|
|
|
|
|
|
|
|
/* TODO: something more intelligent with styles */
|
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
f = "xl/styles." + wbext;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
zip.file(f, write_sty(wb, f, opts));
|
|
|
|
|
ct.styles.push(f);
|
|
|
|
|
add_rels(opts.wbrels, ++rId, "styles." + wbext, RELS.STY);
|
|
|
|
|
|
|
|
|
|
zip.file("[Content_Types].xml", write_ct(ct, opts));
|
|
|
|
|
zip.file('_rels/.rels', write_rels(opts.rels));
|
2014-05-29 22:30:03 +00:00
|
|
|
|
zip.file('xl/_rels/workbook.' + wbext + '.rels', write_rels(opts.wbrels));
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return zip;
|
|
|
|
|
}
|
|
|
|
|
function readSync(data, opts) {
|
2012-12-04 19:27:20 +00:00
|
|
|
|
var zip, d = data;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
var o = opts||{};
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
|
2014-05-16 00:33:34 +00:00
|
|
|
|
switch(o.type) {
|
2012-12-04 19:27:20 +00:00
|
|
|
|
case "base64": zip = new jszip(d, { base64:true }); break;
|
|
|
|
|
case "binary": zip = new jszip(d, { base64:false }); break;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
case "buffer": zip = new jszip(d); break;
|
|
|
|
|
case "file": zip=new jszip(d=_fs.readFileSync(data)); break;
|
|
|
|
|
default: throw new Error("Unrecognized type " + o.type);
|
2012-12-04 19:27:20 +00:00
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
|
return parse_zip(zip, o);
|
2012-12-04 19:27:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function readFileSync(data, opts) {
|
|
|
|
|
var o = opts||{}; o.type = 'file';
|
2012-12-04 19:27:20 +00:00
|
|
|
|
return readSync(data, o);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 00:33:34 +00:00
|
|
|
|
function writeSync(wb, opts) {
|
|
|
|
|
var o = opts||{};
|
|
|
|
|
var z = write_zip(wb, o);
|
|
|
|
|
switch(o.type) {
|
|
|
|
|
case "base64": return z.generate({type:"base64"});
|
|
|
|
|
case "binary": return z.generate({type:"string"});
|
|
|
|
|
case "buffer": return z.generate({type:"nodebuffer"});
|
|
|
|
|
case "file": return _fs.writeFileSync(o.file, z.generate({type:"nodebuffer"}));
|
|
|
|
|
default: throw new Error("Unrecognized type " + o.type);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function writeFileSync(wb, filename, opts) {
|
|
|
|
|
var o = opts||{}; o.type = 'file';
|
|
|
|
|
o.file = filename;
|
|
|
|
|
switch(o.file.substr(-5).toLowerCase()) {
|
|
|
|
|
case '.xlsm': o.bookType = 'xlsm'; break;
|
|
|
|
|
case '.xlsb': o.bookType = 'xlsb'; break;
|
|
|
|
|
}
|
|
|
|
|
return writeSync(wb, o);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function decode_row(rowstr) { return parseInt(unfix_row(rowstr),10) - 1; }
|
2014-05-03 18:51:10 +00:00
|
|
|
|
function encode_row(row) { return "" + (row + 1); }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function fix_row(cstr) { return cstr.replace(/([A-Z]|^)(\d+)$/,"$1$$$2"); }
|
|
|
|
|
function unfix_row(cstr) { return cstr.replace(/\$(\d+)$/,"$1"); }
|
2013-03-15 23:08:09 +00:00
|
|
|
|
|
2014-05-03 18:51:10 +00:00
|
|
|
|
function decode_col(colstr) { var c = unfix_col(colstr), d = 0, i = 0; for(; i !== c.length; ++i) d = 26*d + c.charCodeAt(i) - 64; return d - 1; }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function encode_col(col) { var s=""; for(++col; col; col=Math.floor((col-1)/26)) s = String.fromCharCode(((col-1)%26) + 65) + s; return s; }
|
2014-05-03 18:51:10 +00:00
|
|
|
|
function fix_col(cstr) { return cstr.replace(/^([A-Z])/,"$$$1"); }
|
|
|
|
|
function unfix_col(cstr) { return cstr.replace(/^\$([A-Z])/,"$1"); }
|
2012-12-04 19:27:20 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function split_cell(cstr) { return cstr.replace(/(\$?[A-Z]*)(\$?\d*)/,"$1,$2").split(","); }
|
2012-12-04 19:27:20 +00:00
|
|
|
|
function decode_cell(cstr) { var splt = split_cell(cstr); return { c:decode_col(splt[0]), r:decode_row(splt[1]) }; }
|
2014-05-03 18:51:10 +00:00
|
|
|
|
function encode_cell(cell) { return encode_col(cell.c) + encode_row(cell.r); }
|
|
|
|
|
function fix_cell(cstr) { return fix_col(fix_row(cstr)); }
|
|
|
|
|
function unfix_cell(cstr) { return unfix_col(unfix_row(cstr)); }
|
2012-12-04 19:27:20 +00:00
|
|
|
|
function decode_range(range) { var x =range.split(":").map(decode_cell); return {s:x[0],e:x[x.length-1]}; }
|
2014-05-03 18:51:10 +00:00
|
|
|
|
function encode_range(cs,ce) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(ce === undefined || typeof ce === 'number') return encode_range(cs.s, cs.e);
|
2014-05-03 18:51:10 +00:00
|
|
|
|
if(typeof cs !== 'string') cs = encode_cell(cs); if(typeof ce !== 'string') ce = encode_cell(ce);
|
|
|
|
|
return cs == ce ? cs : cs + ":" + ce;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function safe_decode_range(range) {
|
|
|
|
|
var o = {s:{c:0,r:0},e:{c:0,r:0}};
|
|
|
|
|
var idx = 0, i = 0, cc = 0;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var len = range.length;
|
|
|
|
|
for(idx = 0; i < len; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((cc=range.charCodeAt(i)-64) < 1 || cc > 26) break;
|
|
|
|
|
idx = 26*idx + cc;
|
|
|
|
|
}
|
|
|
|
|
o.s.c = --idx;
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(idx = 0; i < len; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((cc=range.charCodeAt(i)-48) < 0 || cc > 9) break;
|
|
|
|
|
idx = 10*idx + cc;
|
|
|
|
|
}
|
|
|
|
|
o.s.r = --idx;
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(i === len || range.charCodeAt(++i) === 58) { o.e.c=o.s.c; o.e.r=o.s.r; return o; }
|
2014-06-29 18:29:45 +00:00
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(idx = 0; i != len; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((cc=range.charCodeAt(i)-64) < 1 || cc > 26) break;
|
|
|
|
|
idx = 26*idx + cc;
|
|
|
|
|
}
|
|
|
|
|
o.e.c = --idx;
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(idx = 0; i != len; ++i) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if((cc=range.charCodeAt(i)-48) < 0 || cc > 9) break;
|
|
|
|
|
idx = 10*idx + cc;
|
|
|
|
|
}
|
|
|
|
|
o.e.r = --idx;
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function safe_format_cell(cell, v) {
|
|
|
|
|
if(cell.z !== undefined) try { return (cell.w = SSF.format(cell.z, v)); } catch(e) { }
|
2014-05-03 18:51:10 +00:00
|
|
|
|
if(!cell.XF) return v;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
try { return (cell.w = SSF.format(cell.XF.ifmt||0, v)); } catch(e) { return ''+v; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function format_cell(cell, v) {
|
|
|
|
|
if(cell == null || cell.t == null) return "";
|
|
|
|
|
if(cell.w !== undefined) return cell.w;
|
|
|
|
|
if(v === undefined) return safe_format_cell(cell, cell.v);
|
|
|
|
|
return safe_format_cell(cell, v);
|
2014-05-03 18:51:10 +00:00
|
|
|
|
}
|
2014-01-23 06:20:19 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
function sheet_to_json(sheet, opts){
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v;
|
|
|
|
|
var o = opts != null ? opts : {};
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var raw = o.raw;
|
|
|
|
|
if(sheet == null || sheet["!ref"] == null) return [];
|
2014-06-29 18:29:45 +00:00
|
|
|
|
range = o.range !== undefined ? o.range : sheet["!ref"];
|
|
|
|
|
if(o.header === 1) header = 1;
|
|
|
|
|
else if(o.header === "A") header = 2;
|
|
|
|
|
else if(Array.isArray(o.header)) header = 3;
|
2014-05-29 22:30:03 +00:00
|
|
|
|
switch(typeof range) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
case 'string': r = safe_decode_range(range); break;
|
|
|
|
|
case 'number': r = safe_decode_range(sheet["!ref"]); r.s.r = range; break;
|
2014-05-29 22:30:03 +00:00
|
|
|
|
default: r = range;
|
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(header > 0) offset = 0;
|
|
|
|
|
var rr = encode_row(r.s.r);
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var cols = new Array(r.e.c-r.s.c+1);
|
|
|
|
|
var out = new Array(r.e.r-r.s.r-offset+1);
|
|
|
|
|
var outi = 0;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(C = r.s.c; C <= r.e.c; ++C) {
|
|
|
|
|
cols[C] = encode_col(C);
|
|
|
|
|
val = sheet[cols[C] + rr];
|
|
|
|
|
switch(header) {
|
|
|
|
|
case 1: hdr[C] = C; break;
|
|
|
|
|
case 2: hdr[C] = cols[C]; break;
|
|
|
|
|
case 3: hdr[C] = o.header[C - r.s.c]; break;
|
|
|
|
|
default:
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(val === undefined) continue;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
hdr[C] = format_cell(val);
|
|
|
|
|
}
|
2014-01-23 06:20:19 +00:00
|
|
|
|
}
|
2013-02-18 03:16:38 +00:00
|
|
|
|
|
2014-05-29 22:30:03 +00:00
|
|
|
|
for (R = r.s.r + offset; R <= r.e.r; ++R) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
rr = encode_row(R);
|
2014-01-23 06:20:19 +00:00
|
|
|
|
isempty = true;
|
2014-05-29 22:30:03 +00:00
|
|
|
|
row = header === 1 ? [] : Object.create({ __rowNum__ : R });
|
2014-01-23 06:20:19 +00:00
|
|
|
|
for (C = r.s.c; C <= r.e.c; ++C) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
val = sheet[cols[C] + rr];
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(val === undefined || val.t === undefined) continue;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
v = val.v;
|
2014-05-03 18:51:10 +00:00
|
|
|
|
switch(val.t){
|
|
|
|
|
case 'e': continue;
|
|
|
|
|
case 's': case 'str': break;
|
|
|
|
|
case 'b': case 'n': break;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
default: throw 'unrecognized type ' + val.t;
|
2013-02-18 03:16:38 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
if(v !== undefined) {
|
2014-07-28 13:22:32 +00:00
|
|
|
|
row[hdr[C]] = raw ? v : format_cell(val,v);
|
2014-05-03 18:51:10 +00:00
|
|
|
|
isempty = false;
|
|
|
|
|
}
|
2013-02-18 03:16:38 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
if(isempty === false) out[outi++] = row;
|
2013-02-18 03:16:38 +00:00
|
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|
out.length = outi;
|
2014-01-23 06:20:19 +00:00
|
|
|
|
return out;
|
2013-02-18 03:16:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-28 13:22:32 +00:00
|
|
|
|
function sheet_to_row_object_array(sheet, opts) { return sheet_to_json(sheet, opts != null ? opts : {}); }
|
2014-05-29 22:30:03 +00:00
|
|
|
|
|
2014-01-23 06:20:19 +00:00
|
|
|
|
function sheet_to_csv(sheet, opts) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
var out = "", txt = "", qreg = /"/g;
|
|
|
|
|
var o = opts == null ? {} : opts;
|
|
|
|
|
if(sheet == null || sheet["!ref"] == null) return "";
|
|
|
|
|
var r = safe_decode_range(sheet["!ref"]);
|
|
|
|
|
var FS = o.FS !== undefined ? o.FS : ",", fs = FS.charCodeAt(0);
|
|
|
|
|
var RS = o.RS !== undefined ? o.RS : "\n", rs = RS.charCodeAt(0);
|
|
|
|
|
var row = "", rr = "", cols = [];
|
|
|
|
|
var i = 0, cc = 0, val;
|
|
|
|
|
var R = 0, C = 0;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(C = r.s.c; C <= r.e.c; ++C) cols[C] = encode_col(C);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(R = r.s.r; R <= r.e.r; ++R) {
|
|
|
|
|
row = "";
|
|
|
|
|
rr = encode_row(R);
|
|
|
|
|
for(C = r.s.c; C <= r.e.c; ++C) {
|
|
|
|
|
val = sheet[cols[C] + rr];
|
|
|
|
|
txt = val !== undefined ? ''+format_cell(val) : "";
|
|
|
|
|
for(i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) {
|
|
|
|
|
txt = "\"" + txt.replace(qreg, '""') + "\""; break; }
|
|
|
|
|
row += (C === r.s.c ? "" : FS) + txt;
|
2013-02-20 15:25:02 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
out += row + RS;
|
2013-02-20 15:25:02 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
return out;
|
2013-02-20 15:25:02 +00:00
|
|
|
|
}
|
2013-10-30 22:26:31 +00:00
|
|
|
|
var make_csv = sheet_to_csv;
|
2013-02-20 15:25:02 +00:00
|
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
|
function sheet_to_formulae(sheet) {
|
|
|
|
|
var cmds, y = "", x, val="";
|
|
|
|
|
if(sheet == null || sheet["!ref"] == null) return "";
|
2014-07-28 13:22:32 +00:00
|
|
|
|
var r = safe_decode_range(sheet['!ref']), rr = "", cols = [], C;
|
2014-06-29 18:29:45 +00:00
|
|
|
|
cmds = new Array((r.e.r-r.s.r+1)*(r.e.c-r.s.c+1));
|
|
|
|
|
var i = 0;
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(C = r.s.c; C <= r.e.c; ++C) cols[C] = encode_col(C);
|
2014-06-29 18:29:45 +00:00
|
|
|
|
for(var R = r.s.r; R <= r.e.r; ++R) {
|
|
|
|
|
rr = encode_row(R);
|
2014-07-28 13:22:32 +00:00
|
|
|
|
for(C = r.s.c; C <= r.e.c; ++C) {
|
2014-06-29 18:29:45 +00:00
|
|
|
|
y = cols[C] + rr;
|
|
|
|
|
x = sheet[y];
|
|
|
|
|
val = "";
|
|
|
|
|
if(x === undefined) continue;
|
|
|
|
|
if(x.f != null) val = x.f;
|
|
|
|
|
else if(x.w !== undefined) val = "'" + x.w;
|
|
|
|
|
else if(x.v === undefined) continue;
|
|
|
|
|
else val = ""+x.v;
|
|
|
|
|
cmds[i++] = y + "=" + val;
|
|
|
|
|
}
|
2013-04-17 01:32:20 +00:00
|
|
|
|
}
|
2014-06-29 18:29:45 +00:00
|
|
|
|
cmds.length = i;
|
2013-04-13 17:00:01 +00:00
|
|
|
|
return cmds;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-03 18:51:10 +00:00
|
|
|
|
var utils = {
|
2012-12-04 19:27:20 +00:00
|
|
|
|
encode_col: encode_col,
|
|
|
|
|
encode_row: encode_row,
|
|
|
|
|
encode_cell: encode_cell,
|
2013-02-20 16:02:00 +00:00
|
|
|
|
encode_range: encode_range,
|
2012-12-04 19:27:20 +00:00
|
|
|
|
decode_col: decode_col,
|
|
|
|
|
decode_row: decode_row,
|
|
|
|
|
split_cell: split_cell,
|
|
|
|
|
decode_cell: decode_cell,
|
2013-02-18 03:16:38 +00:00
|
|
|
|
decode_range: decode_range,
|
2014-06-29 18:29:45 +00:00
|
|
|
|
format_cell: format_cell,
|
|
|
|
|
get_formulae: sheet_to_formulae,
|
2013-10-30 22:26:31 +00:00
|
|
|
|
make_csv: sheet_to_csv,
|
2014-05-29 22:30:03 +00:00
|
|
|
|
make_json: sheet_to_json,
|
2014-06-29 18:29:45 +00:00
|
|
|
|
make_formulae: sheet_to_formulae,
|
|
|
|
|
sheet_to_csv: sheet_to_csv,
|
2014-05-29 22:30:03 +00:00
|
|
|
|
sheet_to_json: sheet_to_json,
|
2014-06-29 18:29:45 +00:00
|
|
|
|
sheet_to_formulae: sheet_to_formulae,
|
2013-02-18 03:16:38 +00:00
|
|
|
|
sheet_to_row_object_array: sheet_to_row_object_array
|
2012-12-04 19:27:20 +00:00
|
|
|
|
};
|
2014-05-16 00:33:34 +00:00
|
|
|
|
XLSX.parseZip = parse_zip;
|
2014-04-15 09:04:03 +00:00
|
|
|
|
XLSX.read = readSync;
|
|
|
|
|
XLSX.readFile = readFileSync;
|
2014-05-16 00:33:34 +00:00
|
|
|
|
XLSX.write = writeSync;
|
|
|
|
|
XLSX.writeFile = writeFileSync;
|
2014-05-03 18:51:10 +00:00
|
|
|
|
XLSX.utils = utils;
|
2014-04-15 09:04:03 +00:00
|
|
|
|
XLSX.SSF = SSF;
|
|
|
|
|
})(typeof exports !== 'undefined' ? exports : XLSX);
|