sheetjs/dist/xlsx.core.min.js

8 lines
187 KiB
JavaScript
Raw Normal View History

/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
var JSZip=function(data,options){this.files={};this.root="";if(data){this.load(data,options)}};JSZip.signature={LOCAL_FILE_HEADER:"PK",CENTRAL_FILE_HEADER:"PK",CENTRAL_DIRECTORY_END:"PK",ZIP64_CENTRAL_DIRECTORY_LOCATOR:"PK",ZIP64_CENTRAL_DIRECTORY_END:"PK",DATA_DESCRIPTOR:"PK\b"};JSZip.defaults={base64:false,binary:false,dir:false,date:null,compression:null};JSZip.support={arraybuffer:function(){return typeof ArrayBuffer!=="undefined"&&typeof Uint8Array!=="undefined"}(),nodebuffer:function(){return typeof Buffer!=="undefined"}(),uint8array:function(){return typeof Uint8Array!=="undefined"}(),blob:function(){if(typeof ArrayBuffer==="undefined"){return false}var buffer=new ArrayBuffer(0);try{return new Blob([buffer],{type:"application/zip"}).size===0}catch(e){}try{var BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;var builder=new BlobBuilder;builder.append(buffer);return builder.getBlob("application/zip").size===0}catch(e){}return false}()};JSZip.prototype=function(){var textEncoder,textDecoder;if(JSZip.support.uint8array&&typeof TextEncoder==="function"&&typeof TextDecoder==="function"){textEncoder=new TextEncoder("utf-8");textDecoder=new TextDecoder("utf-8")}var getRawData=function(file){if(file._data instanceof JSZip.CompressedObject){file._data=file._data.getContent();file.options.binary=true;file.options.base64=false;if(JSZip.utils.getTypeOf(file._data)==="uint8array"){var copy=file._data;file._data=new Uint8Array(copy.length);if(copy.length!==0){file._data.set(copy,0)}}}return file._data};var getBinaryData=function(file){var result=getRawData(file),type=JSZip.utils.getTypeOf(result);if(type==="string"){if(!file.options.binary){if(textEncoder){return textEncoder.encode(result)}if(JSZip.support.nodebuffer){return new Buffer(result,"utf-8")}}return file.asBinary()}return result};var dataToString=function(asUTF8){var result=getRawData(this);if(result===null||typeof result==="undefined"){return""}if(this.options.base64){result=JSZip.base64.decode(result)}if(asUTF8&&this.options.binary){result=JSZip.prototype.utf8decode(result)}else{result=JSZip.utils.transformTo("string",result)}if(!asUTF8&&!this.options.binary){result=JSZip.prototype.utf8encode(result)}return result};var ZipObject=function(name,data,options){this.name=name;this._data=data;this.options=options};ZipObject.prototype={asText:function(){return dataToString.call(this,true)},asBinary:function(){return dataToString.call(this,false)},asNodeBuffer:function(){var result=getBinaryData(this);return JSZip.utils.transformTo("nodebuffer",result)},asUint8Array:function(){var result=getBinaryData(this);return JSZip.utils.transformTo("uint8array",result)},asArrayBuffer:function(){return this.asUint8Array().buffer}};var decToHex=function(dec,bytes){var hex="",i;for(i=0;i<bytes;i++){hex+=String.fromCharCode(dec&255);dec=dec>>>8}return hex};var extend=function(){var result={},i,attr;for(i=0;i<arguments.length;i++){for(attr in arguments[i]){if(arguments[i].hasOwnProperty(attr)&&typeof result[attr]==="undefined"){result[attr]=arguments[i][attr]}}}return result};var prepareFileAttrs=function(o){o=o||{};if(o.base64===true&&o.binary==null){o.binary=true}o=extend(o,JSZip.defaults);o.date=o.date||new Date;if(o.compression!==null)o.compression=o.compression.toUpperCase();return o};var fileAdd=function(name,data,o){var parent=parentFolder(name),dataType=JSZip.utils.getTypeOf(data);if(parent){folderAdd.call(this,parent)}o=prepareFileAttrs(o);if(o.dir||data===null||typeof data==="undefined"){o.base64=false;o.binary=false;data=null}else if(dataType==="string"){if(o.binary&&!o.base64){if(o.optimizedBinaryString!==true){data=JSZip.utils.string2binary(data)}}}else{o.base64=false;o.binary=true;if(!dataType&&!(data instanceof JSZip.CompressedObject)){throw new Error("The data of '"+name+"' is in an unsupported format !")}if(dataType==="arraybuffer"){data=JSZip.utils.transformTo("uint8array",data)}}var object=new ZipObject(name,data,o);this.files[name]=object;return object};var parentFolder=function(path){if(path.slice(-1)=="/"
}else{JSZip.compressions["DEFLATE"].compress=compress;JSZip.compressions["DEFLATE"].compressInputType=USE_TYPEDARRAY?"uint8array":"array"}})();(function(){"use strict";if(!JSZip){throw"JSZip not defined"}var context={};(function(){(function(){"use strict";var l=void 0,p=this;function q(c,d){var a=c.split("."),b=p;!(a[0]in b)&&b.execScript&&b.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)!a.length&&d!==l?b[e]=d:b=b[e]?b[e]:b[e]={}}var r="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array;function u(c){var d=c.length,a=0,b=Number.POSITIVE_INFINITY,e,f,g,h,k,m,s,n,t;for(n=0;n<d;++n)c[n]>a&&(a=c[n]),c[n]<b&&(b=c[n]);e=1<<a;f=new(r?Uint32Array:Array)(e);g=1;h=0;for(k=2;g<=a;){for(n=0;n<d;++n)if(c[n]===g){m=0;s=h;for(t=0;t<g;++t)m=m<<1|s&1,s>>=1;for(t=m;t<e;t+=k)f[t]=g<<16|n;++h}++g;h<<=1;k<<=1}return[f,a,b]}function v(c,d){this.g=[];this.h=32768;this.c=this.f=this.d=this.k=0;this.input=r?new Uint8Array(c):c;this.l=!1;this.i=w;this.p=!1;if(d||!(d={}))d.index&&(this.d=d.index),d.bufferSize&&(this.h=d.bufferSize),d.bufferType&&(this.i=d.bufferType),d.resize&&(this.p=d.resize);switch(this.i){case x:this.a=32768;this.b=new(r?Uint8Array:Array)(32768+this.h+258);break;case w:this.a=0;this.b=new(r?Uint8Array:Array)(this.h);this.e=this.u;this.m=this.r;this.j=this.s;break;default:throw Error("invalid inflate mode")}}var x=0,w=1;v.prototype.t=function(){for(;!this.l;){var c=y(this,3);c&1&&(this.l=!0);c>>>=1;switch(c){case 0:var d=this.input,a=this.d,b=this.b,e=this.a,f=l,g=l,h=l,k=b.length,m=l;this.c=this.f=0;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: LEN (first byte)");g=f;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: LEN (second byte)");g|=f<<8;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: NLEN (first byte)");h=f;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: NLEN (second byte)");h|=f<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case x:for(;e+g>b.length;){m=k-e;g-=m;if(r)b.set(d.subarray(a,a+m),e),e+=m,a+=m;else for(;m--;)b[e++]=d[a++];this.a=e;b=this.e();e=this.a}break;case w:for(;e+g>b.length;)b=this.e({o:2});break;default:throw Error("invalid inflate mode")}if(r)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.d=a;this.a=e;this.b=b;break;case 1:this.j(z,A);break;case 2:B(this);break;default:throw Error("unknown BTYPE: "+c)}}return this.m()};var C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=r?new Uint16Array(C):C,E=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],F=r?new Uint16Array(E):E,G=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],H=r?new Uint8Array(G):G,I=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],J=r?new Uint16Array(I):I,K=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],L=r?new Uint8Array(K):K,M=new(r?Uint8Array:Array)(288),N,O;N=0;for(O=M.length;N<O;++N)M[N]=143>=N?8:255>=N?9:279>=N?7:8;var z=u(M),P=new(r?Uint8Array:Array)(30),Q,R;Q=0;for(R=P.length;Q<R;++Q)P[Q]=5;var A=u(P);function y(c,d){for(var a=c.f,b=c.c,e=c.input,f=c.d,g;b<d;){g=e[f++];if(g===l)throw Error("input buffer is broken");a|=g<<b;b+=8}g=a&(1<<d)-1;c.f=a>>>d;c.c=b-d;c.d=f;return g}function S(c,d){for(var a=c.f,b=c.c,e=c.input,f=c.d,g=d[0],h=d[1],k,m,s;b<h;){k=e[f++];if(k===l)break;a|=k<<b;b+=8}m=g[a&(1<<h)-1];s=m>>>16;c.f=a>>s;c.c=b-s;c.d=f;return m&65535}function B(c){function d(a,c,b){var d,f,e,g;for(g=0;g<a;)switch(d=S(this,c),d){case 16:for(e=3+y(this,2);e--;)b[g++]=f;break;case 17:for(e=3+y(this,3);e--;)b[g++]=0;f=0;break;case 18:for(e=11+y(this,7);e--;)b[g++]=0;f=0;break;default:f=b[g++]=d}return b}var a=y(c,5)+257,b=y(c,5)+1,e=y(c,4)+4,f=new(r?Uint8Array:Array)(D.length),g,h,k,m;for(m=0;m<e;++m)f[D[m]]=y(c,3);g=u(f);h=new(r?Uint8Array:Array)(a);k=new(r?Uint8Array:Array)(b);c.j(u(d.call(c,a,g,h)),u(d.call(c,b,g,k)))}v.prototype.j=
while("0123456789".indexOf(fmt[++i])>-1)o+=fmt[i];out.push({t:"D",v:o});break;case" ":out.push({t:c,v:c});++i;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxz".indexOf(c)===-1)throw"unrecognized character "+fmt[i]+" in "+fmt;out.push({t:"t",v:c});++i;break}}var bt=0,ss0=0,ssm;for(i=out.length-1,lst="t";i>=0;--i){switch(out[i].t){case"h":case"H":out[i].t=hr;lst="h";if(bt<1)bt=1;break;case"s":if(ssm=out[i].v.match(/\.0+$/))ss0=Math.max(ss0,ssm[0].length-1);if(bt<3)bt=3;case"d":case"y":case"M":case"e":lst=out[i].t;break;case"m":if(lst==="s"){out[i].t="M";if(bt<2)bt=2}break;case"X":if(out[i].v==="B2");break;case"Z":if(bt<1&&out[i].v.match(/[Hh]/))bt=1;if(bt<2&&out[i].v.match(/[Mm]/))bt=2;if(bt<3&&out[i].v.match(/[Ss]/))bt=3}}switch(bt){case 0:break;case 1:if(dt.u>=.5){dt.u=0;++dt.S}if(dt.S>=60){dt.S=0;++dt.M}if(dt.M>=60){dt.M=0;++dt.H}break;case 2:if(dt.u>=.5){dt.u=0;++dt.S}if(dt.S>=60){dt.S=0;++dt.M}break}var nstr="",jj;for(i=0;i<out.length;++i){switch(out[i].t){case"t":case"T":case" ":case"D":break;case"X":delete out[i];break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":out[i].v=write_date(out[i].t,out[i].v,dt,ss0);out[i].t="t";break;case"n":case"(":case"?":jj=i+1;while(out[jj]&&("?D".indexOf(out[jj].t)>-1||" t".indexOf(out[jj].t)>-1&&"?t".indexOf((out[jj+1]||{}).t)>-1&&(out[jj+1].t=="?"||out[jj+1].v=="/")||out[i].t=="("&&")n ".indexOf(out[jj].t)>-1||out[jj].t=="t"&&(out[jj].v=="/"||"$€".indexOf(out[jj].v)>-1||out[jj].v==" "&&(out[jj+1]||{}).t=="?"))){out[i].v+=out[jj].v;delete out[jj];++jj}nstr+=out[i].v;i=jj-1;break;case"G":out[i].t="t";out[i].v=general_fmt(v,opts);break}}if(nstr){var ostr=write_num(nstr[0]=="("?"(":"n",nstr,v<0&&nstr[0]=="-"?-v:v);jj=ostr.length-1;var decpt=out.length;for(i=0;i<out.length;++i)if(out[i]&&out[i].v.indexOf(".")>-1){decpt=i;break}var lasti=out.length,vv;if(decpt===out.length&&!ostr.match(/E/)){for(i=out.length-1;i>=0;--i){if(!out[i]||"n?(".indexOf(out[i].t)===-1)continue;vv=out[i].v.split("");for(j=vv.length-1;j>=0;--j){if(jj>=0)vv[j]=ostr[jj--];else vv[j]=""}out[i].v=vv.join("");out[i].t="t";lasti=i}if(jj>=0&&lasti<out.length)out[lasti].v=ostr.substr(0,jj+1)+out[lasti].v}else if(decpt!==out.length&&!ostr.match(/E/)){jj=ostr.indexOf(".")-1;for(i=decpt;i>=0;--i){if(!out[i]||"n?(".indexOf(out[i].t)===-1)continue;vv=out[i].v.split("");for(j=out[i].v.indexOf(".")>-1&&i==decpt?out[i].v.indexOf(".")-1:vv.length-1;j>=0;--j){if(jj>=0&&"0#".indexOf(vv[j])>-1)vv[j]=ostr[jj--];else vv[j]=""}out[i].v=vv.join("");out[i].t="t";lasti=i}if(jj>=0&&lasti<out.length)out[lasti].v=ostr.substr(0,jj+1)+out[lasti].v;jj=ostr.indexOf(".")+1;for(i=decpt;i<out.length;++i){if(!out[i]||"n?(".indexOf(out[i].t)===-1&&i!=decpt)continue;vv=out[i].v.split("");for(j=out[i].v.indexOf(".")>-1&&i==decpt?out[i].v.indexOf(".")+1:0;j<vv.length;++j){if(jj<ostr.length)vv[j]=ostr[jj++];else vv[j]=""}out[i].v=vv.join("");out[i].t="t";lasti=i}}}for(i=0;i<out.length;++i)if(out[i]&&"n(?".indexOf(out[i].t)>-1){out[i].v=write_num(out[i].t,out[i].v,flen>1&&v<0&&i>0&&out[i-1].v=="-"?-v:v);out[i].t="t"}var retval="";for(i=0;i!=out.length;++i)if(out[i])retval+=out[i].v;return retval}SSF._eval=eval_fmt;function choose_fmt(fmt,v,o){if(typeof fmt==="number")fmt=(o&&o.table?o.table:table_fmt)[fmt];if(typeof fmt==="string")fmt=split_fmt(fmt);var l=fmt.length;if(l<4&&fmt[l-1].indexOf("@")>-1)--l;switch(fmt.length){case 1:fmt=fmt[0].indexOf("@")>-1?["General","General","General",fmt[0]]:[fmt[0],fmt[0],fmt[0],"@"];break;case 2:fmt=fmt[1].indexOf("@")>-1?[fmt[0],fmt[0],fmt[0],fmt[1]]:[fmt[0],fmt[1],fmt[0],"@"];break;case 3:fmt=fmt[2].indexOf("@")>-1?[fmt[0],fmt[1],fmt[0],fmt[2]]:[fmt[0],fmt[1],fmt[2],"@"];break;case 4:break;default:throw"cannot find right format for |"+fmt+"|"}if(typeof v!=="number")return[fmt.length,fmt[3]];var ff=v>0?fmt[0]:v<0?fmt[1]:fmt[2];if(fmt[0].match(/\[[=<>]/)||fmt[1].match(/\[[=<>]/)){var chk=function(v,rr,out){if(!rr)return null;var found=false;var thresh=Number(rr[2]);switch(rr[1]){case"=":if(v==thresh)found=true;break;case">":if(v>thresh)found=true;break;case"<":if(v<thresh)fou
break;case"r4":case"r8":case"decimal":p[name]=parseFloat(text);break;case"filetime":case"date":p[name]=new Date(text);break;case"cy":case"error":p[name]=unescapexml(text);break;default:console.warn("Unexpected",x,type,toks)}}else if(x.substr(0,2)==="</"){}else if(opts.WTF)throw new Error(x)}});return p}var CUST_PROPS_XML_ROOT=writextag("Properties",null,{xmlns:XMLNS.CUST_PROPS,"xmlns:vt":XMLNS.vt});function write_cust_props(cp,opts){var o=[],p={};o.push(XML_HEADER);o.push(CUST_PROPS_XML_ROOT);if(!cp)return o.join("");var pid=1;keys(cp).forEach(function(k){++pid;o.push(writextag("property",write_vt(cp[k]),{fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:pid,name:k}))});if(o.length>2){o.push("</Properties>");o[1]=o[1].replace("/>",">")}return o.join("")}var CS2CP={0:1252,1:65001,2:65001,77:1e4,128:932,129:949,130:1361,134:936,136:950,161:1253,162:1254,163:1258,177:1255,178:1256,186:1257,204:1251,222:874,238:1250,255:1252,69:6969};var parse_rs=function(){var tregex=matchtag("t"),rpregex=matchtag("rPr");var parse_rpr=function(rpr,intro,outro){var font={},cp=65001;(rpr.match(/<[^>]*>/g)||[]).forEach(function(x){var y=parsexmltag(x);switch(y[0]){case"<condense":break;case"<extend":break;case"<shadow":case"<shadow/>":break;case"<charset":if(y.val=="1")break;cp=CS2CP[parseInt(y.val,10)];break;case"<outline":case"<outline/>":break;case"<rFont":font.name=y.val;break;case"<sz":font.sz=y.val;break;case"<strike":if(!y.val)break;case"<strike/>":font.strike=1;break;case"</strike>":break;case"<u":if(!y.val)break;case"<u/>":font.u=1;break;case"</u>":break;case"<b":if(!y.val)break;case"<b/>":font.b=1;break;case"</b>":break;case"<i":if(!y.val)break;case"<i/>":font.i=1;break;case"</i>":break;case"<color":if(y.rgb)font.color=y.rgb.substr(2,6);break;case"<family":font.family=y.val;break;case"<vertAlign":break;case"<scheme":break;default:if(y[0][2]!=="/")throw"Unrecognized rich format "+y[0]}});var style=[];if(font.b)style.push("font-weight: bold;");if(font.i)style.push("font-style: italic;");intro.push('<span style="'+style.join("")+'">');outro.push("</span>");return cp};function parse_r(r){var terms=[[],"",[]];var t=r.match(tregex),cp=65001;if(!isval(t))return"";terms[1]=t[1];var rpr=r.match(rpregex);if(isval(rpr))cp=parse_rpr(rpr[1],terms[0],terms[2]);return terms[0].join("")+terms[1].replace(/\r\n/g,"<br/>")+terms[2].join("")}return function(rs){return rs.replace(/<r>/g,"").split(/<\/r>/).map(parse_r).join("")}}();var parse_si=function(x,opts){var html=opts?opts.cellHTML:true;var z={};if(!x)return null;var y;if(x.charCodeAt(1)===116){z.t=utf8read(unescapexml(x.substr(x.indexOf(">")+1).split(/<\/t>/)[0]));z.r=x;if(html)z.h=z.t}else if(y=x.match(/<r>/)){z.r=x;z.t=utf8read(unescapexml(x.replace(/<[^>]*>/gm,"")));if(html)z.h=parse_rs(x)}return z};var parse_sst_xml=function(data,opts){var s=[];var sst=data.match(new RegExp("<sst([^>]*)>([\\s\\S]*)</sst>","m"));if(isval(sst)){s=sst[2].replace(/<(?:si|sstItem)>/g,"").split(/<\/(?:si|sstItem)>/).map(function(x){return parse_si(x,opts)}).filter(function(x){return x});sst=parsexmltag(sst[1]);s.Count=sst.count;s.Unique=sst.uniqueCount}return s};RELS.SST="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings";var write_sst_xml=function(sst,opts){if(!opts.bookSST)return"";var o=[];o.push(XML_HEADER);o.push(writextag("sst",null,{xmlns:XMLNS.main[0],count:sst.Count,uniqueCount:sst.Unique}));sst.forEach(function(s){var sitag="<si>";if(s.r)sitag+=s.r;else{sitag+="<t";if(s.t.match(/^\s|\s$|[\t\n\r]/))sitag+=' xml:space="preserve"';sitag+=">";sitag+=escapexml(s.t);sitag+="</t>"}sitag+="</si>";o.push(sitag)});if(o.length>2){o.push("</sst>");o[1]=o[1].replace("/>",">")}return o.join("")};var parse_BrtBeginSst=function(data,length){return[data.read_shift(4),data.read_shift(4)]};var parse_sst_bin=function(data,opts){var s=[];var pass=false;recordhopper(data,function(val,R,RT){switch(R.n){case"BrtBeginSst":s.Count=val[0];s.Unique=val[1];break;case"BrtSSTItem":s.push(val);break;case"BrtEndSst":return true;case"BrtFRTBegin":pass=true;break;case"BrtFRTEnd":pass=false;break;default:if(
o.t="s";return writextag("c",v,o)}o.t="str";return writextag("c",v,o);case"n":delete o.t;return writextag("c",v,o);case"b":o.t="b";return writextag("c",v,o);case"e":o.t="e";return writextag("c",v,o)}};var write_ws_xml_data=function(ws,opts,idx,wb){var o=[],r=[],range=utils.decode_range(ws["!ref"]),cell,ref;for(var R=range.s.r;R<=range.e.r;++R){r=[];for(var C=range.s.c;C<=range.e.c;++C){ref=utils.encode_cell({c:C,r:R});if(!ws[ref])continue;if(cell=write_ws_xml_cell(ws[ref],ref,ws,opts,idx,wb))r.push(cell)}if(r.length)o.push(writextag("row",r.join(""),{r:encode_row(R)}))}return o.join("")};var WS_XML_ROOT=writextag("worksheet",null,{xmlns:XMLNS.main[0],"xmlns:r":XMLNS.r});var write_ws_xml=function(idx,opts,wb){var o=[],s=wb.SheetNames[idx],ws=wb.Sheets[s]||{},sidx=0,rdata="";o.push(XML_HEADER);o.push(WS_XML_ROOT);o.push(writextag("dimension",null,{ref:ws["!ref"]||"A1"}));if((ws["!cols"]||[]).length>0)o.push(write_ws_xml_cols(ws,ws["!cols"]));sidx=o.length;o.push(writextag("sheetData",null));if(ws["!ref"])rdata=write_ws_xml_data(ws,opts,idx,wb);if(rdata.length)o.push(rdata);if(o.length>sidx+1){o.push("</sheetData>");o[sidx]=o[sidx].replace("/>",">")}if(o.length>2){o.push("</worksheet>");o[1]=o[1].replace("/>",">")}return o.join("")};var parse_BrtRowHdr=function(data,length){var z={};z.r=data.read_shift(4);data.l+=length-4;return z};var parse_BrtWsDim=parse_UncheckedRfX;var write_BrtWsDim=write_UncheckedRfX;var parse_BrtWsProp=function(data,length){var z={};data.l+=19;z.name=parse_CodeName(data,length-19);return z};var parse_BrtCellBlank=function(data,length){var cell=parse_Cell(data);return[cell]};var parse_BrtCellBool=function(data,length){var cell=parse_Cell(data);var fBool=data.read_shift(1);return[cell,fBool,"b"]};var parse_BrtCellError=function(data,length){var cell=parse_Cell(data);var fBool=data.read_shift(1);return[cell,fBool,"e"]};var parse_BrtCellIsst=function(data,length){var cell=parse_Cell(data);var isst=data.read_shift(4);return[cell,isst,"s"]};var parse_BrtCellReal=function(data,length){var cell=parse_Cell(data);var value=parse_Xnum(data);return[cell,value,"n"]};var parse_BrtCellRk=function(data,length){var cell=parse_Cell(data);var value=parse_RkNumber(data);return[cell,value,"n"]};var parse_BrtCellSt=function(data,length){var cell=parse_Cell(data);var value=parse_XLWideString(data);return[cell,value,"str"]};var parse_BrtFmlaBool=function(data,length,opts){var cell=parse_Cell(data);var value=data.read_shift(1);var o=[cell,value,"b"];if(opts.cellFormula){var formula=parse_CellParsedFormula(data,length-9);o[3]=""}else data.l+=length-9;return o};var parse_BrtFmlaError=function(data,length,opts){var cell=parse_Cell(data);var value=data.read_shift(1);var o=[cell,value,"e"];if(opts.cellFormula){var formula=parse_CellParsedFormula(data,length-9);o[3]=""}else data.l+=length-9;return o};var parse_BrtFmlaNum=function(data,length,opts){var cell=parse_Cell(data);var value=parse_Xnum(data);var o=[cell,value,"n"];if(opts.cellFormula){var formula=parse_CellParsedFormula(data,length-16);o[3]=""}else data.l+=length-16;return o};var parse_BrtFmlaString=function(data,length,opts){var start=data.l;var cell=parse_Cell(data);var value=parse_XLWideString(data);var o=[cell,value,"str"];if(opts.cellFormula){var formula=parse_CellParsedFormula(data,start+length-data.l);o[3]=""}else data.l=start+length;return o};var parse_BrtMergeCell=parse_UncheckedRfX;var parse_BrtHLink=function(data,length,opts){var end=data.l+length;var rfx=parse_UncheckedRfX(data,16);var relId=parse_XLNullableWideString(data);var loc=parse_XLWideString(data);var tooltip=parse_XLWideString(data);var display=parse_XLWideString(data);data.l=end;return{rfx:rfx,relId:relId,loc:loc,tooltip:tooltip,display:display}};var parse_ws_bin=function(data,opts,rels){if(!data)return data;if(!rels)rels={"!id":{}};var s={};var ref;var refguess={s:{r:1e6,c:1e6},e:{r:0,c:0}};var pass=false,end=false;var row,p,cf,R,C,addr;var mergecells=[];recordhopper(data,function(val,R){if(end)return;switch(R.n){case"BrtWsDim":ref=val;break;case"BrtRowHdr":row=val;if(opts.sheetRows&&opts.sheetRows
var evert_RE=evert(RecordEnum,"n");function fix_opts(defaults){return function(opts){defaults.forEach(function(d){if(typeof opts[d[0]]==="undefined")opts[d[0]]=d[1];if(d[2]==="n")opts[d[0]]=Number(opts[d[0]])})}}var fix_read_opts=fix_opts([["cellNF",false],["cellHTML",true],["cellFormula",true],["cellStyles",false],["sheetStubs",false],["sheetRows",0,"n"],["bookDeps",false],["bookSheets",false],["bookProps",false],["bookFiles",false],["bookVBA",false],["WTF",false]]);var fix_write_opts=fix_opts([["bookSST",false],["bookType","xlsx"],["WTF",false]]);function safe_parse_wbrels(wbrels,sheets){if(!wbrels)return 0;try{wbrels=sheets.map(function(w){return[w.name,wbrels["!id"][w.id].Target]})}catch(e){return null}return!wbrels||wbrels.length===0?null:wbrels}function safe_parse_ws(zip,path,relsPath,sheet,sheetRels,sheets,opts){try{sheetRels[sheet]=parse_rels(getzipdata(zip,relsPath,true),path);sheets[sheet]=parse_ws(getzipdata(zip,path),path,opts,sheetRels[sheet])}catch(e){if(opts.WTF)throw e}}function parse_zip(zip,opts){make_ssf(SSF);opts=opts||{};fix_read_opts(opts);reset_cp();var entries=keys(zip.files).filter(function(x){return x.substr(-1)!="/"}).sort();var dir=parse_ct(getzipdata(zip,"[Content_Types].xml"),opts);var xlsb=false;var sheets,binname;if(dir.workbooks.length===0){binname="xl/workbook.xml";if(getzipdata(zip,binname,true))dir.workbooks.push(binname)}if(dir.workbooks.length===0){binname="xl/workbook.bin";if(!getzipfile(zip,binname,true))throw new Error("Could not find workbook");dir.workbooks.push(binname);xlsb=true}if(dir.workbooks[0].substr(-3)=="bin")xlsb=true;if(xlsb)set_cp(1200);if(!opts.bookSheets&&!opts.bookProps){strs=[];if(dir.sst)strs=parse_sst(getzipdata(zip,dir.sst.replace(/^\//,"")),dir.sst,opts);styles={};if(dir.style)styles=parse_sty(getzipdata(zip,dir.style.replace(/^\//,"")),dir.style,opts);themes={};if(opts.cellStyles&&dir.themes.length)themes=parse_theme(getzipdata(zip,dir.themes[0].replace(/^\//,""),true),dir.themes[0],opts)}var wb=parse_wb(getzipdata(zip,dir.workbooks[0].replace(/^\//,"")),dir.workbooks[0],opts);var props={},propdata="";if(dir.coreprops.length!==0){propdata=getzipdata(zip,dir.coreprops[0].replace(/^\//,""),true);if(propdata)props=parse_core_props(propdata);if(dir.extprops.length!==0){propdata=getzipdata(zip,dir.extprops[0].replace(/^\//,""),true);if(propdata)parse_ext_props(propdata,props)}}var custprops={};if(!opts.bookSheets||opts.bookProps){if(dir.custprops.length!==0){propdata=getzipdata(zip,dir.custprops[0].replace(/^\//,""),true);if(propdata)custprops=parse_cust_props(propdata,opts)}}var out={};if(opts.bookSheets||opts.bookProps){if(props.Worksheets&&props.SheetNames.length>0)sheets=props.SheetNames;else if(wb.Sheets)sheets=wb.Sheets.map(function(x){return x.name});if(opts.bookProps){out.Props=props;out.Custprops=custprops}if(typeof sheets!=="undefined")out.SheetNames=sheets;if(opts.bookSheets?out.SheetNames:opts.bookProps)return out}sheets={};var deps={};if(opts.bookDeps&&dir.calcchain)deps=parse_cc(getzipdata(zip,dir.calcchain.replace(/^\//,"")),dir.calcchain,opts);var i=0;var sheetRels={};var path,relsPath;if(!props.Worksheets){var wbsheets=wb.Sheets;props.Worksheets=wbsheets.length;props.SheetNames=[];for(var j=0;j!=wbsheets.length;++j){props.SheetNames[j]=wbsheets[j].name}}var wbext=xlsb?"bin":"xml";var wbrelsfile="xl/_rels/workbook."+wbext+".rels";var wbrels=parse_rels(getzipdata(zip,wbrelsfile,true),wbrelsfile);if(wbrels)wbrels=safe_parse_wbrels(wbrels,wb.Sheets);var nmode=getzipdata(zip,"xl/worksheets/sheet.xml",true)?1:0;for(i=0;i!=props.Worksheets;++i){if(wbrels)path="xl/"+wbrels[i][1].replace(/[\/]?xl\//,"");else{path="xl/worksheets/sheet"+(i+1-nmode)+"."+wbext;path=path.replace(/sheet0\./,"sheet.")}relsPath=path.replace(/^(.*)(\/)([^\/]*)$/,"$1/_rels/$3.rels");safe_parse_ws(zip,path,relsPath,props.SheetNames[i],sheetRels,sheets,opts)}if(dir.comments)parse_comments(zip,dir.comments,sheets,sheetRels,opts);out={Directory:dir,Workbook:wb,Props:props,Custprops:custprops,Deps:deps,Sheets:sheets,SheetNames:props.SheetNames,Strings:strs,Styles:styles,Themes:themes,S
//# sourceMappingURL=dist/xlsx.core.min.map