xsheetjs/bits/69_chartxml.js
SheetJS 663270b762 XLS/XLSX/XLSB Interpret Chartsheets as Data Tables
- chartsheets are now stored as sheets with "!type" set to "chart"
- fixed Strict XML Workbook Relationships
- stubbed support for dialog and macro sheets
- removed legacy XLS `!range` field
2017-03-27 17:41:14 -04:00

42 lines
1.1 KiB
JavaScript

function parse_numCache(data) {
var col = [];
/* 21.2.2.150 pt CT_NumVal */
(data.match(/<c:pt idx="(\d*)">(.*?)<\/c:pt>/mg)||[]).forEach(function(pt) {
var q = pt.match(/<c:pt idx="(.*?)"><c:v>(.*)<\/c:v><\/c:pt>/);
if(!q) return;
col[+q[1]] = +q[2];
});
/* 21.2.2.71 formatCode CT_Xstring */
var nf = unescapexml((data.match(/<c:formatCode>(.*?)<\/c:formatCode>/) || ["","General"])[1]);
return [col, nf];
}
/* 21.2 DrawingML - Charts */
function parse_chart(data, name/*:string*/, opts, rels, wb, csheet) {
var cs = ((csheet || {"!type":"chart"})/*:any*/);
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 */
(data.match(/<c:numCache>.*?<\/c:numCache>/gm)||[]).forEach(function(nc) {
var cache = parse_numCache(nc);
refguess.s.r = refguess.s.c = 0;
refguess.e.c = C;
col = encode_col(C);
cache[0].forEach(function(n,i) {
cs[col + encode_row(i)] = {t:'n', v:n, z:cache[1] };
R = i;
});
if(refguess.e.r < R) refguess.e.r = R;
++C;
});
if(C > 0) cs["!ref"] = encode_range(refguess);
return cs;
}