diff --git a/.npmignore b/.npmignore index dcaf716..f861188 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,3 @@ +test_files/ +tests/files/ index.html diff --git a/xlsx.js b/xlsx.js index f2fd59c..1c030f8 100644 --- a/xlsx.js +++ b/xlsx.js @@ -672,7 +672,7 @@ function parseCT(data) { if(!data) return data; var ct = { workbooks: [], sheets: [], calcchains: [], themes: [], styles: [], coreprops: [], extprops: [], strs:[], xmlns: "" }; - data.match(/<[^>]*>/g).forEach(function(x) { + (data.match(/<[^>]*>/g)||[]).forEach(function(x) { var y = parsexmltag(x); switch(y[0]) { case '<?xml': break; @@ -1043,11 +1043,11 @@ function sheet_to_csv(sheet) { }; var out = ""; if(sheet["!ref"]) { - var r = utils.decode_range(sheet["!ref"]); + var r = XLSX.utils.decode_range(sheet["!ref"]); for(var R = r.s.r; R <= r.e.r; ++R) { var row = []; for(var C = r.s.c; C <= r.e.c; ++C) { - var val = sheet[utils.encode_cell({c:C,r:R})]; + var val = sheet[XLSX.utils.encode_cell({c:C,r:R})]; row.push(val ? stringify(val).replace(/\\r\\n/g,"\n").replace(/\\t/g,"\t").replace(/\\\\/g,"\\").replace("\\\"","\"\"") : ""); } out += row.join(",") + "\n"; @@ -1070,7 +1070,7 @@ function get_formulae(ws) { return cmds; } -var utils = { +XLSX.utils = { encode_col: encode_col, encode_row: encode_row, encode_cell: encode_cell, @@ -1089,7 +1089,7 @@ var utils = { if(typeof require !== 'undefined' && typeof exports !== 'undefined') { exports.read = XLSX.read; exports.readFile = XLSX.readFile; - exports.utils = utils; + exports.utils = XLSX.utils; exports.main = function(args) { var zip = XLSX.read(args[0], {type:'file'}); console.log(zip.Sheets);