diff --git a/xlsx.js b/xlsx.js
index b2e6292..0c77957 100644
--- a/xlsx.js
+++ b/xlsx.js
@@ -95,15 +95,21 @@ var strs = {}; // shared strings
function parseSheet(data) { //TODO: use a real xml parser
var s = {};
- s["!ref"] = data.match(//)[1];
+ var ref = data.match(//);
+ if(ref) s["!ref"] = ref[1];
+ var refguess = {s: {r:1000000, c:1000000}, e: {r:0, c:0} };
//s.rows = {};
//s.cells = {};
var q = ["v","f"];
if(!data.match(//))
data.match(/(.*)<\/sheetData>/)[1].split("").forEach(function(x) { if(x === "") return;
var row = parsexmltag(x.match(/]*>/)[0]); //s.rows[row.r]=row.spans;
+ if(refguess.s.r > row.r - 1) refguess.s.r = row.r - 1;
+ if(refguess.e.r < row.r - 1) refguess.e.r = row.r - 1;
var cells = x.substr(x.indexOf('>')+1).split(/<\/c>|\/>/);
- cells.forEach(function(c) { if(c === "") return;
+ cells.forEach(function(c, idx) { if(c === "") return;
+ if(refguess.s.c > idx) refguess.s.c = idx;
+ if(refguess.e.c < idx) refguess.e.c = idx;
var cell = parsexmltag((c.match(/]*>/)||[c])[0]); delete cell[0];
var d = c.substr(c.indexOf('>')+1);
var p = {};
@@ -121,7 +127,8 @@ function parseSheet(data) { //TODO: use a real xml parser
s[cell.r] = p;
});
});
-
+ if(!s["!ref"]) s["!ref"] = encode_range(refguess);
+
if(debug) s.rawdata = data;
return s;
}
@@ -227,6 +234,7 @@ function parseWB(data) {
case '': delete y[0]; wb.CalcPr = y; break;
+ case '': break;
case '