forked from sheetjs/sheetjs
Fix bad google sheets format 'd.m'
This commit is contained in:
parent
3b19491ee9
commit
e0fc89246a
@ -65,3 +65,12 @@ function dateNF_fix(str/*:string*/, dateNF/*:string*/, match/*:Array<string>*/)/
|
||||
return datestr + "T" + timestr;
|
||||
}
|
||||
|
||||
/* table of bad formats written by third-party tools */
|
||||
var bad_formats = {
|
||||
"d.m": "d\\.m" // Issue #2571 Google Sheets writes invalid format 'd.m', correct format is 'd"."m' or 'd\\.m'
|
||||
};
|
||||
|
||||
function SSF__load(fmt, idx) {
|
||||
return SSF_load(bad_formats[fmt] || fmt, idx);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ function parse_numFmts(t, styles, opts) {
|
||||
for(j = 0x188; j > 0x3c; --j) if(styles.NumberFmt[j] == null) break;
|
||||
styles.NumberFmt[j] = f;
|
||||
}
|
||||
SSF_load(f,j);
|
||||
SSF__load(f,j);
|
||||
}
|
||||
} break;
|
||||
case '</numFmt>': break;
|
||||
|
@ -215,7 +215,7 @@ function parse_sty_bin(data, themes, opts) {
|
||||
recordhopper(data, function hopper_sty(val, R, RT) {
|
||||
switch(RT) {
|
||||
case 0x002C: /* BrtFmt */
|
||||
styles.NumberFmt[val[0]] = val[1]; SSF_load(val[1], val[0]);
|
||||
styles.NumberFmt[val[0]] = val[1]; SSF__load(val[1], val[0]);
|
||||
break;
|
||||
case 0x002B: /* BrtFont */
|
||||
styles.Fonts.push(val);
|
||||
|
@ -62,7 +62,7 @@ function get_cell_style(styles/*:Array<any>*/, cell/*:Cell*/, opts) {
|
||||
var i = 0x3c, len = styles.length;
|
||||
if(z == null && opts.ssf) {
|
||||
for(; i < 0x188; ++i) if(opts.ssf[i] == null) {
|
||||
SSF_load(cell.z, i);
|
||||
SSF__load(cell.z, i);
|
||||
// $FlowIgnore
|
||||
opts.ssf[i] = cell.z;
|
||||
opts.revssf[cell.z] = z = i;
|
||||
@ -88,7 +88,7 @@ function safe_format(p/*:Cell*/, fmtid/*:number*/, fillid/*:?number*/, opts, the
|
||||
if(p.t === 'z' && !opts.cellStyles) return;
|
||||
if(p.t === 'd' && typeof p.v === 'string') p.v = parseDate(p.v);
|
||||
if((!opts || opts.cellText !== false) && p.t !== 'z') try {
|
||||
if(table_fmt[fmtid] == null) SSF_load(SSFImplicit[fmtid] || "General", fmtid);
|
||||
if(table_fmt[fmtid] == null) SSF__load(SSFImplicit[fmtid] || "General", fmtid);
|
||||
if(p.t === 'e') p.w = p.w || BErr[p.v];
|
||||
else if(fmtid === 0) {
|
||||
if(p.t === 'n') {
|
||||
|
@ -343,7 +343,7 @@ function parse_xlml_xml(d, _opts)/*:Workbook*/ {
|
||||
stag.nf = unescapexml(xlml_parsexmltag(Rn[0]).Format || "General");
|
||||
if(XLMLFormatMap[stag.nf]) stag.nf = XLMLFormatMap[stag.nf];
|
||||
for(var ssfidx = 0; ssfidx != 0x188; ++ssfidx) if(table_fmt[ssfidx] == stag.nf) break;
|
||||
if(ssfidx == 0x188) for(ssfidx = 0x39; ssfidx != 0x188; ++ssfidx) if(table_fmt[ssfidx] == null) { SSF_load(stag.nf, ssfidx); break; }
|
||||
if(ssfidx == 0x188) for(ssfidx = 0x39; ssfidx != 0x188; ++ssfidx) if(table_fmt[ssfidx] == null) { SSF__load(stag.nf, ssfidx); break; }
|
||||
break;
|
||||
|
||||
case 'column' /*case 'Column'*/:
|
||||
|
@ -488,14 +488,14 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
|
||||
if(opts.biff == 4) {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val[1];
|
||||
for(var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if(table_fmt[b4idx] == val[1]) break;
|
||||
if(b4idx >= 163) SSF_load(val[1], BIFF2Fmt + 163);
|
||||
if(b4idx >= 163) SSF__load(val[1], BIFF2Fmt + 163);
|
||||
}
|
||||
else SSF_load(val[1], val[0]);
|
||||
else SSF__load(val[1], val[0]);
|
||||
} break;
|
||||
case 0x001e /* BIFF2FORMAT */: {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val;
|
||||
for(var b2idx = 0; b2idx < BIFF2Fmt + 163; ++b2idx) if(table_fmt[b2idx] == val) break;
|
||||
if(b2idx >= 163) SSF_load(val, BIFF2Fmt + 163);
|
||||
if(b2idx >= 163) SSF__load(val, BIFF2Fmt + 163);
|
||||
} break;
|
||||
|
||||
case 0x00e5 /* MergeCells */: merges = merges.concat(val); break;
|
||||
|
Loading…
Reference in New Issue
Block a user