updating to 0.11.13

This commit is contained in:
SheetJS 2017-12-09 02:23:04 -05:00
parent 6c0dfc7a1a
commit 2bfa757670
4 changed files with 58 additions and 34 deletions

@ -31,7 +31,7 @@ if(typeof process != 'undefined' && ((process||{}).env)) {
if(process.env.FMTS) ex=process.env.FMTS.split(":").map(function(x){return x[0]==="."?x:"."+x;});
}
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 || ex.indexOf(x.substr(-4))>=0||exp.indexOf(x.substr(-12))>=0; }
function test_file(x){ return ex.indexOf(x.slice(-5))>=0||exp.indexOf(x.slice(-13))>=0 || ex.indexOf(x.slice(-4))>=0||exp.indexOf(x.slice(-12))>=0; }
var files = browser ? [] : (fs.existsSync('tests.lst') ? fs.readFileSync('tests.lst', 'utf-8').split("\n").map(function(x) { return x.trim(); }) : fs.readdirSync('test_files')).filter(test_file);
var fileA = browser ? [] : (fs.existsSync('tests/testA.lst') ? fs.readFileSync('tests/testA.lst', 'utf-8').split("\n").map(function(x) { return x.trim(); }) : []).filter(test_file);
@ -623,7 +623,7 @@ describe('output formats', function() {
["csv", true, true],
["txt", true, true],
["sylk", false, true],
["eth", true, true],
["eth", false, true],
["html", true, true],
["dif", false, true],
["dbf", false, false],
@ -1686,7 +1686,7 @@ var html_bstr = make_html_str(1), html_str = make_html_str(0);
var csv_bstr = make_csv_str(1), csv_str = make_csv_str(0);
describe('csv', function() {
describe('CSV', function() {
describe('input', function(){
var b = "1,2,3,\nTRUE,FALSE,,sheetjs\nfoo,bar,2/19/14,0.3\n,,,\nbaz,,qux,\n";
it('should generate date numbers by default', function() {
@ -1743,6 +1743,13 @@ describe('csv', function() {
assert.equal(get_cell(sheet, "C1").t, 's');
assert.equal(get_cell(sheet, "C1").v, '100');
});
if(!browser || typeof cptable !== 'undefined') it('should honor codepage for binary strings', function() {
var data = "abc,def\nghi,j\xD3l";
[[1251, 'У'],[1252, 'Ó'], [1253, 'Σ'], [1254, 'Ó'], [1255, '׃'], [1256, 'س'], [10000, '”']].forEach(function(m) {
var ws = X.read(data, {type:"binary", codepage:m[0]}).Sheets.Sheet1;
assert.equal(get_cell(ws, "B2").v, "j" + m[1] + "l");
});
});
});
describe('output', function(){
var data, ws;
@ -1868,6 +1875,12 @@ describe('HTML', function() {
assert.equal(get_cell(wb.Sheets.Sheet1, "A1").v, "foo\nbar");
});
});
if(domtest) it('should handle entities', function() {
var html = "<table><tr><td>A&amp;B</td><td>A&middot;B</td></tr></table>";
var ws = X.utils.table_to_sheet(get_dom_element(html));
assert.equal(get_cell(ws, "A1").v, "A&B");
assert.equal(get_cell(ws, "B1").v, "A·B");
});
});
describe('js -> file -> js', function() {

26
xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

24
xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

23
xlsx.js

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.11.12';
XLSX.version = '0.11.13';
var current_codepage = 1200;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -2113,9 +2113,17 @@ var matchtag = (function() {
};
})();
function htmldecode(str) {
return str.trim().replace(/\s+/g, " ").replace(/<\s*[bB][rR]\s*\/?>/g,"\n").replace(/<[^>]*>/g,"").replace(/&nbsp;/g, " ");
}
var htmldecode = (function() {
var entities = [
['nbsp', ' '], ['middot', '·'],
['quot', '"'], ['apos', "'"], ['gt', '>'], ['lt', '<'], ['amp', '&']
].map(function(x) { return [new RegExp('&' + x[0] + ';', "g"), x[1]]; });
return function htmldecode(str) {
var o = str.trim().replace(/\s+/g, " ").replace(/<\s*[bB][rR]\s*\/?>/g,"\n").replace(/<[^>]*>/g,"");
for(var i = 0; i < entities.length; ++i) o = o.replace(entities[i][0], entities[i][1]);
return o;
};
})();
var vtregex = (function(){ var vt_cache = {};
return function vt_regex(bt) {
@ -6248,6 +6256,7 @@ var PRN = (function() {
default: throw new Error("Unrecognized type " + opts.type);
}
if(bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) str = utf8read(str.slice(3));
else if((opts.type == 'binary' || opts.type == 'buffer') && typeof cptable !== 'undefined' && opts.codepage) str = cptable.utils.decode(opts.codepage, cptable.utils.encode(1252,str));
if(str.slice(0,19) == "socialcalc:version:") return ETH.to_sheet(opts.type == 'string' ? str : utf8read(str), opts);
return prn_to_sheet_str(str, opts);
}
@ -15029,6 +15038,7 @@ function parse_workbook(blob, options) {
/* explicit override for some broken writers */
opts.codepage = 1200;
set_cp(1200);
var seen_codepage = false;
while(blob.l < blob.length - 1) {
var s = blob.l;
var RecordType = blob.read_shift(2);
@ -15075,8 +15085,8 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
case 0x8000: val = 10000; break;
case 0x8001: val = 1252; break;
}
opts.codepage = val;
set_cp(val);
set_cp(opts.codepage = val);
seen_codepage = true;
break;
case 'RRTabId': opts.rrtabid = val; break;
case 'WinProtect': opts.winlocked = val; break;
@ -15174,6 +15184,7 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
cell_valid = true;
out = ((options.dense ? [] : {}));
if(opts.biff < 8 && !seen_codepage) { seen_codepage = true; set_cp(opts.codepage = options.codepage || 1252); }
if(opts.biff < 5) {
if(cur_sheet === "") cur_sheet = "Sheet1";
range = {s:{r:0,c:0},e:{r:0,c:0}};