version bump 0.14.4

- CFB update (fixes #1149 h/t @xjnotxj)
- SYLK character encoding (fixes #1544 h/t @Slayess)
- DBF and SYLK ANSI codepage support
This commit is contained in:
SheetJS 2019-07-20 23:32:02 -04:00
parent 2fc52cce3e
commit 9aabf36142
17 changed files with 437 additions and 137 deletions

@ -1 +1 @@
XLSX.version = '0.14.3';
XLSX.version = '0.14.4';

@ -62,8 +62,9 @@ var debom = function(data/*:string*/)/*:string*/ {
};
var _getchar = function _gc1(x/*:number*/)/*:string*/ { return String.fromCharCode(x); };
var _getansi = function _ga1(x/*:number*/)/*:string*/ { return String.fromCharCode(x); };
if(typeof cptable !== 'undefined') {
set_cp = function(cp/*:number*/) { current_codepage = cp; };
set_cp = function(cp/*:number*/) { current_codepage = cp; set_ansi(cp); };
debom = function(data/*:string*/) {
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.slice(2))); }
return data;
@ -72,4 +73,7 @@ if(typeof cptable !== 'undefined') {
if(current_codepage === 1200) return String.fromCharCode(x);
return cptable.utils.decode(current_codepage, [x&255,x>>8])[0];
};
_getansi = function _ga2(x/*:number*/)/*:string*/ {
return cptable.utils.decode(current_ansi, [x])[0];
}
}

@ -142,7 +142,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
exports.version = '1.1.0';
exports.version = '1.1.2';
/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
@ -337,7 +337,8 @@ function check_get_mver(blob/*:CFBlob*/)/*:[number, number]*/ {
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
// clsid 16
blob.chk(HEADER_CLSID, 'CLSID: ');
//blob.chk(HEADER_CLSID, 'CLSID: ');
blob.l += 16;
// minor version 2
var mver/*:number*/ = blob.read_shift(2, 'u');
@ -389,8 +390,8 @@ function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Arr
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
}
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
if(L !== -1) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
if(L !== -1 && i != dad[i]) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1 && i != dad[i]) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
}
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
@ -399,13 +400,12 @@ function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Arr
for(i=1; i < pl; ++i) {
if(FI[i].type === 0 /* unknown */) continue;
j = dad[i];
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
else while(j !== 0 && j !== dad[j]) {
FP[i] = FP[j] + "/" + FP[i];
j = i;
if(j != dad[j]) do {
j = dad[j];
}
dad[i] = 0;
FP[i] = FP[j] + "/" + FP[i];
} while (j !== 0 && -1 !== dad[j] && j != dad[j]);
dad[i] = -1;
}
FP[0] += "/";

@ -39,7 +39,22 @@ var dbf_codepage_map = {
/*::[*/0xFF/*::]*/: 16969
};
var dbf_reverse_map = evert({
/*::[*/0x01/*::]*/: 437, /*::[*/0x02/*::]*/: 850,
/*::[*/0x03/*::]*/: 1252, /*::[*/0x04/*::]*/: 10000,
/*::[*/0x64/*::]*/: 852, /*::[*/0x65/*::]*/: 866,
/*::[*/0x66/*::]*/: 865, /*::[*/0x67/*::]*/: 861,
/*::[*/0x68/*::]*/: 895, /*::[*/0x69/*::]*/: 620,
/*::[*/0x6A/*::]*/: 737, /*::[*/0x6B/*::]*/: 857,
/*::[*/0x78/*::]*/: 950, /*::[*/0x79/*::]*/: 949,
/*::[*/0x7A/*::]*/: 936, /*::[*/0x7B/*::]*/: 932,
/*::[*/0x7C/*::]*/: 874, /*::[*/0x7D/*::]*/: 1255,
/*::[*/0x7E/*::]*/: 1256, /*::[*/0x96/*::]*/: 10007,
/*::[*/0x97/*::]*/: 10029, /*::[*/0x98/*::]*/: 10006,
/*::[*/0xC8/*::]*/: 1250, /*::[*/0xC9/*::]*/: 1251,
/*::[*/0xCA/*::]*/: 1254, /*::[*/0xCB/*::]*/: 1253,
/*::[*/0x00/*::]*/: 20127
});
/* TODO: find an actual specification */
function dbf_to_aoa(buf, opts)/*:AOA*/ {
var out/*:AOA*/ = [];
@ -199,9 +214,10 @@ function dbf_to_workbook(buf, opts)/*:Workbook*/ {
var _RLEN = { 'B': 8, 'C': 250, 'L': 1, 'D': 8, '?': 0, '': 0 };
function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
var o = opts || {};
if(+o.codepage >= 0) set_cp(+o.codepage);
if(o.type == "string") throw new Error("Cannot write DBF to JS string");
var ba = buf_array();
var aoa/*:AOA*/ = sheet_to_json(ws, {header:1, cellDates:true});
var aoa/*:AOA*/ = sheet_to_json(ws, {header:1, raw:true, cellDates:true});
var headers = aoa[0], data = aoa.slice(1);
var i = 0, j = 0, hcnt = 0, rlen = 1;
for(i = 0; i < headers.length; ++i) {
@ -243,7 +259,7 @@ function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
h.write_shift(2, 296 + 32 * hcnt);
h.write_shift(2, rlen);
for(i=0; i < 4; ++i) h.write_shift(4, 0);
h.write_shift(4, 0x00000300); // TODO: CP
h.write_shift(4, 0x00000000 | ((+dbf_reverse_map[current_ansi] || 0x03)<<8));
for(i = 0, j = 0; i < headers.length; ++i) {
if(headers[i] == null) continue;
@ -299,6 +315,27 @@ function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
})();
var SYLK = (function() {
/* TODO: stress test sequences */
var sylk_escapes = {
AA:'À', BA:'Á', CA:'Â', DA:195, HA:'Ä', JA:197,
AE:'È', BE:'É', CE:'Ê', HE:'Ë',
AI:'Ì', BI:'Í', CI:'Î', HI:'Ï',
AO:'Ò', BO:'Ó', CO:'Ô', DO:213, HO:'Ö',
AU:'Ù', BU:'Ú', CU:'Û', HU:'Ü',
Aa:'à', Ba:'á', Ca:'â', Da:227, Ha:'ä', Ja:229,
Ae:'è', Be:'é', Ce:'ê', He:'ë',
Ai:'ì', Bi:'í', Ci:'î', Hi:'ï',
Ao:'ò', Bo:'ó', Co:'ô', Do:245, Ho:'ö',
Au:'ù', Bu:'ú', Cu:'û', Hu:'ü',
KC:'Ç', Kc:'ç', q:'æ', z:'œ', a:'Æ', j:'Œ',
DN:209, Dn:241, Hy:255,
S:169, c:170, R:174, 0:176, 1:177, 2:178, 3:179, B:180, 5:181,
6:182, 7:183, Q:185, k:186, b:208, i:216, l:222, s:240, y:248,
"!":161, '"':162, "#":163, "(":164, "%":165, "'":167, "H ":168,
"+":171, ";":187, "<":188, "=":189, ">":190, "?":191, "{":223
};
var sylk_char_regex = new RegExp("\u001BN(" + keys(sylk_escapes).join("|").replace(/\|\|\|/, "|\\||").replace(/([?()+])/g,"\\$1") + "|\\|)", "gm");
sylk_escapes["|"] = 254;
/* TODO: find an actual specification */
function sylk_to_aoa(d/*:RawData*/, opts)/*:[AOA, Worksheet]*/ {
switch(opts.type) {
@ -315,10 +352,17 @@ var SYLK = (function() {
var next_cell_format/*:string|null*/ = null;
var sht = {}, rowinfo/*:Array<RowInfo>*/ = [], colinfo/*:Array<ColInfo>*/ = [], cw/*:Array<string>*/ = [];
var Mval = 0, j;
if(+opts.codepage >= 0) set_cp(+opts.codepage);
for (; ri !== records.length; ++ri) {
Mval = 0;
var rstr=records[ri].trim();
var record=rstr.replace(/;;/g, "\u0001").split(";").map(function(x) { return x.replace(/\u0001/g, ";"); });
var rstr=records[ri].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g, function($$, $1, $2) {
var newcc = (($1.charCodeAt(0) - 0x20)<<4) | ($2.charCodeAt(0) - 0x30);
return newcc == 59 ? $$ : _getansi(newcc);
}).replace(sylk_char_regex, function(_, $1){
var o = sylk_escapes[$1];
return typeof o == "number" ? _getansi(o) : o;
});
var record=rstr.replace(/;;/g, "\u0000").split(";").map(function(x) { return x.replace(/\u0000/g, ";"); });
var RT=record[0], val;
if(rstr.length > 0) switch(RT) {
case 'ID': break; /* header */
@ -889,3 +933,4 @@ function read_wb_ID(d, opts) {
return PRN.to_workbook(d, opts);
}
}

@ -125,6 +125,36 @@ duk_pop(ctx);
```
## QuickJS
QuickJS is an embeddable JS engine written in C. It provides a separate set of
functions for interacting with the filesystem and the global object. It can run
the browser dist build.
The `global` object is available as `std.global`. To make it visible to the
loader, create a reference to itself:
```js
std.global.global = std.global;
std.loadScript("xlsx.full.min.js");
```
The filesystem interaction mirrors POSIX, including separate allocations:
```js
/* read file */
var rh = std.open(filename, "rb"); rh.seek(0, std.SEEK_END);
var sz = rh.tell(); rh.seek();
var ab = new ArrayBuffer(sz); rh.read(ab, 0, sz); rh.close();
var wb = XLSX.read(ab, {type: 'array'});
/* write file */
var ab = XLSX.write(wb, {type: 'array'});
var wh = std.open("sheetjs.qjs.xlsx", "wb");
wh.write(out, 0, ab.byteLength); wh.close();
```
## Goja
Goja is a pure Go implementation of ECMAScript 5. As of this writing, there are

25
demos/altjs/qjs.js Executable file

@ -0,0 +1,25 @@
#!/usr/bin/env qjs
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* load XLSX */
std.global.global = std.global;
std.loadScript("xlsx.full.min.js");
/* read contents of file */
var rh = std.open("sheetjs.xlsx", "rb");
rh.seek(0, std.SEEK_END);
var sz = rh.tell();
var ab = new ArrayBuffer(sz);
rh.seek();
rh.read(ab, 0, sz);
rh.close();
/* parse file */
var wb = XLSX.read(ab, {type: 'array'});
/* write array */
var out = XLSX.write(wb, {type: 'array'});
/* write contents to file */
var wh = std.open("sheetjs.qjs.xlsx", "wb");
wh.write(out, 0, out.byteLength);
wh.close();

28
dist/xlsx.core.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.core.min.map generated vendored

File diff suppressed because one or more lines are too long

85
dist/xlsx.extendscript.js generated vendored

@ -9160,7 +9160,7 @@ module.exports = ZStream;
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.3';
XLSX.version = '0.14.4';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -9224,8 +9224,9 @@ var debom = function(data) {
};
var _getchar = function _gc1(x) { return String.fromCharCode(x); };
var _getansi = function _ga1(x) { return String.fromCharCode(x); };
if(typeof cptable !== 'undefined') {
set_cp = function(cp) { current_codepage = cp; };
set_cp = function(cp) { current_codepage = cp; set_ansi(cp); };
debom = function(data) {
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.slice(2))); }
return data;
@ -9234,6 +9235,9 @@ if(typeof cptable !== 'undefined') {
if(current_codepage === 1200) return String.fromCharCode(x);
return cptable.utils.decode(current_codepage, [x&255,x>>8])[0];
};
_getansi = function _ga2(x) {
return cptable.utils.decode(current_ansi, [x])[0];
}
}
var DENSE = null;
var DIF_XL = true;
@ -10402,7 +10406,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.1.0';
exports.version = '1.1.2';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -10597,7 +10601,8 @@ function check_get_mver(blob) {
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
// clsid 16
blob.chk(HEADER_CLSID, 'CLSID: ');
//blob.chk(HEADER_CLSID, 'CLSID: ');
blob.l += 16;
// minor version 2
var mver = blob.read_shift(2, 'u');
@ -10649,8 +10654,8 @@ function build_full_paths(FI, FP, Paths) {
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
}
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
if(L !== -1) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
if(L !== -1 && i != dad[i]) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1 && i != dad[i]) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
}
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
@ -10659,13 +10664,12 @@ function build_full_paths(FI, FP, Paths) {
for(i=1; i < pl; ++i) {
if(FI[i].type === 0 /* unknown */) continue;
j = dad[i];
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
else while(j !== 0 && j !== dad[j]) {
FP[i] = FP[j] + "/" + FP[i];
j = i;
if(j != dad[j]) do {
j = dad[j];
}
dad[i] = 0;
FP[i] = FP[j] + "/" + FP[i];
} while (j !== 0 && -1 !== dad[j] && j != dad[j]);
dad[i] = -1;
}
FP[0] += "/";
@ -15821,7 +15825,22 @@ var dbf_codepage_map = {
0xFF: 16969
};
var dbf_reverse_map = evert({
0x01: 437, 0x02: 850,
0x03: 1252, 0x04: 10000,
0x64: 852, 0x65: 866,
0x66: 865, 0x67: 861,
0x68: 895, 0x69: 620,
0x6A: 737, 0x6B: 857,
0x78: 950, 0x79: 949,
0x7A: 936, 0x7B: 932,
0x7C: 874, 0x7D: 1255,
0x7E: 1256, 0x96: 10007,
0x97: 10029, 0x98: 10006,
0xC8: 1250, 0xC9: 1251,
0xCA: 1254, 0xCB: 1253,
0x00: 20127
});
/* TODO: find an actual specification */
function dbf_to_aoa(buf, opts) {
var out = [];
@ -15980,9 +15999,10 @@ function dbf_to_workbook(buf, opts) {
var _RLEN = { 'B': 8, 'C': 250, 'L': 1, 'D': 8, '?': 0, '': 0 };
function sheet_to_dbf(ws, opts) {
var o = opts || {};
if(+o.codepage >= 0) set_cp(+o.codepage);
if(o.type == "string") throw new Error("Cannot write DBF to JS string");
var ba = buf_array();
var aoa = sheet_to_json(ws, {header:1, cellDates:true});
var aoa = sheet_to_json(ws, {header:1, raw:true, cellDates:true});
var headers = aoa[0], data = aoa.slice(1);
var i = 0, j = 0, hcnt = 0, rlen = 1;
for(i = 0; i < headers.length; ++i) {
@ -16024,7 +16044,7 @@ function sheet_to_dbf(ws, opts) {
h.write_shift(2, 296 + 32 * hcnt);
h.write_shift(2, rlen);
for(i=0; i < 4; ++i) h.write_shift(4, 0);
h.write_shift(4, 0x00000300); // TODO: CP
h.write_shift(4, 0x00000000 | ((+dbf_reverse_map[current_ansi] || 0x03)<<8));
for(i = 0, j = 0; i < headers.length; ++i) {
if(headers[i] == null) continue;
@ -16080,6 +16100,27 @@ function sheet_to_dbf(ws, opts) {
})();
var SYLK = (function() {
/* TODO: stress test sequences */
var sylk_escapes = {
AA:'À', BA:'Á', CA:'Â', DA:195, HA:'Ä', JA:197,
AE:'È', BE:'É', CE:'Ê', HE:'Ë',
AI:'Ì', BI:'Í', CI:'Î', HI:'Ï',
AO:'Ò', BO:'Ó', CO:'Ô', DO:213, HO:'Ö',
AU:'Ù', BU:'Ú', CU:'Û', HU:'Ü',
Aa:'à', Ba:'á', Ca:'â', Da:227, Ha:'ä', Ja:229,
Ae:'è', Be:'é', Ce:'ê', He:'ë',
Ai:'ì', Bi:'í', Ci:'î', Hi:'ï',
Ao:'ò', Bo:'ó', Co:'ô', Do:245, Ho:'ö',
Au:'ù', Bu:'ú', Cu:'û', Hu:'ü',
KC:'Ç', Kc:'ç', q:'æ', z:'œ', a:'Æ', j:'Œ',
DN:209, Dn:241, Hy:255,
S:169, c:170, R:174, 0:176, 1:177, 2:178, 3:179, B:180, 5:181,
6:182, 7:183, Q:185, k:186, b:208, i:216, l:222, s:240, y:248,
"!":161, '"':162, "#":163, "(":164, "%":165, "'":167, "H ":168,
"+":171, ";":187, "<":188, "=":189, ">":190, "?":191, "{":223
};
var sylk_char_regex = new RegExp("\u001BN(" + keys(sylk_escapes).join("|").replace(/\|\|\|/, "|\\||").replace(/([?()+])/g,"\\$1") + "|\\|)", "gm");
sylk_escapes["|"] = 254;
/* TODO: find an actual specification */
function sylk_to_aoa(d, opts) {
switch(opts.type) {
@ -16096,10 +16137,17 @@ var SYLK = (function() {
var next_cell_format = null;
var sht = {}, rowinfo = [], colinfo = [], cw = [];
var Mval = 0, j;
if(+opts.codepage >= 0) set_cp(+opts.codepage);
for (; ri !== records.length; ++ri) {
Mval = 0;
var rstr=records[ri].trim();
var record=rstr.replace(/;;/g, "\u0001").split(";").map(function(x) { return x.replace(/\u0001/g, ";"); });
var rstr=records[ri].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g, function($$, $1, $2) {
var newcc = (($1.charCodeAt(0) - 0x20)<<4) | ($2.charCodeAt(0) - 0x30);
return newcc == 59 ? $$ : _getansi(newcc);
}).replace(sylk_char_regex, function(_, $1){
var o = sylk_escapes[$1];
return typeof o == "number" ? _getansi(o) : o;
});
var record=rstr.replace(/;;/g, "\u0000").split(";").map(function(x) { return x.replace(/\u0000/g, ";"); });
var RT=record[0], val;
if(rstr.length > 0) switch(RT) {
case 'ID': break; /* header */
@ -16670,6 +16718,7 @@ function read_wb_ID(d, opts) {
return PRN.to_workbook(d, opts);
}
}
var WK_ = (function() {
function lotushopper(data, cb, opts) {
if(!data) return;
@ -30038,7 +30087,6 @@ if(has_buf && typeof require != 'undefined') (function() {
var BOM = false;
stream._read = function() {
if(!BOM) { BOM = true; return stream.push("\uFEFF"); }
if(R > r.e.r) return stream.push(null);
while(R <= r.e.r) {
++R;
if ((rowinfo[R-1]||{}).hidden) continue;
@ -30049,6 +30097,7 @@ if(has_buf && typeof require != 'undefined') (function() {
break;
}
}
if(R > r.e.r) return stream.push(null);
};
return stream;
};

32
dist/xlsx.full.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.full.min.map generated vendored

File diff suppressed because one or more lines are too long

85
dist/xlsx.js generated vendored

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.3';
XLSX.version = '0.14.4';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -68,8 +68,9 @@ var debom = function(data) {
};
var _getchar = function _gc1(x) { return String.fromCharCode(x); };
var _getansi = function _ga1(x) { return String.fromCharCode(x); };
if(typeof cptable !== 'undefined') {
set_cp = function(cp) { current_codepage = cp; };
set_cp = function(cp) { current_codepage = cp; set_ansi(cp); };
debom = function(data) {
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.slice(2))); }
return data;
@ -78,6 +79,9 @@ if(typeof cptable !== 'undefined') {
if(current_codepage === 1200) return String.fromCharCode(x);
return cptable.utils.decode(current_codepage, [x&255,x>>8])[0];
};
_getansi = function _ga2(x) {
return cptable.utils.decode(current_ansi, [x])[0];
}
}
var DENSE = null;
var DIF_XL = true;
@ -1246,7 +1250,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.1.0';
exports.version = '1.1.2';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -1441,7 +1445,8 @@ function check_get_mver(blob) {
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
// clsid 16
blob.chk(HEADER_CLSID, 'CLSID: ');
//blob.chk(HEADER_CLSID, 'CLSID: ');
blob.l += 16;
// minor version 2
var mver = blob.read_shift(2, 'u');
@ -1493,8 +1498,8 @@ function build_full_paths(FI, FP, Paths) {
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
}
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
if(L !== -1) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
if(L !== -1 && i != dad[i]) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1 && i != dad[i]) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
}
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
@ -1503,13 +1508,12 @@ function build_full_paths(FI, FP, Paths) {
for(i=1; i < pl; ++i) {
if(FI[i].type === 0 /* unknown */) continue;
j = dad[i];
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
else while(j !== 0 && j !== dad[j]) {
FP[i] = FP[j] + "/" + FP[i];
j = i;
if(j != dad[j]) do {
j = dad[j];
}
dad[i] = 0;
FP[i] = FP[j] + "/" + FP[i];
} while (j !== 0 && -1 !== dad[j] && j != dad[j]);
dad[i] = -1;
}
FP[0] += "/";
@ -6665,7 +6669,22 @@ var dbf_codepage_map = {
0xFF: 16969
};
var dbf_reverse_map = evert({
0x01: 437, 0x02: 850,
0x03: 1252, 0x04: 10000,
0x64: 852, 0x65: 866,
0x66: 865, 0x67: 861,
0x68: 895, 0x69: 620,
0x6A: 737, 0x6B: 857,
0x78: 950, 0x79: 949,
0x7A: 936, 0x7B: 932,
0x7C: 874, 0x7D: 1255,
0x7E: 1256, 0x96: 10007,
0x97: 10029, 0x98: 10006,
0xC8: 1250, 0xC9: 1251,
0xCA: 1254, 0xCB: 1253,
0x00: 20127
});
/* TODO: find an actual specification */
function dbf_to_aoa(buf, opts) {
var out = [];
@ -6824,9 +6843,10 @@ function dbf_to_workbook(buf, opts) {
var _RLEN = { 'B': 8, 'C': 250, 'L': 1, 'D': 8, '?': 0, '': 0 };
function sheet_to_dbf(ws, opts) {
var o = opts || {};
if(+o.codepage >= 0) set_cp(+o.codepage);
if(o.type == "string") throw new Error("Cannot write DBF to JS string");
var ba = buf_array();
var aoa = sheet_to_json(ws, {header:1, cellDates:true});
var aoa = sheet_to_json(ws, {header:1, raw:true, cellDates:true});
var headers = aoa[0], data = aoa.slice(1);
var i = 0, j = 0, hcnt = 0, rlen = 1;
for(i = 0; i < headers.length; ++i) {
@ -6868,7 +6888,7 @@ function sheet_to_dbf(ws, opts) {
h.write_shift(2, 296 + 32 * hcnt);
h.write_shift(2, rlen);
for(i=0; i < 4; ++i) h.write_shift(4, 0);
h.write_shift(4, 0x00000300); // TODO: CP
h.write_shift(4, 0x00000000 | ((+dbf_reverse_map[current_ansi] || 0x03)<<8));
for(i = 0, j = 0; i < headers.length; ++i) {
if(headers[i] == null) continue;
@ -6924,6 +6944,27 @@ function sheet_to_dbf(ws, opts) {
})();
var SYLK = (function() {
/* TODO: stress test sequences */
var sylk_escapes = {
AA:'À', BA:'Á', CA:'Â', DA:195, HA:'Ä', JA:197,
AE:'È', BE:'É', CE:'Ê', HE:'Ë',
AI:'Ì', BI:'Í', CI:'Î', HI:'Ï',
AO:'Ò', BO:'Ó', CO:'Ô', DO:213, HO:'Ö',
AU:'Ù', BU:'Ú', CU:'Û', HU:'Ü',
Aa:'à', Ba:'á', Ca:'â', Da:227, Ha:'ä', Ja:229,
Ae:'è', Be:'é', Ce:'ê', He:'ë',
Ai:'ì', Bi:'í', Ci:'î', Hi:'ï',
Ao:'ò', Bo:'ó', Co:'ô', Do:245, Ho:'ö',
Au:'ù', Bu:'ú', Cu:'û', Hu:'ü',
KC:'Ç', Kc:'ç', q:'æ', z:'œ', a:'Æ', j:'Œ',
DN:209, Dn:241, Hy:255,
S:169, c:170, R:174, 0:176, 1:177, 2:178, 3:179, B:180, 5:181,
6:182, 7:183, Q:185, k:186, b:208, i:216, l:222, s:240, y:248,
"!":161, '"':162, "#":163, "(":164, "%":165, "'":167, "H ":168,
"+":171, ";":187, "<":188, "=":189, ">":190, "?":191, "{":223
};
var sylk_char_regex = new RegExp("\u001BN(" + keys(sylk_escapes).join("|").replace(/\|\|\|/, "|\\||").replace(/([?()+])/g,"\\$1") + "|\\|)", "gm");
sylk_escapes["|"] = 254;
/* TODO: find an actual specification */
function sylk_to_aoa(d, opts) {
switch(opts.type) {
@ -6940,10 +6981,17 @@ var SYLK = (function() {
var next_cell_format = null;
var sht = {}, rowinfo = [], colinfo = [], cw = [];
var Mval = 0, j;
if(+opts.codepage >= 0) set_cp(+opts.codepage);
for (; ri !== records.length; ++ri) {
Mval = 0;
var rstr=records[ri].trim();
var record=rstr.replace(/;;/g, "\u0001").split(";").map(function(x) { return x.replace(/\u0001/g, ";"); });
var rstr=records[ri].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g, function($$, $1, $2) {
var newcc = (($1.charCodeAt(0) - 0x20)<<4) | ($2.charCodeAt(0) - 0x30);
return newcc == 59 ? $$ : _getansi(newcc);
}).replace(sylk_char_regex, function(_, $1){
var o = sylk_escapes[$1];
return typeof o == "number" ? _getansi(o) : o;
});
var record=rstr.replace(/;;/g, "\u0000").split(";").map(function(x) { return x.replace(/\u0000/g, ";"); });
var RT=record[0], val;
if(rstr.length > 0) switch(RT) {
case 'ID': break; /* header */
@ -7514,6 +7562,7 @@ function read_wb_ID(d, opts) {
return PRN.to_workbook(d, opts);
}
}
var WK_ = (function() {
function lotushopper(data, cb, opts) {
if(!data) return;
@ -20882,7 +20931,6 @@ if(has_buf && typeof require != 'undefined') (function() {
var BOM = false;
stream._read = function() {
if(!BOM) { BOM = true; return stream.push("\uFEFF"); }
if(R > r.e.r) return stream.push(null);
while(R <= r.e.r) {
++R;
if ((rowinfo[R-1]||{}).hidden) continue;
@ -20893,6 +20941,7 @@ if(has_buf && typeof require != 'undefined') (function() {
break;
}
}
if(R > r.e.r) return stream.push(null);
};
return stream;
};

26
dist/xlsx.min.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.min.map generated vendored

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.14.3",
"version": "0.14.4",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [
@ -31,7 +31,7 @@
},
"dependencies": {
"adler-32": "~1.2.0",
"cfb": "^1.1.0",
"cfb": "^1.1.2",
"codepage": "~1.14.0",
"commander": "~2.17.1",
"crc-32": "~1.2.0",

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.3';
XLSX.version = '0.14.4';
var current_codepage = 1200, current_ansi = 1252;
/*:: declare var cptable:any; */
/*global cptable:true, window */
@ -69,8 +69,9 @@ var debom = function(data/*:string*/)/*:string*/ {
};
var _getchar = function _gc1(x/*:number*/)/*:string*/ { return String.fromCharCode(x); };
var _getansi = function _ga1(x/*:number*/)/*:string*/ { return String.fromCharCode(x); };
if(typeof cptable !== 'undefined') {
set_cp = function(cp/*:number*/) { current_codepage = cp; };
set_cp = function(cp/*:number*/) { current_codepage = cp; set_ansi(cp); };
debom = function(data/*:string*/) {
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.slice(2))); }
return data;
@ -79,6 +80,9 @@ if(typeof cptable !== 'undefined') {
if(current_codepage === 1200) return String.fromCharCode(x);
return cptable.utils.decode(current_codepage, [x&255,x>>8])[0];
};
_getansi = function _ga2(x/*:number*/)/*:string*/ {
return cptable.utils.decode(current_ansi, [x])[0];
}
}
var DENSE = null;
var DIF_XL = true;
@ -1313,7 +1317,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
exports.version = '1.1.0';
exports.version = '1.1.2';
/* [MS-CFB] 2.6.4 */
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
var L = l.split("/"), R = r.split("/");
@ -1508,7 +1512,8 @@ function check_get_mver(blob/*:CFBlob*/)/*:[number, number]*/ {
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
// clsid 16
blob.chk(HEADER_CLSID, 'CLSID: ');
//blob.chk(HEADER_CLSID, 'CLSID: ');
blob.l += 16;
// minor version 2
var mver/*:number*/ = blob.read_shift(2, 'u');
@ -1560,8 +1565,8 @@ function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Arr
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
}
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
if(L !== -1) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
if(L !== -1 && i != dad[i]) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1 && i != dad[i]) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
}
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
@ -1570,13 +1575,12 @@ function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Arr
for(i=1; i < pl; ++i) {
if(FI[i].type === 0 /* unknown */) continue;
j = dad[i];
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
else while(j !== 0 && j !== dad[j]) {
FP[i] = FP[j] + "/" + FP[i];
j = i;
if(j != dad[j]) do {
j = dad[j];
}
dad[i] = 0;
FP[i] = FP[j] + "/" + FP[i];
} while (j !== 0 && -1 !== dad[j] && j != dad[j]);
dad[i] = -1;
}
FP[0] += "/";
@ -6761,7 +6765,22 @@ var dbf_codepage_map = {
/*::[*/0xFF/*::]*/: 16969
};
var dbf_reverse_map = evert({
/*::[*/0x01/*::]*/: 437, /*::[*/0x02/*::]*/: 850,
/*::[*/0x03/*::]*/: 1252, /*::[*/0x04/*::]*/: 10000,
/*::[*/0x64/*::]*/: 852, /*::[*/0x65/*::]*/: 866,
/*::[*/0x66/*::]*/: 865, /*::[*/0x67/*::]*/: 861,
/*::[*/0x68/*::]*/: 895, /*::[*/0x69/*::]*/: 620,
/*::[*/0x6A/*::]*/: 737, /*::[*/0x6B/*::]*/: 857,
/*::[*/0x78/*::]*/: 950, /*::[*/0x79/*::]*/: 949,
/*::[*/0x7A/*::]*/: 936, /*::[*/0x7B/*::]*/: 932,
/*::[*/0x7C/*::]*/: 874, /*::[*/0x7D/*::]*/: 1255,
/*::[*/0x7E/*::]*/: 1256, /*::[*/0x96/*::]*/: 10007,
/*::[*/0x97/*::]*/: 10029, /*::[*/0x98/*::]*/: 10006,
/*::[*/0xC8/*::]*/: 1250, /*::[*/0xC9/*::]*/: 1251,
/*::[*/0xCA/*::]*/: 1254, /*::[*/0xCB/*::]*/: 1253,
/*::[*/0x00/*::]*/: 20127
});
/* TODO: find an actual specification */
function dbf_to_aoa(buf, opts)/*:AOA*/ {
var out/*:AOA*/ = [];
@ -6921,9 +6940,10 @@ function dbf_to_workbook(buf, opts)/*:Workbook*/ {
var _RLEN = { 'B': 8, 'C': 250, 'L': 1, 'D': 8, '?': 0, '': 0 };
function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
var o = opts || {};
if(+o.codepage >= 0) set_cp(+o.codepage);
if(o.type == "string") throw new Error("Cannot write DBF to JS string");
var ba = buf_array();
var aoa/*:AOA*/ = sheet_to_json(ws, {header:1, cellDates:true});
var aoa/*:AOA*/ = sheet_to_json(ws, {header:1, raw:true, cellDates:true});
var headers = aoa[0], data = aoa.slice(1);
var i = 0, j = 0, hcnt = 0, rlen = 1;
for(i = 0; i < headers.length; ++i) {
@ -6965,7 +6985,7 @@ function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
h.write_shift(2, 296 + 32 * hcnt);
h.write_shift(2, rlen);
for(i=0; i < 4; ++i) h.write_shift(4, 0);
h.write_shift(4, 0x00000300); // TODO: CP
h.write_shift(4, 0x00000000 | ((+dbf_reverse_map[current_ansi] || 0x03)<<8));
for(i = 0, j = 0; i < headers.length; ++i) {
if(headers[i] == null) continue;
@ -7021,6 +7041,27 @@ function sheet_to_dbf(ws/*:Worksheet*/, opts/*:WriteOpts*/) {
})();
var SYLK = (function() {
/* TODO: stress test sequences */
var sylk_escapes = {
AA:'À', BA:'Á', CA:'Â', DA:195, HA:'Ä', JA:197,
AE:'È', BE:'É', CE:'Ê', HE:'Ë',
AI:'Ì', BI:'Í', CI:'Î', HI:'Ï',
AO:'Ò', BO:'Ó', CO:'Ô', DO:213, HO:'Ö',
AU:'Ù', BU:'Ú', CU:'Û', HU:'Ü',
Aa:'à', Ba:'á', Ca:'â', Da:227, Ha:'ä', Ja:229,
Ae:'è', Be:'é', Ce:'ê', He:'ë',
Ai:'ì', Bi:'í', Ci:'î', Hi:'ï',
Ao:'ò', Bo:'ó', Co:'ô', Do:245, Ho:'ö',
Au:'ù', Bu:'ú', Cu:'û', Hu:'ü',
KC:'Ç', Kc:'ç', q:'æ', z:'œ', a:'Æ', j:'Œ',
DN:209, Dn:241, Hy:255,
S:169, c:170, R:174, 0:176, 1:177, 2:178, 3:179, B:180, 5:181,
6:182, 7:183, Q:185, k:186, b:208, i:216, l:222, s:240, y:248,
"!":161, '"':162, "#":163, "(":164, "%":165, "'":167, "H ":168,
"+":171, ";":187, "<":188, "=":189, ">":190, "?":191, "{":223
};
var sylk_char_regex = new RegExp("\u001BN(" + keys(sylk_escapes).join("|").replace(/\|\|\|/, "|\\||").replace(/([?()+])/g,"\\$1") + "|\\|)", "gm");
sylk_escapes["|"] = 254;
/* TODO: find an actual specification */
function sylk_to_aoa(d/*:RawData*/, opts)/*:[AOA, Worksheet]*/ {
switch(opts.type) {
@ -7037,10 +7078,17 @@ var SYLK = (function() {
var next_cell_format/*:string|null*/ = null;
var sht = {}, rowinfo/*:Array<RowInfo>*/ = [], colinfo/*:Array<ColInfo>*/ = [], cw/*:Array<string>*/ = [];
var Mval = 0, j;
if(+opts.codepage >= 0) set_cp(+opts.codepage);
for (; ri !== records.length; ++ri) {
Mval = 0;
var rstr=records[ri].trim();
var record=rstr.replace(/;;/g, "\u0001").split(";").map(function(x) { return x.replace(/\u0001/g, ";"); });
var rstr=records[ri].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g, function($$, $1, $2) {
var newcc = (($1.charCodeAt(0) - 0x20)<<4) | ($2.charCodeAt(0) - 0x30);
return newcc == 59 ? $$ : _getansi(newcc);
}).replace(sylk_char_regex, function(_, $1){
var o = sylk_escapes[$1];
return typeof o == "number" ? _getansi(o) : o;
});
var record=rstr.replace(/;;/g, "\u0000").split(";").map(function(x) { return x.replace(/\u0000/g, ";"); });
var RT=record[0], val;
if(rstr.length > 0) switch(RT) {
case 'ID': break; /* header */
@ -7611,6 +7659,7 @@ function read_wb_ID(d, opts) {
return PRN.to_workbook(d, opts);
}
}
var WK_ = (function() {
function lotushopper(data, cb/*:RecordHopperCB*/, opts/*:any*/) {
if(!data) return;
@ -21011,7 +21060,6 @@ if(has_buf && typeof require != 'undefined') (function() {
var BOM = false;
stream._read = function() {
if(!BOM) { BOM = true; return stream.push("\uFEFF"); }
if(R > r.e.r) return stream.push(null);
while(R <= r.e.r) {
++R;
if ((rowinfo[R-1]||{}).hidden) continue;
@ -21022,6 +21070,7 @@ if(has_buf && typeof require != 'undefined') (function() {
break;
}
}
if(R > r.e.r) return stream.push(null);
};
return stream;
};

85
xlsx.js generated

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */
var XLSX = {};
function make_xlsx_lib(XLSX){
XLSX.version = '0.14.3';
XLSX.version = '0.14.4';
var current_codepage = 1200, current_ansi = 1252;
/*global cptable:true, window */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -68,8 +68,9 @@ var debom = function(data) {
};
var _getchar = function _gc1(x) { return String.fromCharCode(x); };
var _getansi = function _ga1(x) { return String.fromCharCode(x); };
if(typeof cptable !== 'undefined') {
set_cp = function(cp) { current_codepage = cp; };
set_cp = function(cp) { current_codepage = cp; set_ansi(cp); };
debom = function(data) {
if(data.charCodeAt(0) === 0xFF && data.charCodeAt(1) === 0xFE) { return cptable.utils.decode(1200, char_codes(data.slice(2))); }
return data;
@ -78,6 +79,9 @@ if(typeof cptable !== 'undefined') {
if(current_codepage === 1200) return String.fromCharCode(x);
return cptable.utils.decode(current_codepage, [x&255,x>>8])[0];
};
_getansi = function _ga2(x) {
return cptable.utils.decode(current_ansi, [x])[0];
}
}
var DENSE = null;
var DIF_XL = true;
@ -1246,7 +1250,7 @@ CRC32.str = crc32_str;
/* [MS-CFB] v20171201 */
var CFB = (function _CFB(){
var exports = {};
exports.version = '1.1.0';
exports.version = '1.1.2';
/* [MS-CFB] 2.6.4 */
function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
@ -1441,7 +1445,8 @@ function check_get_mver(blob) {
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
// clsid 16
blob.chk(HEADER_CLSID, 'CLSID: ');
//blob.chk(HEADER_CLSID, 'CLSID: ');
blob.l += 16;
// minor version 2
var mver = blob.read_shift(2, 'u');
@ -1493,8 +1498,8 @@ function build_full_paths(FI, FP, Paths) {
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
}
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
if(L !== -1) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
if(L !== -1 && i != dad[i]) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
if(R !== -1 && i != dad[i]) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
}
for(i=1; i < pl; ++i) if(dad[i] === i) {
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
@ -1503,13 +1508,12 @@ function build_full_paths(FI, FP, Paths) {
for(i=1; i < pl; ++i) {
if(FI[i].type === 0 /* unknown */) continue;
j = dad[i];
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
else while(j !== 0 && j !== dad[j]) {
FP[i] = FP[j] + "/" + FP[i];
j = i;
if(j != dad[j]) do {
j = dad[j];
}
dad[i] = 0;
FP[i] = FP[j] + "/" + FP[i];
} while (j !== 0 && -1 !== dad[j] && j != dad[j]);
dad[i] = -1;
}
FP[0] += "/";
@ -6665,7 +6669,22 @@ var dbf_codepage_map = {
0xFF: 16969
};
var dbf_reverse_map = evert({
0x01: 437, 0x02: 850,
0x03: 1252, 0x04: 10000,
0x64: 852, 0x65: 866,
0x66: 865, 0x67: 861,
0x68: 895, 0x69: 620,
0x6A: 737, 0x6B: 857,
0x78: 950, 0x79: 949,
0x7A: 936, 0x7B: 932,
0x7C: 874, 0x7D: 1255,
0x7E: 1256, 0x96: 10007,
0x97: 10029, 0x98: 10006,
0xC8: 1250, 0xC9: 1251,
0xCA: 1254, 0xCB: 1253,
0x00: 20127
});
/* TODO: find an actual specification */
function dbf_to_aoa(buf, opts) {
var out = [];
@ -6824,9 +6843,10 @@ function dbf_to_workbook(buf, opts) {
var _RLEN = { 'B': 8, 'C': 250, 'L': 1, 'D': 8, '?': 0, '': 0 };
function sheet_to_dbf(ws, opts) {
var o = opts || {};
if(+o.codepage >= 0) set_cp(+o.codepage);
if(o.type == "string") throw new Error("Cannot write DBF to JS string");
var ba = buf_array();
var aoa = sheet_to_json(ws, {header:1, cellDates:true});
var aoa = sheet_to_json(ws, {header:1, raw:true, cellDates:true});
var headers = aoa[0], data = aoa.slice(1);
var i = 0, j = 0, hcnt = 0, rlen = 1;
for(i = 0; i < headers.length; ++i) {
@ -6868,7 +6888,7 @@ function sheet_to_dbf(ws, opts) {
h.write_shift(2, 296 + 32 * hcnt);
h.write_shift(2, rlen);
for(i=0; i < 4; ++i) h.write_shift(4, 0);
h.write_shift(4, 0x00000300); // TODO: CP
h.write_shift(4, 0x00000000 | ((+dbf_reverse_map[current_ansi] || 0x03)<<8));
for(i = 0, j = 0; i < headers.length; ++i) {
if(headers[i] == null) continue;
@ -6924,6 +6944,27 @@ function sheet_to_dbf(ws, opts) {
})();
var SYLK = (function() {
/* TODO: stress test sequences */
var sylk_escapes = {
AA:'À', BA:'Á', CA:'Â', DA:195, HA:'Ä', JA:197,
AE:'È', BE:'É', CE:'Ê', HE:'Ë',
AI:'Ì', BI:'Í', CI:'Î', HI:'Ï',
AO:'Ò', BO:'Ó', CO:'Ô', DO:213, HO:'Ö',
AU:'Ù', BU:'Ú', CU:'Û', HU:'Ü',
Aa:'à', Ba:'á', Ca:'â', Da:227, Ha:'ä', Ja:229,
Ae:'è', Be:'é', Ce:'ê', He:'ë',
Ai:'ì', Bi:'í', Ci:'î', Hi:'ï',
Ao:'ò', Bo:'ó', Co:'ô', Do:245, Ho:'ö',
Au:'ù', Bu:'ú', Cu:'û', Hu:'ü',
KC:'Ç', Kc:'ç', q:'æ', z:'œ', a:'Æ', j:'Œ',
DN:209, Dn:241, Hy:255,
S:169, c:170, R:174, 0:176, 1:177, 2:178, 3:179, B:180, 5:181,
6:182, 7:183, Q:185, k:186, b:208, i:216, l:222, s:240, y:248,
"!":161, '"':162, "#":163, "(":164, "%":165, "'":167, "H ":168,
"+":171, ";":187, "<":188, "=":189, ">":190, "?":191, "{":223
};
var sylk_char_regex = new RegExp("\u001BN(" + keys(sylk_escapes).join("|").replace(/\|\|\|/, "|\\||").replace(/([?()+])/g,"\\$1") + "|\\|)", "gm");
sylk_escapes["|"] = 254;
/* TODO: find an actual specification */
function sylk_to_aoa(d, opts) {
switch(opts.type) {
@ -6940,10 +6981,17 @@ var SYLK = (function() {
var next_cell_format = null;
var sht = {}, rowinfo = [], colinfo = [], cw = [];
var Mval = 0, j;
if(+opts.codepage >= 0) set_cp(+opts.codepage);
for (; ri !== records.length; ++ri) {
Mval = 0;
var rstr=records[ri].trim();
var record=rstr.replace(/;;/g, "\u0001").split(";").map(function(x) { return x.replace(/\u0001/g, ";"); });
var rstr=records[ri].trim().replace(/\x1B([\x20-\x2F])([\x30-\x3F])/g, function($$, $1, $2) {
var newcc = (($1.charCodeAt(0) - 0x20)<<4) | ($2.charCodeAt(0) - 0x30);
return newcc == 59 ? $$ : _getansi(newcc);
}).replace(sylk_char_regex, function(_, $1){
var o = sylk_escapes[$1];
return typeof o == "number" ? _getansi(o) : o;
});
var record=rstr.replace(/;;/g, "\u0000").split(";").map(function(x) { return x.replace(/\u0000/g, ";"); });
var RT=record[0], val;
if(rstr.length > 0) switch(RT) {
case 'ID': break; /* header */
@ -7514,6 +7562,7 @@ function read_wb_ID(d, opts) {
return PRN.to_workbook(d, opts);
}
}
var WK_ = (function() {
function lotushopper(data, cb, opts) {
if(!data) return;
@ -20882,7 +20931,6 @@ if(has_buf && typeof require != 'undefined') (function() {
var BOM = false;
stream._read = function() {
if(!BOM) { BOM = true; return stream.push("\uFEFF"); }
if(R > r.e.r) return stream.push(null);
while(R <= r.e.r) {
++R;
if ((rowinfo[R-1]||{}).hidden) continue;
@ -20893,6 +20941,7 @@ if(has_buf && typeof require != 'undefined') (function() {
break;
}
}
if(R > r.e.r) return stream.push(null);
};
return stream;
};