forked from sheetjs/sheetjs
version bump 0.3.9: general format used by default
(when no format or style is found, use general) Other whitespace cleanup
This commit is contained in:
parent
a1ccaf511d
commit
9c9aad5df3
@ -1 +1 @@
|
||||
XLSX.version = '0.3.8';
|
||||
XLSX.version = '0.3.9';
|
||||
|
@ -162,17 +162,17 @@ function parseSheet(data) {
|
||||
}
|
||||
|
||||
/* formatting */
|
||||
if(cell.s && styles.CellXf) { /* TODO: second check is a hacked guard */
|
||||
var fmtid = 0;
|
||||
if(cell.s && styles.CellXf) {
|
||||
var cf = styles.CellXf[cell.s];
|
||||
if(cf && cf.numFmtId && cf.numFmtId !== 0) {
|
||||
if(cf && cf.numFmtId) fmtid = cf.numFmtId;
|
||||
}
|
||||
p.raw = p.v;
|
||||
p.rawt = p.t;
|
||||
try {
|
||||
p.v = SSF.format(cf.numFmtId,p.v,_ssfopts);
|
||||
p.v = SSF.format(fmtid,p.v,_ssfopts);
|
||||
p.t = 'str';
|
||||
} catch(e) { p.v = p.raw; }
|
||||
}
|
||||
}
|
||||
} catch(e) { p.v = p.raw; p.t = p.rawt; }
|
||||
|
||||
s[cell.r] = p;
|
||||
});
|
||||
@ -456,19 +456,19 @@ function parseRels(data, currentFilePath) {
|
||||
var rels = {};
|
||||
|
||||
var resolveRelativePathIntoAbsolute = function (to) {
|
||||
var toksFrom = currentFilePath.split('/');
|
||||
var toksFrom = currentFilePath.split('/');
|
||||
toksFrom.pop(); // folder path
|
||||
var toksTo = to.split('/');
|
||||
var reversed = [];
|
||||
while (toksTo.length !== 0) {
|
||||
var tokTo = toksTo.shift();
|
||||
if (tokTo === '..') {
|
||||
toksFrom.pop();
|
||||
} else if (tokTo !== '.') {
|
||||
toksFrom.push(tokTo);
|
||||
}
|
||||
}
|
||||
return toksFrom.join('/');
|
||||
var toksTo = to.split('/');
|
||||
var reversed = [];
|
||||
while (toksTo.length !== 0) {
|
||||
var tokTo = toksTo.shift();
|
||||
if (tokTo === '..') {
|
||||
toksFrom.pop();
|
||||
} else if (tokTo !== '.') {
|
||||
toksFrom.push(tokTo);
|
||||
}
|
||||
}
|
||||
return toksFrom.join('/');
|
||||
}
|
||||
|
||||
data.match(/<[^>]*>/g).forEach(function(x) {
|
||||
|
@ -15,17 +15,16 @@ function sheet_to_row_object_array(sheet, opts){
|
||||
var val, row, r, hdr = {}, isempty, R, C, v;
|
||||
var out = [];
|
||||
opts = opts || {};
|
||||
if(!sheet["!ref"]) return out;
|
||||
if(!sheet || !sheet["!ref"]) return out;
|
||||
r = XLSX.utils.decode_range(sheet["!ref"]);
|
||||
for(R=r.s.r, C = r.s.c; C <= r.e.c; ++C) {
|
||||
val = sheet[encode_cell({c:C,r:R})];
|
||||
if(val){
|
||||
if(!val) continue;
|
||||
switch(val.t) {
|
||||
case 's': case 'str': hdr[C] = val.v; break;
|
||||
case 'n': hdr[C] = val.v; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (R = r.s.r + 1; R <= r.e.r; ++R) {
|
||||
isempty = true;
|
||||
@ -33,7 +32,7 @@ function sheet_to_row_object_array(sheet, opts){
|
||||
row = Object.create({ __rowNum__ : R });
|
||||
for (C = r.s.c; C <= r.e.c; ++C) {
|
||||
val = sheet[encode_cell({c: C,r: R})];
|
||||
if(!val) continue;
|
||||
if(!val || !val.t) continue;
|
||||
v = (val || {}).v;
|
||||
switch(val.t){
|
||||
case 's': case 'str': case 'b': case 'n':
|
||||
@ -66,7 +65,7 @@ function sheet_to_csv(sheet, opts) {
|
||||
};
|
||||
var out = "", txt = "";
|
||||
opts = opts || {};
|
||||
if(!sheet["!ref"]) return out;
|
||||
if(!sheet || !sheet["!ref"]) return out;
|
||||
var r = XLSX.utils.decode_range(sheet["!ref"]);
|
||||
for(var R = r.s.r; R <= r.e.r; ++R) {
|
||||
var row = [];
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xlsx",
|
||||
"version": "0.3.8",
|
||||
"version": "0.3.9",
|
||||
"author": "sheetjs",
|
||||
"description": "(one day) a full-featured XLSX parser and writer. For now, primitive parser",
|
||||
"keywords": [ "xlsx", "office", "excel", "spreadsheet" ],
|
||||
|
14
test.js
14
test.js
@ -29,6 +29,20 @@ function parsetest(x, wb) {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(x + ' should generate JSON', function() {
|
||||
wb.SheetNames.forEach(function(ws, i) {
|
||||
it('#' + i + ' (' + ws + ')', function() {
|
||||
var json = XLSX.utils.sheet_to_row_object_array(wb.Sheets[ws]);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(x + ' should generate formulae', function() {
|
||||
wb.SheetNames.forEach(function(ws, i) {
|
||||
it('#' + i + ' (' + ws + ')', function() {
|
||||
var json = XLSX.utils.get_formulae(wb.Sheets[ws]);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(x + ' should generate correct output', function() {
|
||||
wb.SheetNames.forEach(function(ws, i) {
|
||||
var name = ('./test_files/' + x + '.' + i + '.csv');
|
||||
|
47
xlsx.js
47
xlsx.js
@ -419,7 +419,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.3.8';
|
||||
XLSX.version = '0.3.9';
|
||||
function parsexmltag(tag) {
|
||||
var words = tag.split(/\s+/);
|
||||
var z = {'0': words[0]};
|
||||
@ -788,17 +788,17 @@ function parseSheet(data) {
|
||||
}
|
||||
|
||||
/* formatting */
|
||||
if(cell.s && styles.CellXf) { /* TODO: second check is a hacked guard */
|
||||
var fmtid = 0;
|
||||
if(cell.s && styles.CellXf) {
|
||||
var cf = styles.CellXf[cell.s];
|
||||
if(cf && cf.numFmtId && cf.numFmtId !== 0) {
|
||||
if(cf && cf.numFmtId) fmtid = cf.numFmtId;
|
||||
}
|
||||
p.raw = p.v;
|
||||
p.rawt = p.t;
|
||||
try {
|
||||
p.v = SSF.format(cf.numFmtId,p.v,_ssfopts);
|
||||
p.v = SSF.format(fmtid,p.v,_ssfopts);
|
||||
p.t = 'str';
|
||||
} catch(e) { p.v = p.raw; }
|
||||
}
|
||||
}
|
||||
} catch(e) { p.v = p.raw; p.t = p.rawt; }
|
||||
|
||||
s[cell.r] = p;
|
||||
});
|
||||
@ -1082,19 +1082,19 @@ function parseRels(data, currentFilePath) {
|
||||
var rels = {};
|
||||
|
||||
var resolveRelativePathIntoAbsolute = function (to) {
|
||||
var toksFrom = currentFilePath.split('/');
|
||||
var toksFrom = currentFilePath.split('/');
|
||||
toksFrom.pop(); // folder path
|
||||
var toksTo = to.split('/');
|
||||
var reversed = [];
|
||||
while (toksTo.length !== 0) {
|
||||
var tokTo = toksTo.shift();
|
||||
if (tokTo === '..') {
|
||||
toksFrom.pop();
|
||||
} else if (tokTo !== '.') {
|
||||
toksFrom.push(tokTo);
|
||||
}
|
||||
}
|
||||
return toksFrom.join('/');
|
||||
var toksTo = to.split('/');
|
||||
var reversed = [];
|
||||
while (toksTo.length !== 0) {
|
||||
var tokTo = toksTo.shift();
|
||||
if (tokTo === '..') {
|
||||
toksFrom.pop();
|
||||
} else if (tokTo !== '.') {
|
||||
toksFrom.push(tokTo);
|
||||
}
|
||||
}
|
||||
return toksFrom.join('/');
|
||||
}
|
||||
|
||||
data.match(/<[^>]*>/g).forEach(function(x) {
|
||||
@ -1304,17 +1304,16 @@ function sheet_to_row_object_array(sheet, opts){
|
||||
var val, row, r, hdr = {}, isempty, R, C, v;
|
||||
var out = [];
|
||||
opts = opts || {};
|
||||
if(!sheet["!ref"]) return out;
|
||||
if(!sheet || !sheet["!ref"]) return out;
|
||||
r = XLSX.utils.decode_range(sheet["!ref"]);
|
||||
for(R=r.s.r, C = r.s.c; C <= r.e.c; ++C) {
|
||||
val = sheet[encode_cell({c:C,r:R})];
|
||||
if(val){
|
||||
if(!val) continue;
|
||||
switch(val.t) {
|
||||
case 's': case 'str': hdr[C] = val.v; break;
|
||||
case 'n': hdr[C] = val.v; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (R = r.s.r + 1; R <= r.e.r; ++R) {
|
||||
isempty = true;
|
||||
@ -1322,7 +1321,7 @@ function sheet_to_row_object_array(sheet, opts){
|
||||
row = Object.create({ __rowNum__ : R });
|
||||
for (C = r.s.c; C <= r.e.c; ++C) {
|
||||
val = sheet[encode_cell({c: C,r: R})];
|
||||
if(!val) continue;
|
||||
if(!val || !val.t) continue;
|
||||
v = (val || {}).v;
|
||||
switch(val.t){
|
||||
case 's': case 'str': case 'b': case 'n':
|
||||
@ -1355,7 +1354,7 @@ function sheet_to_csv(sheet, opts) {
|
||||
};
|
||||
var out = "", txt = "";
|
||||
opts = opts || {};
|
||||
if(!sheet["!ref"]) return out;
|
||||
if(!sheet || !sheet["!ref"]) return out;
|
||||
var r = XLSX.utils.decode_range(sheet["!ref"]);
|
||||
for(var R = r.s.r; R <= r.e.r; ++R) {
|
||||
var row = [];
|
||||
|
Loading…
Reference in New Issue
Block a user