version bump 0.5.10-a: xlsx performance

- utf8 translation pushes to array rather than string concat
- large_strings test actually runs now (rather than blowing up)
This commit is contained in:
SheetJS 2014-02-22 16:36:28 -05:00
parent ad20bf9b83
commit ecee362e00
11 changed files with 41 additions and 41 deletions

@ -7,7 +7,7 @@ $(TARGET): $(DEPS)
cat $^ > $@
bits/31_version.js: package.json
echo "XLSX.version = '"`grep version package.json | awk '{gsub(/[^0-9\.]/,"",$$2); print $$2}'`"';" > $@
echo "XLSX.version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
.PHONY: clean
clean:

@ -1 +1 @@
XLSX.version = '0.5.10';
XLSX.version = '0.5.10-a';

@ -47,20 +47,20 @@ function parsexmlbool(value, tag) {
}
var utf8read = function(orig) {
var out = "", i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0;
var out = [], i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0;
while (i < orig.length) {
c = orig.charCodeAt(i++);
if (c < 128) out += _chr(c);
if (c < 128) out.push(_chr(c));
else {
c2 = orig.charCodeAt(i++);
if (c>191 && c<224) out += _chr((c & 31) << 6 | c2 & 63);
if (c>191 && c<224) out.push(_chr((c & 31) << 6 | c2 & 63));
else {
c3 = orig.charCodeAt(i++);
out += _chr((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
out.push(_chr((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63));
}
}
}
return out;
return out.join("");
};
// matches <foo>...</foo> extracts content

@ -37,7 +37,7 @@ var __readDoubleLE = function(b, idx) { return b.readDoubleLE ? b.readDoubleLE(i
function ReadShift(size, t) {
var o, w, vv, i, loc; t = t || 'u';
var o = "", oo = [], w, vv, i, loc; t = t || 'u';
if(size === 'ieee754') { size = 8; t = 'f'; }
switch(size) {
case 1: o = __readUInt8(this, this.l); break;
@ -49,11 +49,11 @@ function ReadShift(size, t) {
/* sbcs and dbcs support continue records in the SST way TODO codepages */
/* TODO: DBCS http://msdn.microsoft.com/en-us/library/cc194788.aspx */
case 'dbcs': size = 2*t; o = ""; loc = this.l;
case 'dbcs': size = 2*t; loc = this.l;
for(i = 0; i != t; ++i) {
o += _getchar(__readUInt16LE(this, loc));
oo.push(_getchar(__readUInt16LE(this, loc)));
loc+=2;
} break;
} o = oo.join(""); break;
case 'sbcs': size = t; o = ""; loc = this.l;
for(i = 0; i != t; ++i) {

@ -26,10 +26,7 @@ function parse_ws_xml(data, opts) {
cells.forEach(function(c, idx) { if(c === "" || c.trim() === "") return;
var cref = c.match(/r=["']([^"']*)["']/);
c = "<c " + c;
if(cref && cref.length == 2) {
var cref_cell = decode_cell(cref[1]);
idx = cref_cell.c;
}
if(cref && cref.length == 2) idx = decode_cell(cref[1]).c;
var cell = parsexmltag((c.match(/<c[^>]*>/)||[c])[0]); delete cell[0];
var d = c.substr(c.indexOf('>')+1);
var p = {};

@ -63,9 +63,9 @@ function sheet_to_csv(sheet, opts) {
default: throw 'unrecognized type ' + val.t;
}
};
var out = "", txt = "";
var out = [], txt = "";
opts = opts || {};
if(!sheet || !sheet["!ref"]) return out;
if(!sheet || !sheet["!ref"]) return "";
var r = XLSX.utils.decode_range(sheet["!ref"]);
var fs = opts.FS||",", rs = opts.RS||"\n";
@ -79,9 +79,9 @@ function sheet_to_csv(sheet, opts) {
txt = "\"" + txt.replace(/"/g, '""') + "\"";
row.push(txt);
}
out += row.join(fs) + (rs);
out.push(row.join(fs));
}
return out;
return out.join(rs) + (out.length ? rs : "");
}
var make_csv = sheet_to_csv;

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.5.10",
"version": "0.5.10-a",
"author": "sheetjs",
"description": "XLSB / XLSX / XLSM parser",
"keywords": [ "xlsx", "xlsb", "xlsm", "office", "excel", "spreadsheet" ],

@ -55,6 +55,12 @@ function parsetest(x, wb) {
describe(x + ' should generate correct output', function() {
wb.SheetNames.forEach(function(ws, i) {
var name = (dir + x + '.' + i + '.csv');
if(x.substr(-5) === ".xlsb") {
root = x.slice(0,-5);
//if(!fs.existsSync(name)) name=(dir + root + '.xlsx.'+i+'.csv');
//if(!fs.existsSync(name)) name=(dir + root + '.xlsm.'+i+'.csv');
//if(!fs.existsSync(name)) name=(dir + root + '.xls.'+i+'.csv');
}
it('#' + i + ' (' + ws + ')', fs.existsSync(name) ? function() {
var file = fs.readFileSync(name, 'utf-8');
var csv = XLSX.utils.make_csv(wb.Sheets[ws]);

@ -2,7 +2,7 @@ RkNumber.xlsb
comments_stress_test.xlsb
custom_properties.xlsb
formula_stress_test.xlsb
large_strings.xlsb.pending
large_strings.xlsb
merge_cells.xlsb
named_ranges_2011.xlsb
number_format.xlsb
@ -162,7 +162,7 @@ jxls-core_simple.xlsx
jxls-examples_stress1.xlsx
jxls-examples_stress2.xlsx
jxls-reader_departmentData.xlsx
large_strings.xlsx.pending
large_strings.xlsx
merge_cells.xlsx
mixed_sheets.xlsx
named_ranges_2011.xlsx

@ -1 +1 @@
Subproject commit 15d10e8eba67bafd07a406b3345c9309739b5da1
Subproject commit aad3f9c021d2b70fd4c288e001085b168eba6baf

33
xlsx.js

@ -423,7 +423,7 @@ SSF.load_table = function(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i]) SSF.loa
make_ssf(SSF);
var XLSX = {};
(function(XLSX){
XLSX.version = '0.5.10';
XLSX.version = '0.5.10-a';
var current_codepage, current_cptable, cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('codepage');
@ -518,20 +518,20 @@ function parsexmlbool(value, tag) {
}
var utf8read = function(orig) {
var out = "", i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0;
var out = [], i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0;
while (i < orig.length) {
c = orig.charCodeAt(i++);
if (c < 128) out += _chr(c);
if (c < 128) out.push(_chr(c));
else {
c2 = orig.charCodeAt(i++);
if (c>191 && c<224) out += _chr((c & 31) << 6 | c2 & 63);
if (c>191 && c<224) out.push(_chr((c & 31) << 6 | c2 & 63));
else {
c3 = orig.charCodeAt(i++);
out += _chr((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
out.push(_chr((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63));
}
}
}
return out;
return out.join("");
};
// matches <foo>...</foo> extracts content
@ -590,7 +590,7 @@ var __readDoubleLE = function(b, idx) { return b.readDoubleLE ? b.readDoubleLE(i
function ReadShift(size, t) {
var o, w, vv, i, loc; t = t || 'u';
var o = "", oo = [], w, vv, i, loc; t = t || 'u';
if(size === 'ieee754') { size = 8; t = 'f'; }
switch(size) {
case 1: o = __readUInt8(this, this.l); break;
@ -602,11 +602,11 @@ function ReadShift(size, t) {
/* sbcs and dbcs support continue records in the SST way TODO codepages */
/* TODO: DBCS http://msdn.microsoft.com/en-us/library/cc194788.aspx */
case 'dbcs': size = 2*t; o = ""; loc = this.l;
case 'dbcs': size = 2*t; loc = this.l;
for(i = 0; i != t; ++i) {
o += _getchar(__readUInt16LE(this, loc));
oo.push(_getchar(__readUInt16LE(this, loc)));
loc+=2;
} break;
} o = oo.join(""); break;
case 'sbcs': size = t; o = ""; loc = this.l;
for(i = 0; i != t; ++i) {
@ -1332,10 +1332,7 @@ function parse_ws_xml(data, opts) {
cells.forEach(function(c, idx) { if(c === "" || c.trim() === "") return;
var cref = c.match(/r=["']([^"']*)["']/);
c = "<c " + c;
if(cref && cref.length == 2) {
var cref_cell = decode_cell(cref[1]);
idx = cref_cell.c;
}
if(cref && cref.length == 2) idx = decode_cell(cref[1]).c;
var cell = parsexmltag((c.match(/<c[^>]*>/)||[c])[0]); delete cell[0];
var d = c.substr(c.indexOf('>')+1);
var p = {};
@ -2935,9 +2932,9 @@ function sheet_to_csv(sheet, opts) {
default: throw 'unrecognized type ' + val.t;
}
};
var out = "", txt = "";
var out = [], txt = "";
opts = opts || {};
if(!sheet || !sheet["!ref"]) return out;
if(!sheet || !sheet["!ref"]) return "";
var r = XLSX.utils.decode_range(sheet["!ref"]);
var fs = opts.FS||",", rs = opts.RS||"\n";
@ -2951,9 +2948,9 @@ function sheet_to_csv(sheet, opts) {
txt = "\"" + txt.replace(/"/g, '""') + "\"";
row.push(txt);
}
out += row.join(fs) + (rs);
out.push(row.join(fs));
}
return out;
return out.join(rs) + (out.length ? rs : "");
}
var make_csv = sheet_to_csv;