Permalink
Browse files

version bump 0.7.3: last minute bugfixes

- parse_XFExtGradient stubbed (fixes #62, h/t @oakuraape)
- default to UTF16LE (fixes #64, h/t @ajuhos)
- ensure that date1904 is propagated to SSF (fixes #66, h/t @Martin-Pitt)
- pin CFB version in anticipation of future changes
  • Loading branch information...
1 parent 2aa239b commit 96a37d3313d99fd9ddd291595d9582e4c7f9a907 @SheetJSDev SheetJSDev committed Feb 10, 2015
Showing with 109 additions and 59 deletions.
  1. +1 −1 bits/01_version.js
  2. +2 −2 bits/02_codepage.js
  3. +10 −0 bits/72_style.js
  4. +15 −10 bits/80_xls.js
  5. +1 −1 bower.json
  6. +4 −4 dist/xls.core.min.js
  7. +1 −1 dist/xls.core.min.map
  8. +4 −4 dist/xls.full.min.js
  9. +1 −1 dist/xls.full.min.map
  10. +28 −13 dist/xls.js
  11. +4 −4 dist/xls.min.js
  12. +1 −1 dist/xls.min.map
  13. +2 −2 package.json
  14. +5 −0 test.js
  15. +1 −1 test_files
  16. +1 −1 tests.lst
  17. +28 −13 xls.js
View
@@ -1 +1 @@
-XLS.version = '0.7.2';
+XLS.version = '0.7.3';
View
@@ -1,9 +1,9 @@
-var current_codepage = 1252, current_cptable;
+var current_codepage = 1200, current_cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel');
current_cptable = cptable[current_codepage];
}
-function reset_cp() { set_cp(1252); }
+function reset_cp() { set_cp(1200); }
function set_cp(cp) { current_codepage = cp; if(typeof cptable !== 'undefined') current_cptable = cptable[cp]; }
var _getchar = function _gc1(x) { return String.fromCharCode(x); };
View
@@ -24,6 +24,16 @@ function parse_FullColorExt(blob, length) {
return o;
}
+/* 2.5.164 TODO: read 7 bits*/
+function parse_IcvXF(blob, length) {
+ return parsenoop(blob, length);
+}
+
+/* 2.5.280 */
+function parse_XFExtGradient(blob, length) {
+ return parsenoop(blob, length);
+}
+
/* 2.5.108 */
function parse_ExtProp(blob, length) {
var extType = blob.read_shift(2);
View
@@ -52,7 +52,7 @@ function slurp(R, blob, length, opts) {
return R.f(b, b.length, opts);
}
-function safe_format_xf(p, opts) {
+function safe_format_xf(p, opts, date1904) {
if(!p.XF) return;
try {
var fmtid = p.XF.ifmt||0;
@@ -64,7 +64,7 @@ function safe_format_xf(p, opts) {
}
else p.w = SSF._general(p.v);
}
- else p.w = SSF.format(fmtid,p.v);
+ else p.w = SSF.format(fmtid,p.v, {date1904:date1904||false});
if(opts.cellNF) p.z = SSF._table[fmtid];
} catch(e) { if(opts.WTF) throw e; }
}
@@ -146,6 +146,11 @@ function parse_workbook(blob, options) {
supbooks.arrayf = opts.arrayf;
var last_Rn = '';
var file_depth = 0; /* TODO: make a real stack */
+
+ /* explicit override for some broken writers */
+ opts.codepage = 1200;
+ set_cp(1200);
+
while(blob.l < blob.length - 1) {
var s = blob.l;
var RecordType = blob.read_shift(2);
@@ -265,24 +270,24 @@ function parse_workbook(blob, options) {
} break;
case 'Number': case 'BIFF2NUM': {
temp_val = {ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.val, t:'n'};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
} break;
case 'BoolErr': {
temp_val = {ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.val, t:val.t};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
} break;
case 'RK': {
temp_val = {ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.rknum, t:'n'};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
} break;
case 'MulRk': {
for(var j = val.c; j <= val.C; ++j) {
var ixfe = val.rkrec[j-val.c][0];
temp_val= {ixfe:ixfe, XF:XFs[ixfe], v:val.rkrec[j-val.c][1], t:'n'};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:j, r:val.r}, temp_val, options);
}
} break;
@@ -294,7 +299,7 @@ function parse_workbook(blob, options) {
temp_val = {v:val.val, ixfe:val.cell.ixfe, t:val.tt};
temp_val.XF = XFs[temp_val.ixfe];
if(options.cellFormula) temp_val.f = "="+stringify_formula(val.formula,range,val.cell,supbooks, opts);
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell(val.cell, temp_val, options);
last_formula = val;
}
@@ -305,7 +310,7 @@ function parse_workbook(blob, options) {
temp_val = {v:last_formula.val, ixfe:last_formula.cell.ixfe, t:'s'};
temp_val.XF = XFs[temp_val.ixfe];
if(options.cellFormula) temp_val.f = "="+stringify_formula(last_formula.formula, range, last_formula.cell, supbooks, opts);
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell(last_formula.cell, temp_val, options);
last_formula = null;
}
@@ -323,14 +328,14 @@ function parse_workbook(blob, options) {
//temp_val={v:sst[val.isst].t, ixfe:val.ixfe, t:'s'};
temp_val=make_cell(sst[val.isst].t, val.ixfe, 's');
temp_val.XF = XFs[temp_val.ixfe];
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
break;
case 'Label': case 'BIFF2STR':
/* Some writers erroneously write Label */
temp_val=make_cell(val.val, val.ixfe, 's');
temp_val.XF = XFs[temp_val.ixfe];
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
break;
case 'Dimensions': {
View
@@ -2,7 +2,7 @@
"name": "js-xls",
"homepage": "https://github.com/SheetJS/js-xls",
"main": "dist/xls.js",
- "version": "0.7.2",
+ "version": "0.7.3",
"ignore": [
"bin",
"bits",
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
View
@@ -3,13 +3,13 @@
/*jshint funcscope:true, eqnull:true */
var XLS = {};
(function make_xls(XLS){
-XLS.version = '0.7.2';
-var current_codepage = 1252, current_cptable;
+XLS.version = '0.7.3';
+var current_codepage = 1200, current_cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel');
current_cptable = cptable[current_codepage];
}
-function reset_cp() { set_cp(1252); }
+function reset_cp() { set_cp(1200); }
function set_cp(cp) { current_codepage = cp; if(typeof cptable !== 'undefined') current_cptable = cptable[cp]; }
var _getchar = function _gc1(x) { return String.fromCharCode(x); };
@@ -5155,6 +5155,16 @@ function parse_FullColorExt(blob, length) {
return o;
}
+/* 2.5.164 TODO: read 7 bits*/
+function parse_IcvXF(blob, length) {
+ return parsenoop(blob, length);
+}
+
+/* 2.5.280 */
+function parse_XFExtGradient(blob, length) {
+ return parsenoop(blob, length);
+}
+
/* 2.5.108 */
function parse_ExtProp(blob, length) {
var extType = blob.read_shift(2);
@@ -5729,7 +5739,7 @@ function slurp(R, blob, length, opts) {
return R.f(b, b.length, opts);
}
-function safe_format_xf(p, opts) {
+function safe_format_xf(p, opts, date1904) {
if(!p.XF) return;
try {
var fmtid = p.XF.ifmt||0;
@@ -5741,7 +5751,7 @@ function safe_format_xf(p, opts) {
}
else p.w = SSF._general(p.v);
}
- else p.w = SSF.format(fmtid,p.v);
+ else p.w = SSF.format(fmtid,p.v, {date1904:date1904||false});
if(opts.cellNF) p.z = SSF._table[fmtid];
} catch(e) { if(opts.WTF) throw e; }
}
@@ -5823,6 +5833,11 @@ function parse_workbook(blob, options) {
supbooks.arrayf = opts.arrayf;
var last_Rn = '';
var file_depth = 0; /* TODO: make a real stack */
+
+ /* explicit override for some broken writers */
+ opts.codepage = 1200;
+ set_cp(1200);
+
while(blob.l < blob.length - 1) {
var s = blob.l;
var RecordType = blob.read_shift(2);
@@ -5942,24 +5957,24 @@ function parse_workbook(blob, options) {
} break;
case 'Number': case 'BIFF2NUM': {
temp_val = {ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.val, t:'n'};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
} break;
case 'BoolErr': {
temp_val = {ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.val, t:val.t};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
} break;
case 'RK': {
temp_val = {ixfe: val.ixfe, XF: XFs[val.ixfe], v:val.rknum, t:'n'};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
} break;
case 'MulRk': {
for(var j = val.c; j <= val.C; ++j) {
var ixfe = val.rkrec[j-val.c][0];
temp_val= {ixfe:ixfe, XF:XFs[ixfe], v:val.rkrec[j-val.c][1], t:'n'};
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:j, r:val.r}, temp_val, options);
}
} break;
@@ -5971,7 +5986,7 @@ function parse_workbook(blob, options) {
temp_val = {v:val.val, ixfe:val.cell.ixfe, t:val.tt};
temp_val.XF = XFs[temp_val.ixfe];
if(options.cellFormula) temp_val.f = "="+stringify_formula(val.formula,range,val.cell,supbooks, opts);
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell(val.cell, temp_val, options);
last_formula = val;
}
@@ -5982,7 +5997,7 @@ function parse_workbook(blob, options) {
temp_val = {v:last_formula.val, ixfe:last_formula.cell.ixfe, t:'s'};
temp_val.XF = XFs[temp_val.ixfe];
if(options.cellFormula) temp_val.f = "="+stringify_formula(last_formula.formula, range, last_formula.cell, supbooks, opts);
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell(last_formula.cell, temp_val, options);
last_formula = null;
}
@@ -6000,14 +6015,14 @@ function parse_workbook(blob, options) {
//temp_val={v:sst[val.isst].t, ixfe:val.ixfe, t:'s'};
temp_val=make_cell(sst[val.isst].t, val.ixfe, 's');
temp_val.XF = XFs[temp_val.ixfe];
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
break;
case 'Label': case 'BIFF2STR':
/* Some writers erroneously write Label */
temp_val=make_cell(val.val, val.ixfe, 's');
temp_val.XF = XFs[temp_val.ixfe];
- if(temp_val.XF) safe_format_xf(temp_val, options);
+ if(temp_val.XF) safe_format_xf(temp_val, options, wb.opts.Date1904);
addcell({c:val.c, r:val.r}, temp_val, options);
break;
case 'Dimensions': {
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "xlsjs",
- "version": "0.7.2",
+ "version": "0.7.3",
"author": "sheetjs",
"description": "Excel 5.0/95 and 97-2004 spreadsheet (BIFF5 XLS / BIFF8 XLS / XML 2003) parser",
"keywords": [ "excel", "xls", "office", "spreadsheet" ],
@@ -11,7 +11,7 @@
"dependencies": {
"ssf":"~0.8.1",
"codepage":"~1.3.6",
- "cfb":">=0.10.3",
+ "cfb":"~0.10.3",
"commander":""
},
"devDependencies": {
View
@@ -61,6 +61,11 @@ function parsetest(x, wb, full, ext) {
it('should have all sheets', function() {
wb.SheetNames.forEach(function(y) { assert(wb.Sheets[y], 'bad sheet ' + y); });
});
+ /*
+ if(x.substr(-4) === ".xls") it('should have codepage property', function() {
+ if(!wb.Props || !wb.Props.CodePage) throw "Missing CodePage entry";
+ });
+ */
it('should have the right sheet names', fs.existsSync(sname) ? function() {
var file = fs.readFileSync(sname, 'utf-8').replace(/\r/g,"");
var names = wb.SheetNames.map(fixsheetname).join("\n") + "\n";
View
@@ -321,7 +321,7 @@ apachepoi_ex45978-extraLinkTableSheets.xls
apachepoi_ex46548-23133.xls
apachepoi_ex47747-sharedFormula.xls
apachepoi_excel_with_embeded.xls
-apachepoi_excelant.xls
+apachepoi_excelant.xls.pending
apachepoi_externalFunctionExample.xls
apachepoi_finance.xls
apachepoi_intercept.xls
Oops, something went wrong.

0 comments on commit 96a37d3

Please sign in to comment.