diff --git a/.gitignore b/.gitignore index b512c09..865fd19 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +misc/coverage.html diff --git a/bits/39_parsestructs.js b/bits/39_parsestructs.js index 5cffb34..0135fe1 100644 --- a/bits/39_parsestructs.js +++ b/bits/39_parsestructs.js @@ -2,7 +2,7 @@ /* [MS-XLSB] 2.5.143 */ var parse_StrRun = function(data, length) { return { ich: data.read_shift(2), ifnt: data.read_shift(2) }; -} +}; /* [MS-XLSB] 2.1.7.121 */ var parse_RichStr = function(data, length) { diff --git a/test.js b/test.js index 10540b8..ad8e5d5 100644 --- a/test.js +++ b/test.js @@ -5,7 +5,6 @@ describe('source',function(){ it('should load', function(){ XLSX = require('./') var ex = [".xlsb", ".xlsm", ".xlsx"]; if(process.env.FMTS) ex=process.env.FMTS.split(":").map(function(x){return x[0]==="."?x:"."+x;}); -console.log(ex, process.env.FMTS); var exp = ex.map(function(x){ return x + ".pending"; }); function test_file(x){return ex.indexOf(x.substr(-5))>=0||exp.indexOf(x.substr(-13))>=0;} @@ -113,7 +112,6 @@ describe('options', function() { var found = false; wb.SheetNames.forEach(function(s) { var ws = wb.Sheets[s]; - console.log(ws); Object.keys(ws).forEach(function(addr) { if(addr[0] === "!" || !ws.hasOwnProperty(addr)) return; if(typeof ws[addr].f !== 'undefined') return found = true; @@ -131,4 +129,32 @@ describe('options', function() { }); }); }); + it('should not generate sheet stubs by default', function() { + var wb = XLSX.readFile('./test_files/merge_cells.xlsx'); + assert.throws(function() { wb.Sheets.Merge.A2.v; }); + }); + it('should generate sheet stubs when requested', function() { + var wb = XLSX.readFile('./test_files/merge_cells.xlsx', {sheetStubs:true}); + assert(typeof wb.Sheets.Merge.A2.t !== 'undefined'); + }); + it('should not generate number formats by default', function() { + var wb = XLSX.readFile('./test_files/number_format.xlsm'); + wb.SheetNames.forEach(function(s) { + var ws = wb.Sheets[s]; + Object.keys(ws).forEach(function(addr) { + if(addr[0] === "!" || !ws.hasOwnProperty(addr)) return; + assert(typeof ws[addr].z === 'undefined'); + }); + }); + }); + it('should generate number formats when requested', function() { + var wb = XLSX.readFile('./test_files/number_format.xlsm', {cellNF: true}); + wb.SheetNames.forEach(function(s) { + var ws = wb.Sheets[s]; + Object.keys(ws).forEach(function(addr) { + if(addr[0] === "!" || !ws.hasOwnProperty(addr)) return; + assert(typeof ws[addr].t !== 'n' || typeof ws[addr].z !== 'undefined'); + }); + }); + }); }); diff --git a/xlsx.js b/xlsx.js index 6d2a6f6..f2bf3d8 100644 --- a/xlsx.js +++ b/xlsx.js @@ -639,7 +639,7 @@ var recordhopper = function(data, cb, opts) { /* [MS-XLSB] 2.5.143 */ var parse_StrRun = function(data, length) { return { ich: data.read_shift(2), ifnt: data.read_shift(2) }; -} +}; /* [MS-XLSB] 2.1.7.121 */ var parse_RichStr = function(data, length) {