version bump 0.15.6: niggles from 2012
- CFB prevent infinite loop (h/t @rossj) - pass updated eslint checks (fixes #1726 h/t @BjoernRave) - defined name proper encoding (fixes #1785 h/t @laohe98) - correct theme color order (fixes #389 h/t @foreverpw) - ODS / XLML more aggressive flagging of stub cells - cellStyles implies sheetStubs - updated SSF to 0.10.3
This commit is contained in:
parent
a81bb78f18
commit
0a57229d3b
33
CHANGELOG.md
33
CHANGELOG.md
@ -4,6 +4,39 @@ This log is intended to keep track of backwards-incompatible changes, including
|
||||
but not limited to API changes and file location changes. Minor behavioral
|
||||
changes may not be included if they are not expected to break existing code.
|
||||
|
||||
## v0.15.6
|
||||
|
||||
* CFB prevent infinite loop
|
||||
* ODS empty cells marked as stub (type "z")
|
||||
* `cellStyles` option implies `sheetStubs`
|
||||
|
||||
## v0.15.5
|
||||
|
||||
* `sheets` parse option to specify which sheets to parse
|
||||
|
||||
## v0.15.4
|
||||
|
||||
* AOA utilities properly preserve number formats
|
||||
* Number formats captured in stub cells
|
||||
|
||||
## v0.15.3
|
||||
|
||||
* Properties and Custom Properties properly XML-encoded
|
||||
|
||||
## v0.15.2
|
||||
|
||||
- `sheet_get_cell` utility function
|
||||
- `sheet_to_json` explicitly support `null` as alias for default behavior
|
||||
- `encode_col` throw on negative column index
|
||||
- HTML properly handle whitespace around tags in a run
|
||||
- HTML use `id` option on write
|
||||
- Files starting with `0x09` followed by a display character are now TSV files
|
||||
- XLS parse references col/row indices mod by the correct number for BIFF ver
|
||||
- XLSX comments moved to avoid overlapping cell
|
||||
- XLSB outline level
|
||||
- AutoFilter update `_FilterDatabase` defined name on write
|
||||
- XLML skip CDATA blocks
|
||||
|
||||
## v0.15.1 (2019-08-14)
|
||||
|
||||
* XLSX ignore XML artifacts
|
||||
|
13
bin/xlsx.njs
13
bin/xlsx.njs
@ -137,6 +137,7 @@ if(program.all) {
|
||||
opts.sheetStubs = true;
|
||||
opts.cellDates = true;
|
||||
wopts.cellStyles = true;
|
||||
wopts.sheetStubs = true;
|
||||
wopts.bookVBA = true;
|
||||
}
|
||||
if(program.sparse) opts.dense = false; else opts.dense = true;
|
||||
@ -165,26 +166,26 @@ if(program.dump) {
|
||||
process.exit(0);
|
||||
}
|
||||
if(program.props) {
|
||||
dump_props(wb);
|
||||
if(wb) dump_props(wb);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
/* full workbook formats */
|
||||
workbook_formats.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) {
|
||||
wopts.bookType = m[1];
|
||||
X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
|
||||
if(wb) X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
|
||||
process.exit(0);
|
||||
} });
|
||||
|
||||
wb_formats_2.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) {
|
||||
wopts.bookType = m[1];
|
||||
X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
|
||||
if(wb) X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
|
||||
process.exit(0);
|
||||
} });
|
||||
|
||||
var target_sheet = sheetname || '';
|
||||
if(target_sheet === '') {
|
||||
if(program.sheetIndex < (wb.SheetNames||[]).length) target_sheet = wb.SheetNames[program.sheetIndex];
|
||||
if(+program.sheetIndex < (wb.SheetNames||[]).length) target_sheet = wb.SheetNames[+program.sheetIndex];
|
||||
else target_sheet = (wb.SheetNames||[""])[0];
|
||||
}
|
||||
|
||||
@ -269,13 +270,13 @@ function dump_props(wb/*:Workbook*/) {
|
||||
if(wb.Props) {
|
||||
Keys = Object.keys(wb.Props);
|
||||
for(pi = 0; pi < Keys.length; ++pi) {
|
||||
if(Keys.hasOwnProperty(Keys[pi])) propaoa.push([Keys[pi], Keys[/*::+*/Keys[pi]]]);
|
||||
if(Object.prototype.hasOwnProperty.call(Keys, Keys[pi])) propaoa.push([Keys[pi], Keys[/*::+*/Keys[pi]]]);
|
||||
}
|
||||
}
|
||||
if(wb.Custprops) {
|
||||
Keys = Object.keys(wb.Custprops);
|
||||
for(pi = 0; pi < Keys.length; ++pi) {
|
||||
if(Keys.hasOwnProperty(Keys[pi])) propaoa.push([Keys[pi], Keys[/*::+*/Keys[pi]]]);
|
||||
if(Object.prototype.hasOwnProperty.call(Keys, Keys[pi])) propaoa.push([Keys[pi], Keys[/*::+*/Keys[pi]]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
XLSX.version = '0.15.5';
|
||||
XLSX.version = '0.15.6';
|
||||
|
@ -2,7 +2,7 @@
|
||||
/*jshint -W041 */
|
||||
var SSF/*:SSFModule*/ = ({}/*:any*/);
|
||||
var make_ssf = function make_ssf(SSF/*:SSFModule*/){
|
||||
SSF.version = '0.10.2';
|
||||
SSF.version = '0.10.3';
|
||||
function _strrev(x/*:string*/)/*:string*/ { var o = "", i = x.length-1; while(i>=0) o += x.charAt(i--); return o; }
|
||||
function fill(c/*:string*/,l/*:number*/)/*:string*/ { var o = ""; while(o.length < l) o+=c; return o; }
|
||||
function pad0(v/*:any*/,d/*:number*/)/*:string*/{var t=""+v; return t.length>=d?t:fill('0',d-t.length)+t;}
|
||||
@ -169,7 +169,7 @@ function general_fmt(v/*:any*/, opts/*:any*/) {
|
||||
switch(typeof v) {
|
||||
case 'string': return v;
|
||||
case 'boolean': return v ? "TRUE" : "FALSE";
|
||||
case 'number': return (v|0) === v ? general_fmt_int(v) : general_fmt_num(v);
|
||||
case 'number': return (v|0) === v ? v.toString(10) : general_fmt_num(v);
|
||||
case 'undefined': return "";
|
||||
case 'object':
|
||||
if(v == null) return "";
|
||||
@ -552,7 +552,7 @@ function fmt_is_date(fmt/*:string*/)/*:boolean*/ {
|
||||
while(i < fmt.length) {
|
||||
switch((c = fmt.charAt(i))) {
|
||||
case 'G': if(isgeneral(fmt, i)) i+= 6; i++; break;
|
||||
case '"': for(;(/*cc=*/fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) ++i; ++i; break;
|
||||
case '"': for(;(/*cc=*/fmt.charCodeAt(++i)) !== 34 && i < fmt.length;){/*empty*/} ++i; break;
|
||||
case '\\': i+=2; break;
|
||||
case '_': i+=2; break;
|
||||
case '@': ++i; break;
|
||||
@ -661,6 +661,7 @@ function eval_fmt(fmt/*:string*/, v/*:any*/, opts/*:any*/, flen/*:number*/) {
|
||||
o = c; while(i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) o+=fmt.charAt(i);
|
||||
out[out.length] = {t:'D', v:o}; break;
|
||||
case ' ': out[out.length] = {t:c, v:c}; ++i; break;
|
||||
case "$": out[out.length] = {t:'t', v:'$'}; ++i; break;
|
||||
default:
|
||||
if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);
|
||||
out[out.length] = {t:'t', v:c}; ++i; break;
|
||||
|
@ -21,7 +21,7 @@ declare var new_unsafe_buf:any;
|
||||
/* vim: set ts=2: */
|
||||
/*jshint eqnull:true */
|
||||
/*exported CFB */
|
||||
/*global module, require:false, process:false, Buffer:false, Uint8Array:false, Uint16Array:false */
|
||||
/*global Uint8Array:false, Uint16Array:false */
|
||||
|
||||
/*::
|
||||
declare var DO_NOT_EXPORT_CFB:?boolean;
|
||||
@ -142,7 +142,7 @@ CRC32.str = crc32_str;
|
||||
/* [MS-CFB] v20171201 */
|
||||
var CFB = (function _CFB(){
|
||||
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
|
||||
exports.version = '1.1.3';
|
||||
exports.version = '1.1.4';
|
||||
/* [MS-CFB] 2.6.4 */
|
||||
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
|
||||
var L = l.split("/"), R = r.split("/");
|
||||
@ -473,7 +473,9 @@ function make_sector_list(sectors/*:Array<RawBytes>*/, dir_start/*:number*/, fat
|
||||
k = (i + dir_start); if(k >= sl) k-=sl;
|
||||
if(chkd[k]) continue;
|
||||
buf_chain = [];
|
||||
var seen = [];
|
||||
for(j=k; j>=0;) {
|
||||
seen[j] = true;
|
||||
chkd[j] = true;
|
||||
buf[buf.length] = j;
|
||||
buf_chain.push(sectors[j]);
|
||||
@ -482,6 +484,7 @@ function make_sector_list(sectors/*:Array<RawBytes>*/, dir_start/*:number*/, fat
|
||||
if(ssz < 4 + jj) throw new Error("FAT boundary crossed: " + j + " 4 "+ssz);
|
||||
if(!sectors[addr]) break;
|
||||
j = __readInt32LE(sectors[addr], jj);
|
||||
if(seen[j]) break;
|
||||
}
|
||||
sector_list[k] = ({nodes: buf, data:__toBuffer([buf_chain])}/*:SectorEntry*/);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ function blobify(data) {
|
||||
}
|
||||
/* write or download file */
|
||||
function write_dl(fname/*:string*/, payload/*:any*/, enc/*:?string*/) {
|
||||
/*global IE_SaveFile, Blob, navigator, saveAs, URL, document, File, chrome */
|
||||
/*global IE_SaveFile, Blob, navigator, saveAs, document, File, chrome */
|
||||
if(typeof _fs !== 'undefined' && _fs.writeFileSync) return enc ? _fs.writeFileSync(fname, payload, enc) : _fs.writeFileSync(fname, payload);
|
||||
var data = (enc == "utf8") ? utf8write(payload) : payload;
|
||||
/*:: declare var IE_SaveFile: any; */
|
||||
|
@ -1,6 +1,6 @@
|
||||
function keys(o/*:any*/)/*:Array<any>*/ {
|
||||
var ks = Object.keys(o), o2 = [];
|
||||
for(var i = 0; i < ks.length; ++i) if(o.hasOwnProperty(ks[i])) o2.push(ks[i]);
|
||||
for(var i = 0; i < ks.length; ++i) if(Object.prototype.hasOwnProperty.call(o, ks[i])) o2.push(ks[i]);
|
||||
return o2;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ function dup(o/*:any*/)/*:any*/ {
|
||||
if(typeof o != 'object' || o == null) return o;
|
||||
if(o instanceof Date) return new Date(o.getTime());
|
||||
var out = {};
|
||||
for(var k in o) if(o.hasOwnProperty(k)) out[k] = dup(o[k]);
|
||||
for(var k in o) if(Object.prototype.hasOwnProperty.call(o, k)) out[k] = dup(o[k]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ var rencoding = evert(encodings);
|
||||
// TODO: CP remap (need to read file version to determine OS)
|
||||
var unescapexml/*:StringConv*/ = (function() {
|
||||
/* 22.4.2.4 bstr (Basic String) */
|
||||
var encregex = /&(?:quot|apos|gt|lt|amp|#x?([\da-fA-F]+));/g, coderegex = /_x([\da-fA-F]{4})_/g;
|
||||
var encregex = /&(?:quot|apos|gt|lt|amp|#x?([\da-fA-F]+));/ig, coderegex = /_x([\da-fA-F]{4})_/ig;
|
||||
return function unescapexml(text/*:string*/)/*:string*/ {
|
||||
var s = text + '', i = s.indexOf("<![CDATA[");
|
||||
if(i == -1) return s.replace(encregex, function($$, $1) { return encodings[$$]||String.fromCharCode(parseInt($1,$$.indexOf("x")>-1?16:10))||$$; }).replace(coderegex,function(m,c) {return String.fromCharCode(parseInt(c,16));});
|
||||
@ -175,7 +175,7 @@ var htmldecode/*:{(s:string):string}*/ = (function() {
|
||||
var entities/*:Array<[RegExp, string]>*/ = [
|
||||
['nbsp', ' '], ['middot', '·'],
|
||||
['quot', '"'], ['apos', "'"], ['gt', '>'], ['lt', '<'], ['amp', '&']
|
||||
].map(function(x/*:[string, string]*/) { return [new RegExp('&' + x[0] + ';', "g"), x[1]]; });
|
||||
].map(function(x/*:[string, string]*/) { return [new RegExp('&' + x[0] + ';', "ig"), x[1]]; });
|
||||
return function htmldecode(str/*:string*/)/*:string*/ {
|
||||
var o = str
|
||||
// Remove new lines and spaces from start of content
|
||||
|
@ -38,7 +38,7 @@ function encode_range_xls(r, opts)/*:string*/ {
|
||||
}
|
||||
}
|
||||
if(r.s.c == 0 && !r.s.cRel) {
|
||||
if(r.e.c == (opts.biff >= 12 ? 0xFFFF : 0xFF) && !r.e.cRel) {
|
||||
if(r.e.c == (opts.biff >= 12 ? 0x3FFF : 0xFF) && !r.e.cRel) {
|
||||
return (r.s.rRel ? "" : "$") + encode_row(r.s.r) + ":" + (r.e.rRel ? "" : "$") + encode_row(r.e.r);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,12 @@ function write_XLWideString(data/*:string*/, o) {
|
||||
return _null ? o.slice(0, o.l) : o;
|
||||
}
|
||||
|
||||
/* [MS-XLSB] 2.5.91 */
|
||||
//function parse_LPWideString(data/*::, length*/)/*:string*/ {
|
||||
// var cchCharacters = data.read_shift(2);
|
||||
// return cchCharacters === 0 ? "" : data.read_shift(cchCharacters, "utf16le");
|
||||
//}
|
||||
|
||||
/* [MS-XLSB] 2.5.143 */
|
||||
function parse_StrRun(data) {
|
||||
return { ich: data.read_shift(2), ifnt: data.read_shift(2) };
|
||||
@ -149,6 +155,25 @@ function write_RfX(r/*:Range*/, o) {
|
||||
var parse_UncheckedRfX = parse_RfX;
|
||||
var write_UncheckedRfX = write_RfX;
|
||||
|
||||
/* [MS-XLSB] 2.5.155 UncheckedSqRfX */
|
||||
//function parse_UncheckedSqRfX(data) {
|
||||
// var cnt = data.read_shift(4);
|
||||
// var out = [];
|
||||
// for(var i = 0; i < cnt; ++i) {
|
||||
// var rng = parse_UncheckedRfX(data);
|
||||
// out.push(encode_range(rng));
|
||||
// }
|
||||
// return out.join(",");
|
||||
//}
|
||||
//function write_UncheckedSqRfX(sqrfx/*:string*/) {
|
||||
// var parts = sqrfx.split(/\s*,\s*/);
|
||||
// var o = new_buf(4); o.write_shift(4, parts.length);
|
||||
// var out = [o];
|
||||
// parts.forEach(function(rng) {
|
||||
// out.push(write_UncheckedRfX(safe_decode_range(rng)));
|
||||
// });
|
||||
// return bconcat(out);
|
||||
//}
|
||||
|
||||
/* [MS-XLS] 2.5.342 ; [MS-XLSB] 2.5.171 */
|
||||
/* TODO: error checking, NaN and Infinity values are not valid Xnum */
|
||||
|
@ -101,7 +101,7 @@ var SpecialProperties = {
|
||||
};
|
||||
|
||||
(function() {
|
||||
for(var y in SpecialProperties) if(SpecialProperties.hasOwnProperty(y))
|
||||
for(var y in SpecialProperties) if(Object.prototype.hasOwnProperty.call(SpecialProperties, y))
|
||||
DocSummaryPIDDSI[y] = SummaryPIDSI[y] = SpecialProperties[y];
|
||||
})();
|
||||
|
||||
|
@ -63,7 +63,7 @@ function xlml_write_custprops(Props, Custprops/*::, opts*/) {
|
||||
var o/*:Array<string>*/ = [];
|
||||
if(Props) keys(Props).forEach(function(k) {
|
||||
/*:: if(!Props) return; */
|
||||
if(!Props.hasOwnProperty(k)) return;
|
||||
if(!Object.prototype.hasOwnProperty.call(Props, k)) return;
|
||||
for(var i = 0; i < CORE_PROPS.length; ++i) if(k == CORE_PROPS[i][1]) return;
|
||||
for(i = 0; i < EXT_PROPS.length; ++i) if(k == EXT_PROPS[i][1]) return;
|
||||
for(i = 0; i < BLACKLIST.length; ++i) if(k == BLACKLIST[i]) return;
|
||||
@ -77,8 +77,8 @@ function xlml_write_custprops(Props, Custprops/*::, opts*/) {
|
||||
});
|
||||
if(Custprops) keys(Custprops).forEach(function(k) {
|
||||
/*:: if(!Custprops) return; */
|
||||
if(!Custprops.hasOwnProperty(k)) return;
|
||||
if(Props && Props.hasOwnProperty(k)) return;
|
||||
if(!Object.prototype.hasOwnProperty.call(Custprops, k)) return;
|
||||
if(Props && Object.prototype.hasOwnProperty.call(Props, k)) return;
|
||||
var m = Custprops[k];
|
||||
var t = "string";
|
||||
if(typeof m == 'number') { t = "float"; m = String(m); }
|
||||
|
@ -349,7 +349,7 @@ function write_Window1(/*::opts*/) {
|
||||
}
|
||||
/* [MS-XLS] 2.4.346 TODO */
|
||||
function parse_Window2(blob, length, opts) {
|
||||
if(opts && opts.biff >= 2 && opts.biff < 8) return {};
|
||||
if(opts && opts.biff >= 2 && opts.biff < 5) return {};
|
||||
var f = blob.read_shift(2);
|
||||
return { RTL: f & 0x40 };
|
||||
}
|
||||
|
@ -790,13 +790,13 @@ var PRN = (function() {
|
||||
}
|
||||
|
||||
cc = [];
|
||||
for(end in cnt) if ( cnt.hasOwnProperty(end) ) {
|
||||
for(end in cnt) if ( Object.prototype.hasOwnProperty.call(cnt, end) ) {
|
||||
cc.push([ cnt[end], end ]);
|
||||
}
|
||||
|
||||
if ( !cc.length ) {
|
||||
cnt = guess_sep_weights;
|
||||
for(end in cnt) if ( cnt.hasOwnProperty(end) ) {
|
||||
for(end in cnt) if ( Object.prototype.hasOwnProperty.call(cnt, end) ) {
|
||||
cc.push([ cnt[end], end ]);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ function parse_fonts(t, styles, themes, opts) {
|
||||
break;
|
||||
|
||||
/* 18.8.29 name CT_FontName */
|
||||
case '<name': if(y.val) font.name = y.val; break;
|
||||
case '<name': if(y.val) font.name = utf8read(y.val); break;
|
||||
case '<name/>': case '</name>': break;
|
||||
|
||||
/* 18.8.2 b CT_BooleanProperty */
|
||||
@ -396,11 +396,11 @@ return function parse_sty_xml(data, themes, opts) {
|
||||
if((t=data.match(bordersRegex))) parse_borders(t, styles, themes, opts);
|
||||
|
||||
/* 18.8.9 cellStyleXfs CT_CellStyleXfs ? */
|
||||
/* 18.8.8 cellStyles CT_CellStyles ? */
|
||||
|
||||
/* 18.8.10 cellXfs CT_CellXfs ? */
|
||||
if((t=data.match(cellXfRegex))) parse_cellXfs(t, styles, opts);
|
||||
|
||||
/* 18.8.8 cellStyles CT_CellStyles ? */
|
||||
/* 18.8.15 dxfs CT_Dxfs ? */
|
||||
/* 18.8.42 tableStyles CT_TableStyles ? */
|
||||
/* 18.8.11 colors CT_Colors ? */
|
||||
|
@ -1,5 +1,12 @@
|
||||
RELS.THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
||||
|
||||
/* Even though theme layout is dk1 lt1 dk2 lt2, true order is lt1 dk1 lt2 dk2 */
|
||||
var XLSXThemeClrScheme = [
|
||||
'</a:lt1>', '</a:dk1>', '</a:lt2>', '</a:dk2>',
|
||||
'</a:accent1>', '</a:accent2>', '</a:accent3>',
|
||||
'</a:accent4>', '</a:accent5>', '</a:accent6>',
|
||||
'</a:hlink>', '</a:folHlink>'
|
||||
];
|
||||
/* 20.1.6.2 clrScheme CT_ColorScheme */
|
||||
function parse_clrScheme(t, themes, opts) {
|
||||
themes.themeElements.clrScheme = [];
|
||||
@ -43,7 +50,7 @@ function parse_clrScheme(t, themes, opts) {
|
||||
case '<a:hlink>': case '</a:hlink>':
|
||||
case '<a:folHlink>': case '</a:folHlink>':
|
||||
if (y[0].charAt(1) === '/') {
|
||||
themes.themeElements.clrScheme.push(color);
|
||||
themes.themeElements.clrScheme[XLSXThemeClrScheme.indexOf(y[0])] = color;
|
||||
color = {};
|
||||
} else {
|
||||
color.name = y[0].slice(3, y[0].length - 1);
|
||||
|
@ -23,7 +23,7 @@ var rc_to_a1 = (function(){
|
||||
};
|
||||
})();
|
||||
|
||||
var crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)([1-9]\d{0,5}|10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6])(?![_.\(A-Za-z0-9])/g;
|
||||
var crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)(10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})(?![_.\(A-Za-z0-9])/g;
|
||||
var a1_to_rc =(function(){
|
||||
return function a1_to_rc(fstr/*:string*/, base/*:CellAddress*/) {
|
||||
return fstr.replace(crefregex, function($0, $1, $2, $3, $4, $5) {
|
||||
|
@ -12,7 +12,7 @@ var browser_has_Map = typeof Map !== 'undefined';
|
||||
function get_sst_id(sst/*:SST*/, str/*:string*/, rev)/*:number*/ {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
if(browser_has_Map ? rev.has(str) : Object.prototype.hasOwnProperty.call(rev, str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
@ -27,7 +27,7 @@ function get_sst_id(sst/*:SST*/, str/*:string*/, rev)/*:number*/ {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
if(!Object.prototype.hasOwnProperty.call(rev, str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ {
|
||||
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
|
||||
if(n.Hidden) d.hidden = "1";
|
||||
if(!n.Ref) return;
|
||||
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "<").replace(/>/g, ">"), d);
|
||||
o[o.length] = writextag('definedName', escapexml(n.Ref), d);
|
||||
});
|
||||
o[o.length] = "</definedNames>";
|
||||
}
|
||||
|
@ -122,7 +122,10 @@ function parse_xlml_data(xml, ss, data, cell/*:any*/, base, styles, csty, row, a
|
||||
if(!cell.t) cell.t = 'n';
|
||||
break;
|
||||
case 'Error': cell.t = 'e'; cell.v = RBErr[xml]; if(o.cellText !== false) cell.w = xml; break;
|
||||
default: cell.t = 's'; cell.v = xlml_fixstr(ss||xml); break;
|
||||
default:
|
||||
if(xml == "" && ss == "") { cell.t = 'z'; }
|
||||
else { cell.t = 's'; cell.v = xlml_fixstr(ss||xml); }
|
||||
break;
|
||||
}
|
||||
safe_format_xlml(cell, nf, o);
|
||||
if(o.cellFormula !== false) {
|
||||
@ -913,7 +916,9 @@ function write_sty_xlml(wb, opts)/*:string*/ {
|
||||
opts.cellXfs.forEach(function(xf, id) {
|
||||
var payload/*:Array<string>*/ = [];
|
||||
payload.push(writextag('NumberFormat', null, {"ss:Format": escapexml(SSF._table[xf.numFmtId])}));
|
||||
styles.push(writextag('Style', payload.join(""), {"ss:ID": "s" + (21+id)}));
|
||||
|
||||
var o = /*::(*/{"ss:ID": "s" + (21+id)}/*:: :any)*/;
|
||||
styles.push(writextag('Style', payload.join(""), o));
|
||||
});
|
||||
return writextag("Styles", styles.join(""));
|
||||
}
|
||||
|
@ -887,12 +887,12 @@ function write_xls_props(wb/*:Workbook*/, cfb/*:CFBContainer*/) {
|
||||
if(wb.Props) {
|
||||
Keys = keys(wb.Props);
|
||||
// $FlowIgnore
|
||||
for(i = 0; i < Keys.length; ++i) (DocSummaryRE.hasOwnProperty(Keys[i]) ? DSEntries : SummaryRE.hasOwnProperty(Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);
|
||||
for(i = 0; i < Keys.length; ++i) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);
|
||||
}
|
||||
if(wb.Custprops) {
|
||||
Keys = keys(wb.Custprops);
|
||||
// $FlowIgnore
|
||||
for(i = 0; i < Keys.length; ++i) if(!(wb.Props||{}).hasOwnProperty(Keys[i])) (DocSummaryRE.hasOwnProperty(Keys[i]) ? DSEntries : SummaryRE.hasOwnProperty(Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);
|
||||
for(i = 0; i < Keys.length; ++i) if(!Object.prototype.hasOwnProperty.call((wb.Props||{}), Keys[i])) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);
|
||||
}
|
||||
var CEntries2 = [];
|
||||
for(i = 0; i < CEntries.length; ++i) {
|
||||
|
@ -8,6 +8,29 @@ function write_biff_rec(ba/*:BufArray*/, type/*:number|string*/, payload, length
|
||||
if(/*:: len != null &&*/len > 0 && is_buf(payload)) ba.push(payload);
|
||||
}
|
||||
|
||||
//function write_biff_continue(ba/*:BufArray*/, type/*:number|string*/, payload, length/*:?number*/)/*:void*/ {
|
||||
// var len = length || (payload||[]).length || 0;
|
||||
// if(len <= 8224) return write_biff_rec(ba, type, payload, len);
|
||||
// var t/*:number*/ = +type || +XLSRE[/*::String(*/type/*::)*/];
|
||||
// if(isNaN(t)) return;
|
||||
// var parts = payload.parts || [], sidx = 0;
|
||||
// var i = 0, w = 0;
|
||||
// while(w + (parts[sidx] || 8224) <= 8224) { w+= (parts[sidx] || 8224); sidx++; }
|
||||
// var o = ba.next(4);
|
||||
// o.write_shift(2, t);
|
||||
// o.write_shift(2, w);
|
||||
// ba.push(payload.slice(i, i + w));
|
||||
// i += w;
|
||||
// while(i < len) {
|
||||
// o = ba.next(4);
|
||||
// o.write_shift(2, 0x3c); // TODO: figure out correct continue type
|
||||
// w = 0;
|
||||
// while(w + (parts[sidx] || 8224) <= 8224) { w+= (parts[sidx] || 8224); sidx++; }
|
||||
// o.write_shift(2, w);
|
||||
// ba.push(payload.slice(i, i+w)); i+= w;
|
||||
// }
|
||||
//}
|
||||
|
||||
function write_BIFF2Cell(out, r/*:number*/, c/*:number*/) {
|
||||
if(!out) out = new_buf(7);
|
||||
out.write_shift(2, r);
|
||||
|
@ -186,6 +186,7 @@ var parse_content_xml = (function() {
|
||||
if(atag.Target) q.l = atag;
|
||||
if(comments.length > 0) { q.c = comments; comments = []; }
|
||||
if(textp && opts.cellText !== false) q.w = textp;
|
||||
if(isstub) { q.t = "z"; delete q.v; }
|
||||
if(!isstub || opts.sheetStubs) {
|
||||
if(!(opts.sheetRows && opts.sheetRows <= R)) {
|
||||
for(var rpt = 0; rpt < rowpeat; ++rpt) {
|
||||
|
@ -112,6 +112,11 @@ var write_content_ods/*:{(wb:any, opts:any):string}*/ = (function() {
|
||||
o.push(' <number:text>/</number:text>\n');
|
||||
o.push(' <number:year/>\n');
|
||||
o.push(' </number:date-style>\n');
|
||||
|
||||
o.push(' <style:style style:name="ta1" style:family="table">\n'); // style:master-page-name="mp1">\n');
|
||||
o.push(' <style:table-properties table:display="true" style:writing-mode="lr-tb"/>\n');
|
||||
o.push(' </style:style>\n');
|
||||
|
||||
o.push(' <style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>\n');
|
||||
o.push(' </office:automatic-styles>\n');
|
||||
};
|
||||
|
@ -69,7 +69,7 @@ function readSync(data/*:RawData*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
if(typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) return readSync(new Uint8Array(data), opts);
|
||||
var d = data, n = [0,0,0,0], str = false;
|
||||
var o = opts||{};
|
||||
if(o.cellStyles) { o.cellNF = true; }
|
||||
if(o.cellStyles) { o.cellNF = true; o.sheetStubs = true; }
|
||||
_ssfopts = {};
|
||||
if(o.dateNF) _ssfopts.dateNF = o.dateNF;
|
||||
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
|
||||
|
@ -9,7 +9,6 @@ function write_cfb_ctr(cfb/*:CFBContainer*/, o/*:WriteOpts*/)/*:any*/ {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
/*:: declare var encrypt_agile:any; */
|
||||
function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
var o = opts||{};
|
||||
@ -26,7 +25,9 @@ function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: /*::(*/{"nodebuffer": "buffer", "string": "binary"}/*:: :any)*/[oopts.type] || oopts.type}) : z.generate(oopts);
|
||||
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
|
||||
/*jshint -W083 */
|
||||
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef
|
||||
/*jshint +W083 */
|
||||
if(o.type === "file") return write_dl(o.file, out);
|
||||
return o.type == "string" ? utf8read(/*::(*/out/*:: :any)*/) : out;
|
||||
}
|
||||
@ -87,7 +88,7 @@ function writeSync(wb/*:Workbook*/, opts/*:?WriteOpts*/) {
|
||||
reset_cp();
|
||||
check_wb(wb);
|
||||
var o = opts||{};
|
||||
if(o.cellStyles) { o.cellNF = true; }
|
||||
if(o.cellStyles) { o.cellNF = true; o.sheetStubs = true; }
|
||||
if(o.type == "array") { o.type = "binary"; var out/*:string*/ = (writeSync(wb, o)/*:any*/); o.type = "array"; return s2ab(out); }
|
||||
switch(o.bookType || 'xlsb') {
|
||||
case 'xml':
|
||||
|
@ -6,7 +6,7 @@ type MJRObject = {
|
||||
*/
|
||||
function make_json_row(sheet/*:Worksheet*/, r/*:Range*/, R/*:number*/, cols/*:Array<string>*/, header/*:number*/, hdr/*:Array<any>*/, dense/*:boolean*/, o/*:Sheet2JSONOpts*/)/*:MJRObject*/ {
|
||||
var rr = encode_row(R);
|
||||
var defval = o.defval, raw = o.raw || !o.hasOwnProperty("raw");
|
||||
var defval = o.defval, raw = o.raw || !Object.prototype.hasOwnProperty.call(o, "raw");
|
||||
var isempty = true;
|
||||
var row/*:any*/ = (header === 1) ? [] : {};
|
||||
if(header !== 1) {
|
||||
|
28
dist/xlsx.core.min.js
generated
vendored
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
2
dist/xlsx.core.min.map
generated
vendored
File diff suppressed because one or more lines are too long
141
dist/xlsx.extendscript.js
generated
vendored
141
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.15.5';
|
||||
XLSX.version = '0.15.6';
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
/*global cptable:true, window */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
@ -9348,7 +9348,7 @@ var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;
|
||||
/*jshint -W041 */
|
||||
var SSF = ({});
|
||||
var make_ssf = function make_ssf(SSF){
|
||||
SSF.version = '0.10.2';
|
||||
SSF.version = '0.10.3';
|
||||
function _strrev(x) { var o = "", i = x.length-1; while(i>=0) o += x.charAt(i--); return o; }
|
||||
function fill(c,l) { var o = ""; while(o.length < l) o+=c; return o; }
|
||||
function pad0(v,d){var t=""+v; return t.length>=d?t:fill('0',d-t.length)+t;}
|
||||
@ -9512,7 +9512,7 @@ function general_fmt(v, opts) {
|
||||
switch(typeof v) {
|
||||
case 'string': return v;
|
||||
case 'boolean': return v ? "TRUE" : "FALSE";
|
||||
case 'number': return (v|0) === v ? general_fmt_int(v) : general_fmt_num(v);
|
||||
case 'number': return (v|0) === v ? v.toString(10) : general_fmt_num(v);
|
||||
case 'undefined': return "";
|
||||
case 'object':
|
||||
if(v == null) return "";
|
||||
@ -9892,7 +9892,7 @@ function fmt_is_date(fmt) {
|
||||
while(i < fmt.length) {
|
||||
switch((c = fmt.charAt(i))) {
|
||||
case 'G': if(isgeneral(fmt, i)) i+= 6; i++; break;
|
||||
case '"': for(;(/*cc=*/fmt.charCodeAt(++i)) !== 34 && i < fmt.length;) ++i; ++i; break;
|
||||
case '"': for(;(/*cc=*/fmt.charCodeAt(++i)) !== 34 && i < fmt.length;){/*empty*/} ++i; break;
|
||||
case '\\': i+=2; break;
|
||||
case '_': i+=2; break;
|
||||
case '@': ++i; break;
|
||||
@ -10001,6 +10001,7 @@ function eval_fmt(fmt, v, opts, flen) {
|
||||
o = c; while(i < fmt.length && "0123456789".indexOf(fmt.charAt(++i)) > -1) o+=fmt.charAt(i);
|
||||
out[out.length] = {t:'D', v:o}; break;
|
||||
case ' ': out[out.length] = {t:c, v:c}; ++i; break;
|
||||
case "$": out[out.length] = {t:'t', v:'$'}; ++i; break;
|
||||
default:
|
||||
if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(c) === -1) throw new Error('unrecognized character ' + c + ' in ' + fmt);
|
||||
out[out.length] = {t:'t', v:c}; ++i; break;
|
||||
@ -10299,7 +10300,7 @@ var DO_NOT_EXPORT_CFB = true;
|
||||
/* vim: set ts=2: */
|
||||
/*jshint eqnull:true */
|
||||
/*exported CFB */
|
||||
/*global module, require:false, process:false, Buffer:false, Uint8Array:false, Uint16Array:false */
|
||||
/*global Uint8Array:false, Uint16Array:false */
|
||||
|
||||
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
|
||||
/* vim: set ts=2: */
|
||||
@ -10405,7 +10406,7 @@ CRC32.str = crc32_str;
|
||||
/* [MS-CFB] v20171201 */
|
||||
var CFB = (function _CFB(){
|
||||
var exports = {};
|
||||
exports.version = '1.1.3';
|
||||
exports.version = '1.1.4';
|
||||
/* [MS-CFB] 2.6.4 */
|
||||
function namecmp(l, r) {
|
||||
var L = l.split("/"), R = r.split("/");
|
||||
@ -10736,7 +10737,9 @@ function make_sector_list(sectors, dir_start, fat_addrs, ssz) {
|
||||
k = (i + dir_start); if(k >= sl) k-=sl;
|
||||
if(chkd[k]) continue;
|
||||
buf_chain = [];
|
||||
var seen = [];
|
||||
for(j=k; j>=0;) {
|
||||
seen[j] = true;
|
||||
chkd[j] = true;
|
||||
buf[buf.length] = j;
|
||||
buf_chain.push(sectors[j]);
|
||||
@ -10745,6 +10748,7 @@ function make_sector_list(sectors, dir_start, fat_addrs, ssz) {
|
||||
if(ssz < 4 + jj) throw new Error("FAT boundary crossed: " + j + " 4 "+ssz);
|
||||
if(!sectors[addr]) break;
|
||||
j = __readInt32LE(sectors[addr], jj);
|
||||
if(seen[j]) break;
|
||||
}
|
||||
sector_list[k] = ({nodes: buf, data:__toBuffer([buf_chain])});
|
||||
}
|
||||
@ -11745,7 +11749,7 @@ function blobify(data) {
|
||||
}
|
||||
/* write or download file */
|
||||
function write_dl(fname, payload, enc) {
|
||||
/*global IE_SaveFile, Blob, navigator, saveAs, URL, document, File, chrome */
|
||||
/*global IE_SaveFile, Blob, navigator, saveAs, document, File, chrome */
|
||||
if(typeof _fs !== 'undefined' && _fs.writeFileSync) return enc ? _fs.writeFileSync(fname, payload, enc) : _fs.writeFileSync(fname, payload);
|
||||
var data = (enc == "utf8") ? utf8write(payload) : payload;
|
||||
if(typeof IE_SaveFile !== 'undefined') return IE_SaveFile(data, fname);
|
||||
@ -11792,7 +11796,7 @@ function read_binary(path) {
|
||||
}
|
||||
function keys(o) {
|
||||
var ks = Object.keys(o), o2 = [];
|
||||
for(var i = 0; i < ks.length; ++i) if(o.hasOwnProperty(ks[i])) o2.push(ks[i]);
|
||||
for(var i = 0; i < ks.length; ++i) if(Object.prototype.hasOwnProperty.call(o, ks[i])) o2.push(ks[i]);
|
||||
return o2;
|
||||
}
|
||||
|
||||
@ -11897,7 +11901,7 @@ function dup(o) {
|
||||
if(typeof o != 'object' || o == null) return o;
|
||||
if(o instanceof Date) return new Date(o.getTime());
|
||||
var out = {};
|
||||
for(var k in o) if(o.hasOwnProperty(k)) out[k] = dup(o[k]);
|
||||
for(var k in o) if(Object.prototype.hasOwnProperty.call(o, k)) out[k] = dup(o[k]);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -12091,7 +12095,7 @@ var rencoding = evert(encodings);
|
||||
// TODO: CP remap (need to read file version to determine OS)
|
||||
var unescapexml = (function() {
|
||||
/* 22.4.2.4 bstr (Basic String) */
|
||||
var encregex = /&(?:quot|apos|gt|lt|amp|#x?([\da-fA-F]+));/g, coderegex = /_x([\da-fA-F]{4})_/g;
|
||||
var encregex = /&(?:quot|apos|gt|lt|amp|#x?([\da-fA-F]+));/ig, coderegex = /_x([\da-fA-F]{4})_/ig;
|
||||
return function unescapexml(text) {
|
||||
var s = text + '', i = s.indexOf("<![CDATA[");
|
||||
if(i == -1) return s.replace(encregex, function($$, $1) { return encodings[$$]||String.fromCharCode(parseInt($1,$$.indexOf("x")>-1?16:10))||$$; }).replace(coderegex,function(m,c) {return String.fromCharCode(parseInt(c,16));});
|
||||
@ -12218,7 +12222,7 @@ var htmldecode = (function() {
|
||||
var entities = [
|
||||
['nbsp', ' '], ['middot', '·'],
|
||||
['quot', '"'], ['apos', "'"], ['gt', '>'], ['lt', '<'], ['amp', '&']
|
||||
].map(function(x) { return [new RegExp('&' + x[0] + ';', "g"), x[1]]; });
|
||||
].map(function(x) { return [new RegExp('&' + x[0] + ';', "ig"), x[1]]; });
|
||||
return function htmldecode(str) {
|
||||
var o = str
|
||||
// Remove new lines and spaces from start of content
|
||||
@ -12653,7 +12657,7 @@ function encode_range_xls(r, opts) {
|
||||
}
|
||||
}
|
||||
if(r.s.c == 0 && !r.s.cRel) {
|
||||
if(r.e.c == (opts.biff >= 12 ? 0xFFFF : 0xFF) && !r.e.cRel) {
|
||||
if(r.e.c == (opts.biff >= 12 ? 0x3FFF : 0xFF) && !r.e.cRel) {
|
||||
return (r.s.rRel ? "" : "$") + encode_row(r.s.r) + ":" + (r.e.rRel ? "" : "$") + encode_row(r.e.r);
|
||||
}
|
||||
}
|
||||
@ -12851,6 +12855,12 @@ function write_XLWideString(data, o) {
|
||||
return _null ? o.slice(0, o.l) : o;
|
||||
}
|
||||
|
||||
/* [MS-XLSB] 2.5.91 */
|
||||
//function parse_LPWideString(data) {
|
||||
// var cchCharacters = data.read_shift(2);
|
||||
// return cchCharacters === 0 ? "" : data.read_shift(cchCharacters, "utf16le");
|
||||
//}
|
||||
|
||||
/* [MS-XLSB] 2.5.143 */
|
||||
function parse_StrRun(data) {
|
||||
return { ich: data.read_shift(2), ifnt: data.read_shift(2) };
|
||||
@ -12984,6 +12994,25 @@ function write_RfX(r, o) {
|
||||
var parse_UncheckedRfX = parse_RfX;
|
||||
var write_UncheckedRfX = write_RfX;
|
||||
|
||||
/* [MS-XLSB] 2.5.155 UncheckedSqRfX */
|
||||
//function parse_UncheckedSqRfX(data) {
|
||||
// var cnt = data.read_shift(4);
|
||||
// var out = [];
|
||||
// for(var i = 0; i < cnt; ++i) {
|
||||
// var rng = parse_UncheckedRfX(data);
|
||||
// out.push(encode_range(rng));
|
||||
// }
|
||||
// return out.join(",");
|
||||
//}
|
||||
//function write_UncheckedSqRfX(sqrfx) {
|
||||
// var parts = sqrfx.split(/\s*,\s*/);
|
||||
// var o = new_buf(4); o.write_shift(4, parts.length);
|
||||
// var out = [o];
|
||||
// parts.forEach(function(rng) {
|
||||
// out.push(write_UncheckedRfX(safe_decode_range(rng)));
|
||||
// });
|
||||
// return bconcat(out);
|
||||
//}
|
||||
|
||||
/* [MS-XLS] 2.5.342 ; [MS-XLSB] 2.5.171 */
|
||||
/* TODO: error checking, NaN and Infinity values are not valid Xnum */
|
||||
@ -13218,7 +13247,7 @@ var SpecialProperties = {
|
||||
};
|
||||
|
||||
(function() {
|
||||
for(var y in SpecialProperties) if(SpecialProperties.hasOwnProperty(y))
|
||||
for(var y in SpecialProperties) if(Object.prototype.hasOwnProperty.call(SpecialProperties, y))
|
||||
DocSummaryPIDDSI[y] = SummaryPIDSI[y] = SpecialProperties[y];
|
||||
})();
|
||||
|
||||
@ -14173,7 +14202,7 @@ function xlml_write_custprops(Props, Custprops) {
|
||||
var T = 'CustomDocumentProperties';
|
||||
var o = [];
|
||||
if(Props) keys(Props).forEach(function(k) {
|
||||
if(!Props.hasOwnProperty(k)) return;
|
||||
if(!Object.prototype.hasOwnProperty.call(Props, k)) return;
|
||||
for(var i = 0; i < CORE_PROPS.length; ++i) if(k == CORE_PROPS[i][1]) return;
|
||||
for(i = 0; i < EXT_PROPS.length; ++i) if(k == EXT_PROPS[i][1]) return;
|
||||
for(i = 0; i < BLACKLIST.length; ++i) if(k == BLACKLIST[i]) return;
|
||||
@ -14186,8 +14215,8 @@ if(!Props.hasOwnProperty(k)) return;
|
||||
o.push(writextag(escapexmltag(k), m, {"dt:dt":t}));
|
||||
});
|
||||
if(Custprops) keys(Custprops).forEach(function(k) {
|
||||
if(!Custprops.hasOwnProperty(k)) return;
|
||||
if(Props && Props.hasOwnProperty(k)) return;
|
||||
if(!Object.prototype.hasOwnProperty.call(Custprops, k)) return;
|
||||
if(Props && Object.prototype.hasOwnProperty.call(Props, k)) return;
|
||||
var m = Custprops[k];
|
||||
var t = "string";
|
||||
if(typeof m == 'number') { t = "float"; m = String(m); }
|
||||
@ -15152,7 +15181,7 @@ function write_Window1() {
|
||||
}
|
||||
/* [MS-XLS] 2.4.346 TODO */
|
||||
function parse_Window2(blob, length, opts) {
|
||||
if(opts && opts.biff >= 2 && opts.biff < 8) return {};
|
||||
if(opts && opts.biff >= 2 && opts.biff < 5) return {};
|
||||
var f = blob.read_shift(2);
|
||||
return { RTL: f & 0x40 };
|
||||
}
|
||||
@ -16654,13 +16683,13 @@ var PRN = (function() {
|
||||
}
|
||||
|
||||
cc = [];
|
||||
for(end in cnt) if ( cnt.hasOwnProperty(end) ) {
|
||||
for(end in cnt) if ( Object.prototype.hasOwnProperty.call(cnt, end) ) {
|
||||
cc.push([ cnt[end], end ]);
|
||||
}
|
||||
|
||||
if ( !cc.length ) {
|
||||
cnt = guess_sep_weights;
|
||||
for(end in cnt) if ( cnt.hasOwnProperty(end) ) {
|
||||
for(end in cnt) if ( Object.prototype.hasOwnProperty.call(cnt, end) ) {
|
||||
cc.push([ cnt[end], end ]);
|
||||
}
|
||||
}
|
||||
@ -18058,7 +18087,7 @@ function parse_fonts(t, styles, themes, opts) {
|
||||
break;
|
||||
|
||||
/* 18.8.29 name CT_FontName */
|
||||
case '<name': if(y.val) font.name = y.val; break;
|
||||
case '<name': if(y.val) font.name = utf8read(y.val); break;
|
||||
case '<name/>': case '</name>': break;
|
||||
|
||||
/* 18.8.2 b CT_BooleanProperty */
|
||||
@ -18297,11 +18326,11 @@ return function parse_sty_xml(data, themes, opts) {
|
||||
if((t=data.match(bordersRegex))) parse_borders(t, styles, themes, opts);
|
||||
|
||||
/* 18.8.9 cellStyleXfs CT_CellStyleXfs ? */
|
||||
/* 18.8.8 cellStyles CT_CellStyles ? */
|
||||
|
||||
/* 18.8.10 cellXfs CT_CellXfs ? */
|
||||
if((t=data.match(cellXfRegex))) parse_cellXfs(t, styles, opts);
|
||||
|
||||
/* 18.8.8 cellStyles CT_CellStyles ? */
|
||||
/* 18.8.15 dxfs CT_Dxfs ? */
|
||||
/* 18.8.42 tableStyles CT_TableStyles ? */
|
||||
/* 18.8.11 colors CT_Colors ? */
|
||||
@ -18725,6 +18754,13 @@ function write_sty_bin(wb, opts) {
|
||||
}
|
||||
RELS.THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
||||
|
||||
/* Even though theme layout is dk1 lt1 dk2 lt2, true order is lt1 dk1 lt2 dk2 */
|
||||
var XLSXThemeClrScheme = [
|
||||
'</a:lt1>', '</a:dk1>', '</a:lt2>', '</a:dk2>',
|
||||
'</a:accent1>', '</a:accent2>', '</a:accent3>',
|
||||
'</a:accent4>', '</a:accent5>', '</a:accent6>',
|
||||
'</a:hlink>', '</a:folHlink>'
|
||||
];
|
||||
/* 20.1.6.2 clrScheme CT_ColorScheme */
|
||||
function parse_clrScheme(t, themes, opts) {
|
||||
themes.themeElements.clrScheme = [];
|
||||
@ -18768,7 +18804,7 @@ function parse_clrScheme(t, themes, opts) {
|
||||
case '<a:hlink>': case '</a:hlink>':
|
||||
case '<a:folHlink>': case '</a:folHlink>':
|
||||
if (y[0].charAt(1) === '/') {
|
||||
themes.themeElements.clrScheme.push(color);
|
||||
themes.themeElements.clrScheme[XLSXThemeClrScheme.indexOf(y[0])] = color;
|
||||
color = {};
|
||||
} else {
|
||||
color.name = y[0].slice(3, y[0].length - 1);
|
||||
@ -19507,7 +19543,7 @@ var rc_to_a1 = (function(){
|
||||
};
|
||||
})();
|
||||
|
||||
var crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)([1-9]\d{0,5}|10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6])(?![_.\(A-Za-z0-9])/g;
|
||||
var crefregex = /(^|[^._A-Z0-9])([$]?)([A-Z]{1,2}|[A-W][A-Z]{2}|X[A-E][A-Z]|XF[A-D])([$]?)(10[0-3]\d{4}|104[0-7]\d{3}|1048[0-4]\d{2}|10485[0-6]\d|104857[0-6]|[1-9]\d{0,5})(?![_.\(A-Za-z0-9])/g;
|
||||
var a1_to_rc =(function(){
|
||||
return function a1_to_rc(fstr, base) {
|
||||
return fstr.replace(crefregex, function($0, $1, $2, $3, $4, $5) {
|
||||
@ -22026,7 +22062,7 @@ var browser_has_Map = typeof Map !== 'undefined';
|
||||
function get_sst_id(sst, str, rev) {
|
||||
var i = 0, len = sst.length;
|
||||
if(rev) {
|
||||
if(browser_has_Map ? rev.has(str) : rev.hasOwnProperty(str)) {
|
||||
if(browser_has_Map ? rev.has(str) : Object.prototype.hasOwnProperty.call(rev, str)) {
|
||||
var revarr = browser_has_Map ? rev.get(str) : rev[str];
|
||||
for(; i < revarr.length; ++i) {
|
||||
if(sst[revarr[i]].t === str) { sst.Count ++; return revarr[i]; }
|
||||
@ -22041,7 +22077,7 @@ function get_sst_id(sst, str, rev) {
|
||||
if(!rev.has(str)) rev.set(str, []);
|
||||
rev.get(str).push(len);
|
||||
} else {
|
||||
if(!rev.hasOwnProperty(str)) rev[str] = [];
|
||||
if(!Object.prototype.hasOwnProperty.call(rev, str)) rev[str] = [];
|
||||
rev[str].push(len);
|
||||
}
|
||||
}
|
||||
@ -24165,7 +24201,7 @@ if(wb.Workbook.WBProps.CodeName) { workbookPr.codeName = wb.Workbook.WBProps.Cod
|
||||
if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
|
||||
if(n.Hidden) d.hidden = "1";
|
||||
if(!n.Ref) return;
|
||||
o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "<").replace(/>/g, ">"), d);
|
||||
o[o.length] = writextag('definedName', escapexml(n.Ref), d);
|
||||
});
|
||||
o[o.length] = "</definedNames>";
|
||||
}
|
||||
@ -24681,7 +24717,10 @@ function parse_xlml_data(xml, ss, data, cell, base, styles, csty, row, arrayf, o
|
||||
if(!cell.t) cell.t = 'n';
|
||||
break;
|
||||
case 'Error': cell.t = 'e'; cell.v = RBErr[xml]; if(o.cellText !== false) cell.w = xml; break;
|
||||
default: cell.t = 's'; cell.v = xlml_fixstr(ss||xml); break;
|
||||
default:
|
||||
if(xml == "" && ss == "") { cell.t = 'z'; }
|
||||
else { cell.t = 's'; cell.v = xlml_fixstr(ss||xml); }
|
||||
break;
|
||||
}
|
||||
safe_format_xlml(cell, nf, o);
|
||||
if(o.cellFormula !== false) {
|
||||
@ -25469,7 +25508,9 @@ function write_sty_xlml(wb, opts) {
|
||||
opts.cellXfs.forEach(function(xf, id) {
|
||||
var payload = [];
|
||||
payload.push(writextag('NumberFormat', null, {"ss:Format": escapexml(SSF._table[xf.numFmtId])}));
|
||||
styles.push(writextag('Style', payload.join(""), {"ss:ID": "s" + (21+id)}));
|
||||
|
||||
var o = {"ss:ID": "s" + (21+id)};
|
||||
styles.push(writextag('Style', payload.join(""), o));
|
||||
});
|
||||
return writextag("Styles", styles.join(""));
|
||||
}
|
||||
@ -26639,12 +26680,12 @@ function write_xls_props(wb, cfb) {
|
||||
if(wb.Props) {
|
||||
Keys = keys(wb.Props);
|
||||
// $FlowIgnore
|
||||
for(i = 0; i < Keys.length; ++i) (DocSummaryRE.hasOwnProperty(Keys[i]) ? DSEntries : SummaryRE.hasOwnProperty(Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);
|
||||
for(i = 0; i < Keys.length; ++i) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Props[Keys[i]]]);
|
||||
}
|
||||
if(wb.Custprops) {
|
||||
Keys = keys(wb.Custprops);
|
||||
// $FlowIgnore
|
||||
for(i = 0; i < Keys.length; ++i) if(!(wb.Props||{}).hasOwnProperty(Keys[i])) (DocSummaryRE.hasOwnProperty(Keys[i]) ? DSEntries : SummaryRE.hasOwnProperty(Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);
|
||||
for(i = 0; i < Keys.length; ++i) if(!Object.prototype.hasOwnProperty.call((wb.Props||{}), Keys[i])) (Object.prototype.hasOwnProperty.call(DocSummaryRE, Keys[i]) ? DSEntries : Object.prototype.hasOwnProperty.call(SummaryRE, Keys[i]) ? SEntries : CEntries).push([Keys[i], wb.Custprops[Keys[i]]]);
|
||||
}
|
||||
var CEntries2 = [];
|
||||
for(i = 0; i < CEntries.length; ++i) {
|
||||
@ -27999,6 +28040,29 @@ function write_biff_rec(ba, type, payload, length) {
|
||||
if(len > 0 && is_buf(payload)) ba.push(payload);
|
||||
}
|
||||
|
||||
//function write_biff_continue(ba, type, payload, length) {
|
||||
// var len = length || (payload||[]).length || 0;
|
||||
// if(len <= 8224) return write_biff_rec(ba, type, payload, len);
|
||||
// var t = +type || +XLSRE[type];
|
||||
// if(isNaN(t)) return;
|
||||
// var parts = payload.parts || [], sidx = 0;
|
||||
// var i = 0, w = 0;
|
||||
// while(w + (parts[sidx] || 8224) <= 8224) { w+= (parts[sidx] || 8224); sidx++; }
|
||||
// var o = ba.next(4);
|
||||
// o.write_shift(2, t);
|
||||
// o.write_shift(2, w);
|
||||
// ba.push(payload.slice(i, i + w));
|
||||
// i += w;
|
||||
// while(i < len) {
|
||||
// o = ba.next(4);
|
||||
// o.write_shift(2, 0x3c); // TODO: figure out correct continue type
|
||||
// w = 0;
|
||||
// while(w + (parts[sidx] || 8224) <= 8224) { w+= (parts[sidx] || 8224); sidx++; }
|
||||
// o.write_shift(2, w);
|
||||
// ba.push(payload.slice(i, i+w)); i+= w;
|
||||
// }
|
||||
//}
|
||||
|
||||
function write_BIFF2Cell(out, r, c) {
|
||||
if(!out) out = new_buf(7);
|
||||
out.write_shift(2, r);
|
||||
@ -28724,6 +28788,7 @@ var parse_content_xml = (function() {
|
||||
if(atag.Target) q.l = atag;
|
||||
if(comments.length > 0) { q.c = comments; comments = []; }
|
||||
if(textp && opts.cellText !== false) q.w = textp;
|
||||
if(isstub) { q.t = "z"; delete q.v; }
|
||||
if(!isstub || opts.sheetStubs) {
|
||||
if(!(opts.sheetRows && opts.sheetRows <= R)) {
|
||||
for(var rpt = 0; rpt < rowpeat; ++rpt) {
|
||||
@ -29215,6 +29280,11 @@ var write_content_ods = (function() {
|
||||
o.push(' <number:text>/</number:text>\n');
|
||||
o.push(' <number:year/>\n');
|
||||
o.push(' </number:date-style>\n');
|
||||
|
||||
o.push(' <style:style style:name="ta1" style:family="table">\n'); // style:master-page-name="mp1">\n');
|
||||
o.push(' <style:table-properties table:display="true" style:writing-mode="lr-tb"/>\n');
|
||||
o.push(' </style:style>\n');
|
||||
|
||||
o.push(' <style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>\n');
|
||||
o.push(' </office:automatic-styles>\n');
|
||||
};
|
||||
@ -29838,7 +29908,7 @@ function readSync(data, opts) {
|
||||
if(typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) return readSync(new Uint8Array(data), opts);
|
||||
var d = data, n = [0,0,0,0], str = false;
|
||||
var o = opts||{};
|
||||
if(o.cellStyles) { o.cellNF = true; }
|
||||
if(o.cellStyles) { o.cellNF = true; o.sheetStubs = true; }
|
||||
_ssfopts = {};
|
||||
if(o.dateNF) _ssfopts.dateNF = o.dateNF;
|
||||
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
|
||||
@ -29883,7 +29953,6 @@ function write_cfb_ctr(cfb, o) {
|
||||
return CFB.write(cfb, o);
|
||||
}
|
||||
|
||||
/*global encrypt_agile */
|
||||
function write_zip_type(wb, opts) {
|
||||
var o = opts||{};
|
||||
var z = write_zip(wb, o);
|
||||
@ -29899,7 +29968,9 @@ function write_zip_type(wb, opts) {
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: {"nodebuffer": "buffer", "string": "binary"}[oopts.type] || oopts.type}) : z.generate(oopts);
|
||||
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
|
||||
/*jshint -W083 */
|
||||
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef
|
||||
/*jshint +W083 */
|
||||
if(o.type === "file") return write_dl(o.file, out);
|
||||
return o.type == "string" ? utf8read(out) : out;
|
||||
}
|
||||