2019-11-01 03:09:14 +00:00
|
|
|
function parse_Cache(data/*:string*/)/*:[Array<number|string>, string, ?string]*/ {
|
|
|
|
var col/*:Array<number|string>*/ = [];
|
|
|
|
var num = data.match(/^<c:numCache>/);
|
|
|
|
var f;
|
2017-03-27 21:35:15 +00:00
|
|
|
|
|
|
|
/* 21.2.2.150 pt CT_NumVal */
|
2024-04-05 01:20:28 +00:00
|
|
|
(data.match(/<c:pt idx="(\d*)"[^<>\/]*><c:v>([^<])<\/c:v><\/c:pt>/mg)||[]).forEach(function(pt) {
|
|
|
|
var q = pt.match(/<c:pt idx="(\d*)"[^<>\/]*><c:v>([^<]*)<\/c:v><\/c:pt>/);
|
2017-03-27 21:35:15 +00:00
|
|
|
if(!q) return;
|
2019-11-01 03:09:14 +00:00
|
|
|
col[+q[1]] = num ? +q[2] : q[2];
|
2017-03-27 21:35:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/* 21.2.2.71 formatCode CT_Xstring */
|
2024-04-05 01:20:28 +00:00
|
|
|
var nf = unescapexml((str_match_xml(data, "c:formatCode") || ["","General"])[1]);
|
2017-03-27 21:35:15 +00:00
|
|
|
|
2024-04-05 01:20:28 +00:00
|
|
|
(str_match_ng(data, "<c:f>", "</c:f>")||[]).forEach(function(F) { f = F.replace(/<[^<>]*>/g,""); });
|
2019-11-01 03:09:14 +00:00
|
|
|
|
|
|
|
return [col, nf, f];
|
2017-03-27 21:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 21.2 DrawingML - Charts */
|
2017-12-30 05:40:35 +00:00
|
|
|
function parse_chart(data/*:?string*/, name/*:string*/, opts, rels, wb, csheet) {
|
|
|
|
var cs/*:Worksheet*/ = ((csheet || {"!type":"chart"})/*:any*/);
|
2017-03-27 21:35:15 +00:00
|
|
|
if(!data) return csheet;
|
|
|
|
/* 21.2.2.27 chart CT_Chart */
|
|
|
|
|
|
|
|
var C = 0, R = 0, col = "A";
|
|
|
|
var refguess = {s: {r:2000000, c:2000000}, e: {r:0, c:0} };
|
|
|
|
|
|
|
|
/* 21.2.2.120 numCache CT_NumData */
|
2024-04-05 01:20:28 +00:00
|
|
|
(str_match_ng(data, "<c:numCache>", "</c:numCache>")||[]).forEach(function(nc) {
|
2019-11-01 03:09:14 +00:00
|
|
|
var cache = parse_Cache(nc);
|
2017-03-27 21:35:15 +00:00
|
|
|
refguess.s.r = refguess.s.c = 0;
|
|
|
|
refguess.e.c = C;
|
|
|
|
col = encode_col(C);
|
|
|
|
cache[0].forEach(function(n,i) {
|
2022-10-24 01:05:59 +00:00
|
|
|
if(cs["!data"]) {
|
|
|
|
if(!cs["!data"][i]) cs["!data"][i] = [];
|
|
|
|
cs["!data"][i][C] = {t:'n', v:n, z:cache[1] };
|
|
|
|
} else cs[col + encode_row(i)] = {t:'n', v:n, z:cache[1] };
|
2017-03-27 21:35:15 +00:00
|
|
|
R = i;
|
|
|
|
});
|
|
|
|
if(refguess.e.r < R) refguess.e.r = R;
|
|
|
|
++C;
|
|
|
|
});
|
|
|
|
if(C > 0) cs["!ref"] = encode_range(refguess);
|
|
|
|
return cs;
|
|
|
|
}
|