version bump 0.11.9
- CLI `--book` convert all worksheets (fixes #701 h/t @pmelisko) - Detect ";"-DSV with no "\t" or "," (fixes #875 h/t @sh977218) - editable HTML uses spans for IE6+ compat (fixes #851 h/t @elogicmedia) - XLSB formula structure parallels XLS (fixes #680 h/t @bstiel)
This commit is contained in:
parent
687dcc80b9
commit
7c7f4a69d4
69
bin/xlsx.njs
69
bin/xlsx.njs
|
@ -46,6 +46,7 @@ program
|
|||
.option('--sst', 'generate shared string table for XLS* formats')
|
||||
.option('--compress', 'use compression when writing XLSX/M/B and ODS')
|
||||
.option('--read', 'read but do not generate output')
|
||||
.option('--book', 'for single-sheet formats, emit a file per worksheet')
|
||||
.option('--all', 'parse everything; write as much as possible')
|
||||
.option('--dev', 'development mode')
|
||||
.option('--sparse', 'sparse mode')
|
||||
|
@ -84,7 +85,6 @@ if(!filename) {
|
|||
console.error(n + ": must specify a filename");
|
||||
process.exit(1);
|
||||
}
|
||||
/*:: if(filename) { */
|
||||
if(!fs.existsSync(filename)) {
|
||||
console.error(n + ": " + filename + ": No such file or directory");
|
||||
process.exit(2);
|
||||
|
@ -112,6 +112,9 @@ if(seen) {
|
|||
} else if(program.formulae) opts.cellFormula = true;
|
||||
else opts.cellFormula = false;
|
||||
|
||||
var wopts = ({WTF:opts.WTF, bookSST:program.sst}/*:any*/);
|
||||
if(program.compress) wopts.compression = true;
|
||||
|
||||
if(program.all) {
|
||||
opts.cellFormula = true;
|
||||
opts.bookVBA = true;
|
||||
|
@ -120,6 +123,7 @@ if(program.all) {
|
|||
opts.cellStyles = true;
|
||||
opts.sheetStubs = true;
|
||||
opts.cellDates = true;
|
||||
wopts.cellStyles = true;
|
||||
}
|
||||
if(program.sparse) opts.dense = false; else opts.dense = true;
|
||||
|
||||
|
@ -135,16 +139,13 @@ if(program.dev) {
|
|||
process.exit(3);
|
||||
}
|
||||
if(program.read) process.exit(0);
|
||||
|
||||
/*:: if(wb) { */
|
||||
if(!wb) { console.error(n + ": error parsing " + filename + ": empty workbook"); process.exit(0); }
|
||||
/*:: if(!wb) throw new Error("unreachable"); */
|
||||
if(program.listSheets) {
|
||||
console.log((wb.SheetNames||[]).join("\n"));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
var wopts = ({WTF:opts.WTF, bookSST:program.sst}/*:any*/);
|
||||
if(program.compress) wopts.compression = true;
|
||||
|
||||
/* full workbook formats */
|
||||
workbook_formats.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) {
|
||||
wopts.bookType = m[1];
|
||||
|
@ -176,6 +177,7 @@ try {
|
|||
process.exit(4);
|
||||
}
|
||||
|
||||
if(!program.quiet && !program.book) console.error(target_sheet);
|
||||
|
||||
/* single worksheet file formats */
|
||||
[
|
||||
|
@ -190,27 +192,44 @@ try {
|
|||
['dbf', '.dbf'],
|
||||
['dif', '.dif']
|
||||
].forEach(function(m) { if(program[m[0]] || isfmt(m[1])) {
|
||||
wopts.bookType = m[0];
|
||||
X.writeFile(wb, program.output || sheetname || ((filename || "") + m[1]), wopts);
|
||||
process.exit(0);
|
||||
wopts.bookType = m[0];
|
||||
if(program.book) {
|
||||
wb.SheetNames.forEach(function(n, i) {
|
||||
wopts.sheet = n;
|
||||
X.writeFile(wb, (program.output || sheetname || filename || "") + m[1] + "." + i, wopts);
|
||||
});
|
||||
} else X.writeFile(wb, program.output || sheetname || ((filename || "") + m[1]), wopts);
|
||||
process.exit(0);
|
||||
} });
|
||||
|
||||
var oo = "", strm = false;
|
||||
if(!program.quiet) console.error(target_sheet);
|
||||
if(program.formulae) oo = X.utils.sheet_to_formulae(ws).join("\n");
|
||||
else if(program.json) oo = JSON.stringify(X.utils.sheet_to_json(ws));
|
||||
else if(program.rawJs) oo = JSON.stringify(X.utils.sheet_to_json(ws,{raw:true}));
|
||||
else if(program.arrays) oo = JSON.stringify(X.utils.sheet_to_json(ws,{raw:true, header:1}));
|
||||
else {
|
||||
strm = true;
|
||||
var stream = X.stream.to_csv(ws, {FS:program.fieldSep, RS:program.rowSep});
|
||||
if(program.output) stream.pipe(fs.createWriteStream(program.output));
|
||||
else stream.pipe(process.stdout);
|
||||
function outit(o, fn) { if(fn) fs.writeFileSync(fn, o); else console.log(o); }
|
||||
|
||||
function doit(cb) {
|
||||
if(program.book) wb.SheetNames.forEach(function(n, i) {
|
||||
outit(cb(wb.Sheets[n]), (program.output || sheetname || filename) + "." + i);
|
||||
});
|
||||
else outit(cb(ws), program.output);
|
||||
}
|
||||
|
||||
if(!strm) {
|
||||
if(program.output) fs.writeFileSync(program.output, oo);
|
||||
else console.log(oo);
|
||||
var jso = {};
|
||||
switch(true) {
|
||||
case program.formulae:
|
||||
doit(function(ws) { return X.utils.sheet_to_formulae(ws).join("\n"); });
|
||||
break;
|
||||
|
||||
case program.arrays: jso.header = 1;
|
||||
/* falls through */
|
||||
case program.rawJs: jso.raw = true;
|
||||
/* falls through */
|
||||
case program.json:
|
||||
doit(function(ws) { return JSON.stringify(X.utils.sheet_to_json(ws,jso)); });
|
||||
break;
|
||||
|
||||
default:
|
||||
if(!program.book) {
|
||||
var stream = X.stream.to_csv(ws, {FS:program.fieldSep, RS:program.rowSep});
|
||||
if(program.output) stream.pipe(fs.createWriteStream(program.output));
|
||||
else stream.pipe(process.stdout);
|
||||
} else doit(function(ws) { return X.utils.sheet_to_csv(ws,{FS:program.fieldSep, RS:program.rowSep}); });
|
||||
break;
|
||||
}
|
||||
/*:: } */
|
||||
/*:: } */
|
||||
|
|
|
@ -1 +1 @@
|
|||
XLSX.version = '0.11.8';
|
||||
XLSX.version = '0.11.9';
|
||||
|
|
|
@ -20,7 +20,7 @@ function recordhopper(data, cb/*:RecordHopperCB*/, opts/*:?any*/) {
|
|||
|
||||
/* control buffer usage for fixed-length buffers */
|
||||
function buf_array()/*:BufArray*/ {
|
||||
var bufs = [], blksz = 2048;
|
||||
var bufs = [], blksz = has_buf ? 256 : 2048;
|
||||
var newblk = function ba_newblk(sz) {
|
||||
var o/*:Block*/ = (new_buf(sz)/*:any*/);
|
||||
prep_blob(o, 0);
|
||||
|
|
|
@ -714,7 +714,7 @@ var PRN = (function() {
|
|||
|
||||
function prn_to_sheet_str(str/*:string*/, opts)/*:Worksheet*/ {
|
||||
if(str.substr(0,4) == "sep=") return dsv_to_sheet_str(str, opts);
|
||||
if(str.indexOf("\t") >= 0 || str.indexOf(",") >= 0) 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -691,12 +691,43 @@ var PtgBinOp = {
|
|||
PtgSub: "-"
|
||||
};
|
||||
function formula_quote_sheet_name(sname/*:string*/)/*:string*/ {
|
||||
if(!sname) return "";
|
||||
if(!sname) throw new Error("empty sheet name");
|
||||
if(sname.indexOf(" ") > -1) return "'" + sname + "'";
|
||||
return sname;
|
||||
}
|
||||
function get_ixti_raw(supbooks, ixti/*:number*/, opts)/*:string*/ {
|
||||
return supbooks.SheetNames[ixti];
|
||||
if(!supbooks) return "SH33TJSERR0";
|
||||
if(!supbooks.XTI) return "SH33TJSERR6";
|
||||
var XTI = supbooks.XTI[ixti];
|
||||
if(opts.biff > 8 && !supbooks.XTI[ixti]) return supbooks.SheetNames[ixti];
|
||||
if(opts.biff < 8) {
|
||||
if(ixti > 10000) ixti-= 65536;
|
||||
if(ixti < 0) ixti = -ixti;
|
||||
return ixti == 0 ? "" : supbooks.XTI[ixti - 1];
|
||||
}
|
||||
if(!XTI) return "SH33TJSERR1";
|
||||
var o = "";
|
||||
if(opts.biff > 8) switch(supbooks[XTI[0]][0]) {
|
||||
case 0x0165: /* 'BrtSupSelf' */
|
||||
o = XTI[1] == -1 ? "#REF" : supbooks.SheetNames[XTI[1]];
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x0166: /* 'BrtSupSame' */
|
||||
if(opts.SID != null) return supbooks.SheetNames[opts.SID];
|
||||
return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
/* falls through */
|
||||
default: return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
}
|
||||
switch(supbooks[XTI[0]][0][0]) {
|
||||
case 0x0401:
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks.SheetNames[XTI[1]] || "SH33TJSERR3");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x3A01: return "SH33TJSERR8";
|
||||
default:
|
||||
if(!supbooks[XTI[0]][0][3]) return "SH33TJSERR2";
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks[XTI[0]][0][3][XTI[1]] || "SH33TJSERR4");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks[XTI[0]][0][3][XTI[2]];
|
||||
}
|
||||
}
|
||||
function get_ixti(supbooks, ixti/*:number*/, opts)/*:string*/ {
|
||||
return formula_quote_sheet_name(get_ixti_raw(supbooks, ixti, opts));
|
||||
|
@ -818,7 +849,8 @@ function stringify_formula(formula/*Array<any>*/, range, cell/*:any*/, supbooks,
|
|||
break;
|
||||
case 'PtgArea3d': /* 2.5.198.28 TODO */
|
||||
type = f[1][0]; ixti = /*::Number(*/f[1][1]/*::)*/; r = f[1][2];
|
||||
sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
//sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
sname = get_ixti(supbooks, ixti, opts);
|
||||
stack.push(sname + "!" + encode_range_xls((r/*:any*/), opts));
|
||||
break;
|
||||
case 'PtgAttrSum': /* 2.5.198.41 */
|
||||
|
@ -845,7 +877,6 @@ function stringify_formula(formula/*Array<any>*/, range, cell/*:any*/, supbooks,
|
|||
if(bookidx < 0) bookidx = -bookidx;
|
||||
if(supbooks[bookidx]) externbook = supbooks[bookidx][nameidx];
|
||||
} else {
|
||||
var pnxname = supbooks.SheetNames[bookidx];
|
||||
var o = "";
|
||||
if(((supbooks[bookidx]||[])[0]||[])[0] == 0x3A01){/* empty */}
|
||||
else if(((supbooks[bookidx]||[])[0]||[])[0] == 0x0401){
|
||||
|
|
|
@ -402,12 +402,14 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
|
|||
|
||||
var array_formulae = [];
|
||||
var shared_formulae = {};
|
||||
var supbooks = ([[]]/*:any*/);
|
||||
var supbooks = opts.supbooks || ([[]]/*:any*/);
|
||||
supbooks.sharedf = shared_formulae;
|
||||
supbooks.arrayf = array_formulae;
|
||||
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
if(!opts.supbooks) {
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
}
|
||||
|
||||
var colinfo = [], rowinfo = [];
|
||||
var defwidth = 0, defheight = 0; // twips / MDW respectively
|
||||
|
|
|
@ -91,8 +91,9 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
opts.biff = 12;
|
||||
|
||||
var Names = [];
|
||||
var supbooks = ([]/*:any*/);
|
||||
var supbooks = ([[]]/*:any*/);
|
||||
supbooks.SheetNames = [];
|
||||
supbooks.XTI = [];
|
||||
|
||||
recordhopper(data, function hopper_wb(val, R_n, RT) {
|
||||
switch(RT) {
|
||||
|
@ -104,7 +105,9 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
wb.WBProps = val; break;
|
||||
|
||||
case 0x0027: /* 'BrtName' */
|
||||
if(val.Sheet != null) opts.SID = val.Sheet;
|
||||
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
|
||||
delete opts.SID;
|
||||
delete val.Ptg;
|
||||
Names.push(val);
|
||||
break;
|
||||
|
@ -114,7 +117,15 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
case 0x0166: /* 'BrtSupSame' */
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
case 0x029B: /* 'BrtSupAddin' */
|
||||
if(!supbooks[0].length) supbooks[0] = [RT, val];
|
||||
else supbooks.push([RT, val]);
|
||||
supbooks[supbooks.length - 1].XTI = [];
|
||||
break;
|
||||
case 0x016A: /* 'BrtExternSheet' */
|
||||
if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
|
||||
supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
|
||||
supbooks.XTI = supbooks.XTI.concat(val);
|
||||
break;
|
||||
case 0x0169: /* 'BrtPlaceholderName' */
|
||||
break;
|
||||
|
||||
|
@ -169,6 +180,7 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
// $FlowIgnore
|
||||
wb.Names = Names;
|
||||
|
||||
(wb/*:any*/).supbooks = supbooks;
|
||||
return wb;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ function parse_xlml_data(xml, ss, data, cell/*:any*/, base, styles, csty, row, a
|
|||
});
|
||||
cell.s = S;
|
||||
}
|
||||
cell.ixfe = cell.StyleID !== undefined ? cell.StyleID : 'Default';
|
||||
if(cell.StyleID !== undefined) cell.ixfe = cell.StyleID;
|
||||
}
|
||||
|
||||
function xlml_clean_comment(comment/*:any*/) {
|
||||
|
|
|
@ -869,7 +869,7 @@ else/*:: if(cfb instanceof CFBContainer) */ {
|
|||
/* Quattro Pro 9 */
|
||||
else if((_data=CFB.find(cfb, 'NativeContent_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));
|
||||
else throw new Error("Cannot find Workbook stream");
|
||||
if(options.bookVBA && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
if(options.bookVBA && cfb.FullPaths && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
}
|
||||
|
||||
var props = {};
|
||||
|
|
|
@ -66,7 +66,7 @@ var HTML_ = (function() {
|
|||
function make_html_row(ws/*:Worksheet*/, r/*:Range*/, R/*:number*/, o/*:Sheet2HTMLOpts*/)/*:string*/ {
|
||||
var M = (ws['!merges'] ||[]);
|
||||
var oo = [];
|
||||
var nullcell = "<td" + (o.editable ? ' contenteditable="true"' : "" ) + "></td>";
|
||||
var nullcell = "<td>" + (o.editable ? '<span contenteditable="true"></span>' : "" ) + "</td>";
|
||||
for(var C = r.s.c; C <= r.e.c; ++C) {
|
||||
var RS = 0, CS = 0;
|
||||
for(var j = 0; j < M.length; ++j) {
|
||||
|
@ -84,7 +84,7 @@ var HTML_ = (function() {
|
|||
var sp = {};
|
||||
if(RS > 1) sp.rowspan = RS;
|
||||
if(CS > 1) sp.colspan = CS;
|
||||
if(o.editable) sp.contenteditable = "true";
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>'
|
||||
sp.id = "sjs-" + coord;
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ var XLSX = require('../../'); // test against development version
|
|||
//var XLSX = require('xlsx'); // use in production
|
||||
/*jshint browser:true */
|
||||
/*global require */
|
||||
var X = require('xlsx');
|
||||
var X = XLSX;
|
||||
var XW = {
|
||||
/* worker message */
|
||||
msg: 'xlsx',
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
/*global global, exports, module, require:false, process:false, Buffer:false */
|
||||
var XLSX = {};
|
||||
(function make_xlsx(XLSX){
|
||||
XLSX.version = '0.11.8';
|
||||
XLSX.version = '0.11.9';
|
||||
var current_codepage = 1200;
|
||||
/*global cptable:true */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
|
@ -2430,7 +2430,7 @@ function recordhopper(data, cb, opts) {
|
|||
|
||||
/* control buffer usage for fixed-length buffers */
|
||||
function buf_array() {
|
||||
var bufs = [], blksz = 2048;
|
||||
var bufs = [], blksz = has_buf ? 256 : 2048;
|
||||
var newblk = function ba_newblk(sz) {
|
||||
var o = (new_buf(sz));
|
||||
prep_blob(o, 0);
|
||||
|
@ -6122,7 +6122,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.indexOf("\t") >= 0 || str.indexOf(",") >= 0) 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);
|
||||
}
|
||||
|
||||
|
@ -9545,12 +9545,43 @@ var PtgBinOp = {
|
|||
PtgSub: "-"
|
||||
};
|
||||
function formula_quote_sheet_name(sname) {
|
||||
if(!sname) return "";
|
||||
if(!sname) throw new Error("empty sheet name");
|
||||
if(sname.indexOf(" ") > -1) return "'" + sname + "'";
|
||||
return sname;
|
||||
}
|
||||
function get_ixti_raw(supbooks, ixti, opts) {
|
||||
return supbooks.SheetNames[ixti];
|
||||
if(!supbooks) return "SH33TJSERR0";
|
||||
if(!supbooks.XTI) return "SH33TJSERR6";
|
||||
var XTI = supbooks.XTI[ixti];
|
||||
if(opts.biff > 8 && !supbooks.XTI[ixti]) return supbooks.SheetNames[ixti];
|
||||
if(opts.biff < 8) {
|
||||
if(ixti > 10000) ixti-= 65536;
|
||||
if(ixti < 0) ixti = -ixti;
|
||||
return ixti == 0 ? "" : supbooks.XTI[ixti - 1];
|
||||
}
|
||||
if(!XTI) return "SH33TJSERR1";
|
||||
var o = "";
|
||||
if(opts.biff > 8) switch(supbooks[XTI[0]][0]) {
|
||||
case 0x0165: /* 'BrtSupSelf' */
|
||||
o = XTI[1] == -1 ? "#REF" : supbooks.SheetNames[XTI[1]];
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x0166: /* 'BrtSupSame' */
|
||||
if(opts.SID != null) return supbooks.SheetNames[opts.SID];
|
||||
return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
/* falls through */
|
||||
default: return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
}
|
||||
switch(supbooks[XTI[0]][0][0]) {
|
||||
case 0x0401:
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks.SheetNames[XTI[1]] || "SH33TJSERR3");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x3A01: return "SH33TJSERR8";
|
||||
default:
|
||||
if(!supbooks[XTI[0]][0][3]) return "SH33TJSERR2";
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks[XTI[0]][0][3][XTI[1]] || "SH33TJSERR4");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks[XTI[0]][0][3][XTI[2]];
|
||||
}
|
||||
}
|
||||
function get_ixti(supbooks, ixti, opts) {
|
||||
return formula_quote_sheet_name(get_ixti_raw(supbooks, ixti, opts));
|
||||
|
@ -9672,7 +9703,8 @@ function stringify_formula(formula/*Array<any>*/, range, cell, supbooks, opts) {
|
|||
break;
|
||||
case 'PtgArea3d': /* 2.5.198.28 TODO */
|
||||
type = f[1][0]; ixti = f[1][1]; r = f[1][2];
|
||||
sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
//sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
sname = get_ixti(supbooks, ixti, opts);
|
||||
stack.push(sname + "!" + encode_range_xls((r), opts));
|
||||
break;
|
||||
case 'PtgAttrSum': /* 2.5.198.41 */
|
||||
|
@ -9699,7 +9731,6 @@ function stringify_formula(formula/*Array<any>*/, range, cell, supbooks, opts) {
|
|||
if(bookidx < 0) bookidx = -bookidx;
|
||||
if(supbooks[bookidx]) externbook = supbooks[bookidx][nameidx];
|
||||
} else {
|
||||
var pnxname = supbooks.SheetNames[bookidx];
|
||||
var o = "";
|
||||
if(((supbooks[bookidx]||[])[0]||[])[0] == 0x3A01){/* empty */}
|
||||
else if(((supbooks[bookidx]||[])[0]||[])[0] == 0x0401){
|
||||
|
@ -12259,12 +12290,14 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
|
|||
|
||||
var array_formulae = [];
|
||||
var shared_formulae = {};
|
||||
var supbooks = ([[]]);
|
||||
var supbooks = opts.supbooks || ([[]]);
|
||||
supbooks.sharedf = shared_formulae;
|
||||
supbooks.arrayf = array_formulae;
|
||||
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
if(!opts.supbooks) {
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
}
|
||||
|
||||
var colinfo = [], rowinfo = [];
|
||||
var defwidth = 0, defheight = 0; // twips / MDW respectively
|
||||
|
@ -13264,8 +13297,9 @@ function parse_wb_bin(data, opts) {
|
|||
opts.biff = 12;
|
||||
|
||||
var Names = [];
|
||||
var supbooks = ([]);
|
||||
var supbooks = ([[]]);
|
||||
supbooks.SheetNames = [];
|
||||
supbooks.XTI = [];
|
||||
|
||||
recordhopper(data, function hopper_wb(val, R_n, RT) {
|
||||
switch(RT) {
|
||||
|
@ -13277,7 +13311,9 @@ function parse_wb_bin(data, opts) {
|
|||
wb.WBProps = val; break;
|
||||
|
||||
case 0x0027: /* 'BrtName' */
|
||||
if(val.Sheet != null) opts.SID = val.Sheet;
|
||||
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
|
||||
delete opts.SID;
|
||||
delete val.Ptg;
|
||||
Names.push(val);
|
||||
break;
|
||||
|
@ -13287,7 +13323,15 @@ function parse_wb_bin(data, opts) {
|
|||
case 0x0166: /* 'BrtSupSame' */
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
case 0x029B: /* 'BrtSupAddin' */
|
||||
if(!supbooks[0].length) supbooks[0] = [RT, val];
|
||||
else supbooks.push([RT, val]);
|
||||
supbooks[supbooks.length - 1].XTI = [];
|
||||
break;
|
||||
case 0x016A: /* 'BrtExternSheet' */
|
||||
if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
|
||||
supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
|
||||
supbooks.XTI = supbooks.XTI.concat(val);
|
||||
break;
|
||||
case 0x0169: /* 'BrtPlaceholderName' */
|
||||
break;
|
||||
|
||||
|
@ -13342,6 +13386,7 @@ function parse_wb_bin(data, opts) {
|
|||
// $FlowIgnore
|
||||
wb.Names = Names;
|
||||
|
||||
(wb).supbooks = supbooks;
|
||||
return wb;
|
||||
}
|
||||
|
||||
|
@ -13682,7 +13727,7 @@ function parse_xlml_data(xml, ss, data, cell, base, styles, csty, row, arrayf, o
|
|||
});
|
||||
cell.s = S;
|
||||
}
|
||||
cell.ixfe = cell.StyleID !== undefined ? cell.StyleID : 'Default';
|
||||
if(cell.StyleID !== undefined) cell.ixfe = cell.StyleID;
|
||||
}
|
||||
|
||||
function xlml_clean_comment(comment) {
|
||||
|
@ -15482,7 +15527,7 @@ else {
|
|||
/* Quattro Pro 9 */
|
||||
else if((_data=CFB.find(cfb, 'NativeContent_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));
|
||||
else throw new Error("Cannot find Workbook stream");
|
||||
if(options.bookVBA && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
if(options.bookVBA && cfb.FullPaths && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
}
|
||||
|
||||
var props = {};
|
||||
|
@ -17058,7 +17103,7 @@ var HTML_ = (function() {
|
|||
function make_html_row(ws, r, R, o) {
|
||||
var M = (ws['!merges'] ||[]);
|
||||
var oo = [];
|
||||
var nullcell = "<td" + (o.editable ? ' contenteditable="true"' : "" ) + "></td>";
|
||||
var nullcell = "<td>" + (o.editable ? '<span contenteditable="true"></span>' : "" ) + "</td>";
|
||||
for(var C = r.s.c; C <= r.e.c; ++C) {
|
||||
var RS = 0, CS = 0;
|
||||
for(var j = 0; j < M.length; ++j) {
|
||||
|
@ -17076,7 +17121,7 @@ var HTML_ = (function() {
|
|||
var sp = {};
|
||||
if(RS > 1) sp.rowspan = RS;
|
||||
if(CS > 1) sp.colspan = CS;
|
||||
if(o.editable) sp.contenteditable = "true";
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>'
|
||||
sp.id = "sjs-" + coord;
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
49
package.json
49
package.json
|
@ -1,9 +1,22 @@
|
|||
{
|
||||
"name": "xlsx",
|
||||
"version": "0.11.8",
|
||||
"version": "0.11.9",
|
||||
"author": "sheetjs",
|
||||
"description": "SheetJS Spreadsheet data parser and writer",
|
||||
"keywords": [ "excel", "xls", "xlsx", "xlsb", "xlsm", "ods", "csv", "dbf", "dif", "sylk", "office", "spreadsheet" ],
|
||||
"keywords": [
|
||||
"excel",
|
||||
"xls",
|
||||
"xlsx",
|
||||
"xlsb",
|
||||
"xlsm",
|
||||
"ods",
|
||||
"csv",
|
||||
"dbf",
|
||||
"dif",
|
||||
"sylk",
|
||||
"office",
|
||||
"spreadsheet"
|
||||
],
|
||||
"bin": {
|
||||
"xlsx": "./bin/xlsx.njs"
|
||||
},
|
||||
|
@ -17,13 +30,13 @@
|
|||
"fs": false
|
||||
},
|
||||
"dependencies": {
|
||||
"exit-on-epipe": "~1.0.1",
|
||||
"ssf": "~0.10.1",
|
||||
"codepage": "~1.11.0",
|
||||
"cfb": "~1.0.0",
|
||||
"crc-32": "~1.1.1",
|
||||
"adler-32": "~1.1.0",
|
||||
"commander": "~2.11.0"
|
||||
"cfb": "~1.0.0",
|
||||
"codepage": "~1.11.0",
|
||||
"commander": "~2.11.0",
|
||||
"crc-32": "~1.1.1",
|
||||
"exit-on-epipe": "~1.0.1",
|
||||
"ssf": "~0.10.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "~2.5.3",
|
||||
|
@ -35,7 +48,10 @@
|
|||
"dtslint": "^0.1.2",
|
||||
"typescript": "2.2.0"
|
||||
},
|
||||
"repository": { "type":"git", "url":"git://github.com/SheetJS/js-xlsx.git" },
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/SheetJS/js-xlsx.git"
|
||||
},
|
||||
"scripts": {
|
||||
"pretest": "git submodule init && git submodule update",
|
||||
"test": "make travis",
|
||||
|
@ -48,9 +64,18 @@
|
|||
"pattern": "xlsx.js"
|
||||
}
|
||||
},
|
||||
"alex": { "allow": ["wtf", "holes"] },
|
||||
"alex": {
|
||||
"allow": [
|
||||
"wtf",
|
||||
"holes"
|
||||
]
|
||||
},
|
||||
"homepage": "http://sheetjs.com/opensource",
|
||||
"bugs": { "url": "https://github.com/SheetJS/js-xlsx/issues" },
|
||||
"bugs": {
|
||||
"url": "https://github.com/SheetJS/js-xlsx/issues"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"engines": { "node": ">=0.8" }
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
}
|
||||
|
|
75
xlsx.flow.js
75
xlsx.flow.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.8';
|
||||
XLSX.version = '0.11.9';
|
||||
var current_codepage = 1200;
|
||||
/*:: declare var cptable:any; */
|
||||
/*global cptable:true */
|
||||
|
@ -2507,7 +2507,7 @@ function recordhopper(data, cb/*:RecordHopperCB*/, opts/*:?any*/) {
|
|||
|
||||
/* control buffer usage for fixed-length buffers */
|
||||
function buf_array()/*:BufArray*/ {
|
||||
var bufs = [], blksz = 2048;
|
||||
var bufs = [], blksz = has_buf ? 256 : 2048;
|
||||
var newblk = function ba_newblk(sz) {
|
||||
var o/*:Block*/ = (new_buf(sz)/*:any*/);
|
||||
prep_blob(o, 0);
|
||||
|
@ -6207,7 +6207,7 @@ var PRN = (function() {
|
|||
|
||||
function prn_to_sheet_str(str/*:string*/, opts)/*:Worksheet*/ {
|
||||
if(str.substr(0,4) == "sep=") return dsv_to_sheet_str(str, opts);
|
||||
if(str.indexOf("\t") >= 0 || str.indexOf(",") >= 0) 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);
|
||||
}
|
||||
|
||||
|
@ -9634,12 +9634,43 @@ var PtgBinOp = {
|
|||
PtgSub: "-"
|
||||
};
|
||||
function formula_quote_sheet_name(sname/*:string*/)/*:string*/ {
|
||||
if(!sname) return "";
|
||||
if(!sname) throw new Error("empty sheet name");
|
||||
if(sname.indexOf(" ") > -1) return "'" + sname + "'";
|
||||
return sname;
|
||||
}
|
||||
function get_ixti_raw(supbooks, ixti/*:number*/, opts)/*:string*/ {
|
||||
return supbooks.SheetNames[ixti];
|
||||
if(!supbooks) return "SH33TJSERR0";
|
||||
if(!supbooks.XTI) return "SH33TJSERR6";
|
||||
var XTI = supbooks.XTI[ixti];
|
||||
if(opts.biff > 8 && !supbooks.XTI[ixti]) return supbooks.SheetNames[ixti];
|
||||
if(opts.biff < 8) {
|
||||
if(ixti > 10000) ixti-= 65536;
|
||||
if(ixti < 0) ixti = -ixti;
|
||||
return ixti == 0 ? "" : supbooks.XTI[ixti - 1];
|
||||
}
|
||||
if(!XTI) return "SH33TJSERR1";
|
||||
var o = "";
|
||||
if(opts.biff > 8) switch(supbooks[XTI[0]][0]) {
|
||||
case 0x0165: /* 'BrtSupSelf' */
|
||||
o = XTI[1] == -1 ? "#REF" : supbooks.SheetNames[XTI[1]];
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x0166: /* 'BrtSupSame' */
|
||||
if(opts.SID != null) return supbooks.SheetNames[opts.SID];
|
||||
return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
/* falls through */
|
||||
default: return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
}
|
||||
switch(supbooks[XTI[0]][0][0]) {
|
||||
case 0x0401:
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks.SheetNames[XTI[1]] || "SH33TJSERR3");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x3A01: return "SH33TJSERR8";
|
||||
default:
|
||||
if(!supbooks[XTI[0]][0][3]) return "SH33TJSERR2";
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks[XTI[0]][0][3][XTI[1]] || "SH33TJSERR4");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks[XTI[0]][0][3][XTI[2]];
|
||||
}
|
||||
}
|
||||
function get_ixti(supbooks, ixti/*:number*/, opts)/*:string*/ {
|
||||
return formula_quote_sheet_name(get_ixti_raw(supbooks, ixti, opts));
|
||||
|
@ -9761,7 +9792,8 @@ function stringify_formula(formula/*Array<any>*/, range, cell/*:any*/, supbooks,
|
|||
break;
|
||||
case 'PtgArea3d': /* 2.5.198.28 TODO */
|
||||
type = f[1][0]; ixti = /*::Number(*/f[1][1]/*::)*/; r = f[1][2];
|
||||
sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
//sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
sname = get_ixti(supbooks, ixti, opts);
|
||||
stack.push(sname + "!" + encode_range_xls((r/*:any*/), opts));
|
||||
break;
|
||||
case 'PtgAttrSum': /* 2.5.198.41 */
|
||||
|
@ -9788,7 +9820,6 @@ function stringify_formula(formula/*Array<any>*/, range, cell/*:any*/, supbooks,
|
|||
if(bookidx < 0) bookidx = -bookidx;
|
||||
if(supbooks[bookidx]) externbook = supbooks[bookidx][nameidx];
|
||||
} else {
|
||||
var pnxname = supbooks.SheetNames[bookidx];
|
||||
var o = "";
|
||||
if(((supbooks[bookidx]||[])[0]||[])[0] == 0x3A01){/* empty */}
|
||||
else if(((supbooks[bookidx]||[])[0]||[])[0] == 0x0401){
|
||||
|
@ -12349,12 +12380,14 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles)/*:Worksheet*/ {
|
|||
|
||||
var array_formulae = [];
|
||||
var shared_formulae = {};
|
||||
var supbooks = ([[]]/*:any*/);
|
||||
var supbooks = opts.supbooks || ([[]]/*:any*/);
|
||||
supbooks.sharedf = shared_formulae;
|
||||
supbooks.arrayf = array_formulae;
|
||||
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
if(!opts.supbooks) {
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
}
|
||||
|
||||
var colinfo = [], rowinfo = [];
|
||||
var defwidth = 0, defheight = 0; // twips / MDW respectively
|
||||
|
@ -13355,8 +13388,9 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
opts.biff = 12;
|
||||
|
||||
var Names = [];
|
||||
var supbooks = ([]/*:any*/);
|
||||
var supbooks = ([[]]/*:any*/);
|
||||
supbooks.SheetNames = [];
|
||||
supbooks.XTI = [];
|
||||
|
||||
recordhopper(data, function hopper_wb(val, R_n, RT) {
|
||||
switch(RT) {
|
||||
|
@ -13368,7 +13402,9 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
wb.WBProps = val; break;
|
||||
|
||||
case 0x0027: /* 'BrtName' */
|
||||
if(val.Sheet != null) opts.SID = val.Sheet;
|
||||
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
|
||||
delete opts.SID;
|
||||
delete val.Ptg;
|
||||
Names.push(val);
|
||||
break;
|
||||
|
@ -13378,7 +13414,15 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
case 0x0166: /* 'BrtSupSame' */
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
case 0x029B: /* 'BrtSupAddin' */
|
||||
if(!supbooks[0].length) supbooks[0] = [RT, val];
|
||||
else supbooks.push([RT, val]);
|
||||
supbooks[supbooks.length - 1].XTI = [];
|
||||
break;
|
||||
case 0x016A: /* 'BrtExternSheet' */
|
||||
if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
|
||||
supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
|
||||
supbooks.XTI = supbooks.XTI.concat(val);
|
||||
break;
|
||||
case 0x0169: /* 'BrtPlaceholderName' */
|
||||
break;
|
||||
|
||||
|
@ -13433,6 +13477,7 @@ function parse_wb_bin(data, opts)/*:WorkbookFile*/ {
|
|||
// $FlowIgnore
|
||||
wb.Names = Names;
|
||||
|
||||
(wb/*:any*/).supbooks = supbooks;
|
||||
return wb;
|
||||
}
|
||||
|
||||
|
@ -13775,7 +13820,7 @@ function parse_xlml_data(xml, ss, data, cell/*:any*/, base, styles, csty, row, a
|
|||
});
|
||||
cell.s = S;
|
||||
}
|
||||
cell.ixfe = cell.StyleID !== undefined ? cell.StyleID : 'Default';
|
||||
if(cell.StyleID !== undefined) cell.ixfe = cell.StyleID;
|
||||
}
|
||||
|
||||
function xlml_clean_comment(comment/*:any*/) {
|
||||
|
@ -15582,7 +15627,7 @@ else/*:: if(cfb instanceof CFBContainer) */ {
|
|||
/* Quattro Pro 9 */
|
||||
else if((_data=CFB.find(cfb, 'NativeContent_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));
|
||||
else throw new Error("Cannot find Workbook stream");
|
||||
if(options.bookVBA && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
if(options.bookVBA && cfb.FullPaths && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
}
|
||||
|
||||
var props = {};
|
||||
|
@ -17158,7 +17203,7 @@ var HTML_ = (function() {
|
|||
function make_html_row(ws/*:Worksheet*/, r/*:Range*/, R/*:number*/, o/*:Sheet2HTMLOpts*/)/*:string*/ {
|
||||
var M = (ws['!merges'] ||[]);
|
||||
var oo = [];
|
||||
var nullcell = "<td" + (o.editable ? ' contenteditable="true"' : "" ) + "></td>";
|
||||
var nullcell = "<td>" + (o.editable ? '<span contenteditable="true"></span>' : "" ) + "</td>";
|
||||
for(var C = r.s.c; C <= r.e.c; ++C) {
|
||||
var RS = 0, CS = 0;
|
||||
for(var j = 0; j < M.length; ++j) {
|
||||
|
@ -17176,7 +17221,7 @@ var HTML_ = (function() {
|
|||
var sp = {};
|
||||
if(RS > 1) sp.rowspan = RS;
|
||||
if(CS > 1) sp.colspan = CS;
|
||||
if(o.editable) sp.contenteditable = "true";
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>'
|
||||
sp.id = "sjs-" + coord;
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
|
|
75
xlsx.js
75
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.8';
|
||||
XLSX.version = '0.11.9';
|
||||
var current_codepage = 1200;
|
||||
/*global cptable:true */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
|
@ -2430,7 +2430,7 @@ function recordhopper(data, cb, opts) {
|
|||
|
||||
/* control buffer usage for fixed-length buffers */
|
||||
function buf_array() {
|
||||
var bufs = [], blksz = 2048;
|
||||
var bufs = [], blksz = has_buf ? 256 : 2048;
|
||||
var newblk = function ba_newblk(sz) {
|
||||
var o = (new_buf(sz));
|
||||
prep_blob(o, 0);
|
||||
|
@ -6122,7 +6122,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.indexOf("\t") >= 0 || str.indexOf(",") >= 0) 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);
|
||||
}
|
||||
|
||||
|
@ -9545,12 +9545,43 @@ var PtgBinOp = {
|
|||
PtgSub: "-"
|
||||
};
|
||||
function formula_quote_sheet_name(sname) {
|
||||
if(!sname) return "";
|
||||
if(!sname) throw new Error("empty sheet name");
|
||||
if(sname.indexOf(" ") > -1) return "'" + sname + "'";
|
||||
return sname;
|
||||
}
|
||||
function get_ixti_raw(supbooks, ixti, opts) {
|
||||
return supbooks.SheetNames[ixti];
|
||||
if(!supbooks) return "SH33TJSERR0";
|
||||
if(!supbooks.XTI) return "SH33TJSERR6";
|
||||
var XTI = supbooks.XTI[ixti];
|
||||
if(opts.biff > 8 && !supbooks.XTI[ixti]) return supbooks.SheetNames[ixti];
|
||||
if(opts.biff < 8) {
|
||||
if(ixti > 10000) ixti-= 65536;
|
||||
if(ixti < 0) ixti = -ixti;
|
||||
return ixti == 0 ? "" : supbooks.XTI[ixti - 1];
|
||||
}
|
||||
if(!XTI) return "SH33TJSERR1";
|
||||
var o = "";
|
||||
if(opts.biff > 8) switch(supbooks[XTI[0]][0]) {
|
||||
case 0x0165: /* 'BrtSupSelf' */
|
||||
o = XTI[1] == -1 ? "#REF" : supbooks.SheetNames[XTI[1]];
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x0166: /* 'BrtSupSame' */
|
||||
if(opts.SID != null) return supbooks.SheetNames[opts.SID];
|
||||
return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
/* falls through */
|
||||
default: return "SH33TJSERR" + supbooks[XTI[0]][0];
|
||||
}
|
||||
switch(supbooks[XTI[0]][0][0]) {
|
||||
case 0x0401:
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks.SheetNames[XTI[1]] || "SH33TJSERR3");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks.SheetNames[XTI[2]];
|
||||
case 0x3A01: return "SH33TJSERR8";
|
||||
default:
|
||||
if(!supbooks[XTI[0]][0][3]) return "SH33TJSERR2";
|
||||
o = XTI[1] == -1 ? "#REF" : (supbooks[XTI[0]][0][3][XTI[1]] || "SH33TJSERR4");
|
||||
return XTI[1] == XTI[2] ? o : o + ":" + supbooks[XTI[0]][0][3][XTI[2]];
|
||||
}
|
||||
}
|
||||
function get_ixti(supbooks, ixti, opts) {
|
||||
return formula_quote_sheet_name(get_ixti_raw(supbooks, ixti, opts));
|
||||
|
@ -9672,7 +9703,8 @@ function stringify_formula(formula/*Array<any>*/, range, cell, supbooks, opts) {
|
|||
break;
|
||||
case 'PtgArea3d': /* 2.5.198.28 TODO */
|
||||
type = f[1][0]; ixti = f[1][1]; r = f[1][2];
|
||||
sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
//sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**");
|
||||
sname = get_ixti(supbooks, ixti, opts);
|
||||
stack.push(sname + "!" + encode_range_xls((r), opts));
|
||||
break;
|
||||
case 'PtgAttrSum': /* 2.5.198.41 */
|
||||
|
@ -9699,7 +9731,6 @@ function stringify_formula(formula/*Array<any>*/, range, cell, supbooks, opts) {
|
|||
if(bookidx < 0) bookidx = -bookidx;
|
||||
if(supbooks[bookidx]) externbook = supbooks[bookidx][nameidx];
|
||||
} else {
|
||||
var pnxname = supbooks.SheetNames[bookidx];
|
||||
var o = "";
|
||||
if(((supbooks[bookidx]||[])[0]||[])[0] == 0x3A01){/* empty */}
|
||||
else if(((supbooks[bookidx]||[])[0]||[])[0] == 0x0401){
|
||||
|
@ -12259,12 +12290,14 @@ function parse_ws_bin(data, _opts, rels, wb, themes, styles) {
|
|||
|
||||
var array_formulae = [];
|
||||
var shared_formulae = {};
|
||||
var supbooks = ([[]]);
|
||||
var supbooks = opts.supbooks || ([[]]);
|
||||
supbooks.sharedf = shared_formulae;
|
||||
supbooks.arrayf = array_formulae;
|
||||
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
if(!opts.supbooks) {
|
||||
opts.supbooks = supbooks;
|
||||
for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
|
||||
}
|
||||
|
||||
var colinfo = [], rowinfo = [];
|
||||
var defwidth = 0, defheight = 0; // twips / MDW respectively
|
||||
|
@ -13264,8 +13297,9 @@ function parse_wb_bin(data, opts) {
|
|||
opts.biff = 12;
|
||||
|
||||
var Names = [];
|
||||
var supbooks = ([]);
|
||||
var supbooks = ([[]]);
|
||||
supbooks.SheetNames = [];
|
||||
supbooks.XTI = [];
|
||||
|
||||
recordhopper(data, function hopper_wb(val, R_n, RT) {
|
||||
switch(RT) {
|
||||
|
@ -13277,7 +13311,9 @@ function parse_wb_bin(data, opts) {
|
|||
wb.WBProps = val; break;
|
||||
|
||||
case 0x0027: /* 'BrtName' */
|
||||
if(val.Sheet != null) opts.SID = val.Sheet;
|
||||
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
|
||||
delete opts.SID;
|
||||
delete val.Ptg;
|
||||
Names.push(val);
|
||||
break;
|
||||
|
@ -13287,7 +13323,15 @@ function parse_wb_bin(data, opts) {
|
|||
case 0x0166: /* 'BrtSupSame' */
|
||||
case 0x0163: /* 'BrtSupBookSrc' */
|
||||
case 0x029B: /* 'BrtSupAddin' */
|
||||
if(!supbooks[0].length) supbooks[0] = [RT, val];
|
||||
else supbooks.push([RT, val]);
|
||||
supbooks[supbooks.length - 1].XTI = [];
|
||||
break;
|
||||
case 0x016A: /* 'BrtExternSheet' */
|
||||
if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
|
||||
supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
|
||||
supbooks.XTI = supbooks.XTI.concat(val);
|
||||
break;
|
||||
case 0x0169: /* 'BrtPlaceholderName' */
|
||||
break;
|
||||
|
||||
|
@ -13342,6 +13386,7 @@ function parse_wb_bin(data, opts) {
|
|||
// $FlowIgnore
|
||||
wb.Names = Names;
|
||||
|
||||
(wb).supbooks = supbooks;
|
||||
return wb;
|
||||
}
|
||||
|
||||
|
@ -13682,7 +13727,7 @@ function parse_xlml_data(xml, ss, data, cell, base, styles, csty, row, arrayf, o
|
|||
});
|
||||
cell.s = S;
|
||||
}
|
||||
cell.ixfe = cell.StyleID !== undefined ? cell.StyleID : 'Default';
|
||||
if(cell.StyleID !== undefined) cell.ixfe = cell.StyleID;
|
||||
}
|
||||
|
||||
function xlml_clean_comment(comment) {
|
||||
|
@ -15482,7 +15527,7 @@ else {
|
|||
/* Quattro Pro 9 */
|
||||
else if((_data=CFB.find(cfb, 'NativeContent_MAIN')) && _data.content) WorkbookP = WK_.to_workbook(_data.content, (options.type = T, options));
|
||||
else throw new Error("Cannot find Workbook stream");
|
||||
if(options.bookVBA && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
if(options.bookVBA && cfb.FullPaths && CFB.find(cfb, '/_VBA_PROJECT_CUR/VBA/dir')) WorkbookP.vbaraw = make_vba_xls(cfb);
|
||||
}
|
||||
|
||||
var props = {};
|
||||
|
@ -17058,7 +17103,7 @@ var HTML_ = (function() {
|
|||
function make_html_row(ws, r, R, o) {
|
||||
var M = (ws['!merges'] ||[]);
|
||||
var oo = [];
|
||||
var nullcell = "<td" + (o.editable ? ' contenteditable="true"' : "" ) + "></td>";
|
||||
var nullcell = "<td>" + (o.editable ? '<span contenteditable="true"></span>' : "" ) + "</td>";
|
||||
for(var C = r.s.c; C <= r.e.c; ++C) {
|
||||
var RS = 0, CS = 0;
|
||||
for(var j = 0; j < M.length; ++j) {
|
||||
|
@ -17076,7 +17121,7 @@ var HTML_ = (function() {
|
|||
var sp = {};
|
||||
if(RS > 1) sp.rowspan = RS;
|
||||
if(CS > 1) sp.colspan = CS;
|
||||
if(o.editable) sp.contenteditable = "true";
|
||||
if(o.editable) w = '<span contenteditable="true">' + w + '</span>'
|
||||
sp.id = "sjs-" + coord;
|
||||
oo.push(writextag('td', w, sp));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue