updating to 0.11.12

This commit is contained in:
SheetJS 2017-12-04 00:21:43 -05:00
parent c882f866d0
commit 6c0dfc7a1a
5 changed files with 145 additions and 30 deletions

1
.gitignore vendored
View File

@ -23,6 +23,7 @@ tmp
*.[qQ][pP][wW]
*.[bB][iI][fF][fF][23458]
*.[rR][tT][fF]
*.[eE][tT][hH]
*.123
*.sheetjs
*.exe

View File

@ -22,7 +22,7 @@ var opts = ({cellNF: true}/*:any*/);
var TYPE = browser ? "binary" : "buffer";
opts.type = TYPE;
var fullex = [".xlsb", /*".xlsm",*/ ".xlsx"/*, ".xlml", ".xls"*/];
var ofmt = ["xlsb", "xlsm", "xlsx", "ods", "biff2", "biff5", "biff8", "xlml", "sylk", "dif", "dbf"];
var ofmt = ["xlsb", "xlsm", "xlsx", "ods", "biff2", "biff5", "biff8", "xlml", "sylk", "dif", "dbf", "eth"];
var ex = fullex.slice(); ex = ex.concat([".ods", ".xls", ".xml", ".fods"]);
if(typeof process != 'undefined' && ((process||{}).env)) {
opts.WTF = true;
@ -321,7 +321,7 @@ var wbtable = {};
fileA.forEach(function(x) {
if(x.slice(-8) == ".pending" || !fs.existsSync(dir + x)) return;
it(x, function() {
var wb = X.readFile(dir + x, {WTF:opts.wtf, sheetRows:10});
var wb = X.readFile(dir + x, {WTF:opts.WTF, sheetRows:10});
parsetest(x, wb, false);
});
});
@ -623,6 +623,7 @@ describe('output formats', function() {
["csv", true, true],
["txt", true, true],
["sylk", false, true],
["eth", true, true],
["html", true, true],
["dif", false, true],
["dbf", false, false],

25
xlsx.core.min.js vendored

File diff suppressed because one or more lines are too long

26
xlsx.full.min.js vendored

File diff suppressed because one or more lines are too long

118
xlsx.js
View File

@ -4,7 +4,7 @@
/*global global, exports, module, require:false, process:false, Buffer:false */
var XLSX = {};
(function make_xlsx(XLSX){
XLSX.version = '0.11.11';
XLSX.version = '0.11.12';
var current_codepage = 1200;
/*global cptable:true */
if(typeof module !== "undefined" && typeof require !== 'undefined') {
@ -2313,6 +2313,12 @@ function ReadShift(size, t) {
loc+=2;
} o = oo.join(""); size *= 2; break;
case 'cpstr':
if(typeof cptable !== 'undefined') {
o = cptable.utils.decode(current_codepage, this.slice(this.l, this.l + size));
break;
}
/* falls through */
case 'sbcs-cont': o = ""; loc = this.l;
for(i = 0; i != size; ++i) {
if(this.lens && this.lens.indexOf(loc) !== -1) {
@ -4351,7 +4357,7 @@ function parse_XLUnicodeString2(blob, length, opts) {
if(opts.biff > 5) return parse_XLUnicodeString(blob, length, opts);
var cch = blob.read_shift(1);
if(cch === 0) { blob.l++; return ""; }
return blob.read_shift(cch, 'sbcs-cont');
return blob.read_shift(cch, opts.biff == 4 ? 'cpstr' : 'sbcs-cont');
}
/* TODO: BIFF5 and lower, codepage awareness */
function write_XLUnicodeString(str, opts, o) {
@ -5994,6 +6000,105 @@ var DIF = (function() {
};
})();
var ETH = (function() {
function decode(s) { return s.replace(/\\b/g,"\\").replace(/\\c/g,":").replace(/\\n/g,"\n"); }
function encode(s) { return s.replace(/\\/g, "\\b").replace(/:/g, "\\c").replace(/\n/g,"\\n"); }
function eth_to_aoa(str, opts) {
var records = str.split('\n'), R = -1, C = -1, ri = 0, arr = [];
for (; ri !== records.length; ++ri) {
var record = records[ri].trim().split(":");
if(record[0] !== 'cell') continue;
var addr = decode_cell(record[1]);
if(arr.length <= addr.r) for(R = arr.length; R <= addr.r; ++R) if(!arr[R]) arr[R] = [];
R = addr.r; C = addr.c;
switch(record[2]) {
case 't': arr[R][C] = decode(record[3]); break;
case 'v': arr[R][C] = +record[3]; break;
case 'vtf': var _f = record[record.length - 1];
/* falls through */
case 'vtc':
switch(record[3]) {
case 'nl': arr[R][C] = +record[4] ? true : false; break;
default: arr[R][C] = +record[4]; break;
}
if(record[2] == 'vtf') arr[R][C] = [arr[R][C], _f];
}
}
return arr;
}
function eth_to_sheet(d, opts) { return aoa_to_sheet(eth_to_aoa(d, opts), opts); }
function eth_to_workbook(d, opts) { return sheet_to_workbook(eth_to_sheet(d, opts), opts); }
var header = [
"socialcalc:version:1.5",
"MIME-Version: 1.0",
"Content-Type: multipart/mixed; boundary=SocialCalcSpreadsheetControlSave"
].join("\n");
var sep = [
"--SocialCalcSpreadsheetControlSave",
"Content-type: text/plain; charset=UTF-8"
].join("\n") + "\n";
/* TODO: the other parts */
var meta = [
"# SocialCalc Spreadsheet Control Save",
"part:sheet"
].join("\n");
var end = "--SocialCalcSpreadsheetControlSave--";
function sheet_to_eth_data(ws) {
if(!ws || !ws['!ref']) return "";
var o = [], oo = [], cell, coord;
var r = decode_range(ws['!ref']);
var dense = Array.isArray(ws);
for(var R = r.s.r; R <= r.e.r; ++R) {
for(var C = r.s.c; C <= r.e.c; ++C) {
coord = encode_cell({r:R,c:C});
cell = dense ? (ws[R]||[])[C] : ws[coord];
if(!cell || cell.v == null || cell.t === 'z') continue;
oo = ["cell", coord, 't'];
switch(cell.t) {
case 's': case 'str': oo.push(encode(cell.v)); break;
case 'n':
if(!cell.f) { oo[2]='v'; oo[3]=cell.v; }
else { oo[2]='vtf'; oo[3]='n'; oo[4]=cell.v; oo[5]=encode(cell.f); }
break;
case 'b':
oo[2] = 'vt'+(cell.f?'f':'c'); oo[3]='nl'; oo[4]=+!!cell.v;
oo[5] = encode(cell.f||(cell.v?'TRUE':'FALSE'));
break;
case 'd':
var t = datenum(parseDate(cell.v));
oo[2] = 'vtc'; oo[3] = 'nd'; oo[4] = t;
oo[5] = cell.w || SSF.format(cell.z || SSF._table[14], t);
break;
case 'e': continue;
}
o.push(oo.join(":"));
}
}
o.push("sheet:c:" + (r.e.c-r.s.c+1) + ":r:" + (r.e.r-r.s.r+1) + ":tvf:1");
o.push("valueformat:1:text-wiki");
//o.push("copiedfrom:" + ws['!ref']); // clipboard only
return o.join("\n");
}
function sheet_to_eth(ws, opts) {
return [header, sep, meta, sep, sheet_to_eth_data(ws), end].join("\n");
// return ["version:1.5", sheet_to_eth_data(ws)].join("\n"); // clipboard form
}
return {
to_workbook: eth_to_workbook,
to_sheet: eth_to_sheet,
from_sheet: sheet_to_eth
};
})();
var PRN = (function() {
function set_text_arr(data, arr, R, C, o) {
if(o.raw) arr[R][C] = data;
@ -6127,7 +6232,7 @@ var PRN = (function() {
}
function prn_to_sheet_str(str, opts) {
if(str.substr(0,4) == "sep=") return dsv_to_sheet_str(str, opts);
if(str.slice(0,4) == "sep=") return dsv_to_sheet_str(str, opts);
if(str.indexOf("\t") >= 0 || str.indexOf(",") >= 0 || str.indexOf(";") >= 0) return dsv_to_sheet_str(str, opts);
return aoa_to_sheet(prn_to_aoa_str(str, opts), opts);
}
@ -6143,6 +6248,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));
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);
}
@ -18046,6 +18152,7 @@ var write_rtf_str = write_obj_str(RTF);
var write_txt_str = write_obj_str({from_sheet:sheet_to_txt});
// $FlowIgnore
var write_dbf_buf = write_obj_str(DBF);
var write_eth_str = write_obj_str(ETH);
function fix_opts_func(defaults) {
return function fix_opts(opts) {
@ -18626,6 +18733,7 @@ function writeSync(wb, opts) {
case 'dbf': return write_binary_type(write_dbf_buf(wb, o), o);
case 'prn': return write_string_type(write_prn_str(wb, o), o);
case 'rtf': return write_string_type(write_rtf_str(wb, o), o);
case 'eth': return write_string_type(write_eth_str(wb, o), o);
case 'fods': return write_string_type(write_ods(wb, o), o);
case 'biff2': if(!o.biff) o.biff = 2; /* falls through */
case 'biff3': if(!o.biff) o.biff = 3; /* falls through */
@ -18647,6 +18755,7 @@ function resolve_book_type(o) {
"xls": "biff8",
"htm": "html",
"slk": "sylk",
"socialcalc": "eth",
"Sh33tJS": "WTF"
};
var ext = o.file.slice(o.file.lastIndexOf(".")).toLowerCase();
@ -18893,6 +19002,9 @@ var utils = {
sheet_to_txt: sheet_to_txt,
sheet_to_json: sheet_to_json,
sheet_to_html: HTML_.from_sheet,
sheet_to_dif: DIF.from_sheet,
sheet_to_slk: SYLK.from_sheet,
sheet_to_eth: ETH.from_sheet,
sheet_to_formulae: sheet_to_formulae,
sheet_to_row_object_array: sheet_to_json
};