}returnres};exports.findCompression=function(compressionMethod){for(varmethodincompressions){if(!compressions.hasOwnProperty(method)){continue}if(compressions[method].magic===compressionMethod){returncompressions[method]}}returnnull};exports.isRegExp=function(object){returnObject.prototype.toString.call(object)==="[object RegExp]"}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(_dereq_,module,exports){"use strict";varStringReader=_dereq_("./stringReader");varNodeBufferReader=_dereq_("./nodeBufferReader");varUint8ArrayReader=_dereq_("./uint8ArrayReader");varutils=_dereq_("./utils");varsig=_dereq_("./signature");varZipEntry=_dereq_("./zipEntry");varsupport=_dereq_("./support");varjszipProto=_dereq_("./object");functionZipEntries(data,loadOptions){this.files=[];this.loadOptions=loadOptions;if(data){this.load(data)}}ZipEntries.prototype={checkSignature:function(expectedSignature){varsignature=this.reader.readString(4);if(signature!==expectedSignature){thrownewError("Corrupted zip or bug : unexpected signature "+"("+utils.pretty(signature)+", expected "+utils.pretty(expectedSignature)+")")}},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2);this.diskWithCentralDirStart=this.reader.readInt(2);this.centralDirRecordsOnThisDisk=this.reader.readInt(2);this.centralDirRecords=this.reader.readInt(2);this.centralDirSize=this.reader.readInt(4);this.centralDirOffset=this.reader.readInt(4);this.zipCommentLength=this.reader.readInt(2);this.zipComment=this.reader.readString(this.zipCommentLength);this.zipComment=jszipProto.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8);this.versionMadeBy=this.reader.readString(2);this.versionNeeded=this.reader.readInt(2);this.diskNumber=this.reader.readInt(4);this.diskWithCentralDirStart=this.reader.readInt(4);this.centralDirRecordsOnThisDisk=this.reader.readInt(8);this.centralDirRecords=this.reader.readInt(8);this.centralDirSize=this.reader.readInt(8);this.centralDirOffset=this.reader.readInt(8);this.zip64ExtensibleData={};varextraDataSize=this.zip64EndOfCentralSize-44,index=0,extraFieldId,extraFieldLength,extraFieldValue;while(index<extraDataSize){extraFieldId=this.reader.readInt(2);extraFieldLength=this.reader.readInt(4);extraFieldValue=this.reader.readString(extraFieldLength);this.zip64ExtensibleData[extraFieldId]={id:extraFieldId,length:extraFieldLength,value:extraFieldValue}}},readBlockZip64EndOfCentralLocator:function(){this.diskWithZip64CentralDirStart=this.reader.readInt(4);this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8);this.disksCount=this.reader.readInt(4);if(this.disksCount>1){thrownewError("Multi-volumes zip are not supported")}},readLocalFiles:function(){vari,file;for(i=0;i<this.files.length;i++){file=this.files[i];this.reader.setIndex(file.localHeaderOffset);this.checkSignature(sig.LOCAL_FILE_HEADER);file.readLocalPart(this.reader);file.handleUTF8()}},readCentralDir:function(){varfile;this.reader.setIndex(this.centralDirOffset);while(this.reader.readString(4)===sig.CENTRAL_FILE_HEADER){file=newZipEntry({zip64:this.zip64},this.loadOptions);file.readCentralPart(this.reader);this.files.push(file)}},readEndOfCentral:function(){varoffset=this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);if(offset===-1){thrownewError("Corrupted zip : can't find end of central directory")}this.reader.setIndex(offset);this.checkSignature(sig.CENTRAL_DIRECTORY_END);this.readBlockEndOfCentral();if(this.diskNumber===utils.MAX_VALUE_16BITS||this.diskWithCentralDirStart===utils.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===utils.MAX_VALUE_16BITS||this.centralDirRecords===utils.MAX_VALUE_16BITS||this.centralDirSize===utils.MAX_VALUE_32BITS||this.centralDirOffset===utils.MAX_VALUE_32BITS){this.zip64=true;offset=this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);if(offset===-1){thrownewError("Corrupted zip : can't find the ZIP64 end of central directory locator")}this.reader.setIndex(offset);this.checkSignature(sig.ZIP64_CENTRAL_D
}functionwxt_helper(h){returnkeys(h).map(function(k){return" "+k+'="'+h[k]+'"'}).join("")}functionwritextag(f,g,h){return"<"+f+(isval(h)?wxt_helper(h):"")+(isval(g)?(g.match(wtregex)?' xml:space="preserve"':"")+">"+g+"</"+f:"/")+">"}functionwrite_w3cdtf(d,t){try{returnd.toISOString().replace(/\.\d*/,"")}catch(e){if(t)throwe}return""}functionwrite_vt(s){switch(typeofs){case"string":returnwritextag("vt:lpwstr",s);case"number":returnwritextag((s|0)==s?"vt:i4":"vt:r8",String(s));case"boolean":returnwritextag("vt:bool",s?"true":"false");}if(sinstanceofDate)returnwritextag("vt:filetime",write_w3cdtf(s));thrownewError("Unable to serialize "+s)}varXML_HEADER='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';varXMLNS={dc:"http://purl.org/dc/elements/1.1/",dcterms:"http://purl.org/dc/terms/",dcmitype:"http://purl.org/dc/dcmitype/",mx:"http://schemas.microsoft.com/office/mac/excel/2008/main",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",sjs:"http://schemas.openxmlformats.org/package/2006/sheetjs/core-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",xsi:"http://www.w3.org/2001/XMLSchema-instance",xsd:"http://www.w3.org/2001/XMLSchema"};XMLNS.main=["http://schemas.openxmlformats.org/spreadsheetml/2006/main","http://purl.oclc.org/ooxml/spreadsheetml/main","http://schemas.microsoft.com/office/excel/2006/main","http://schemas.microsoft.com/office/excel/2006/2"];varXLMLNS={o:"urn:schemas-microsoft-com:office:office",x:"urn:schemas-microsoft-com:office:excel",ss:"urn:schemas-microsoft-com:office:spreadsheet",dt:"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882",mv:"http://macVmlSchemaUri",v:"urn:schemas-microsoft-com:vml",html:"http://www.w3.org/TR/REC-html40"};functionread_double_le(b,idx){vars=1-2*(b[idx+7]>>>7);vare=((b[idx+7]&127)<<4)+(b[idx+6]>>>4&15);varm=b[idx+6]&15;for(vari=5;i>=0;--i)m=m*256+b[idx+i];if(e==2047)returnm==0?s*Infinity:NaN;if(e==0)e=-1022;else{e-=1023;m+=Math.pow(2,52)}returns*Math.pow(2,e-52)*m}functionwrite_double_le(b,v,idx){varbs=(v<0||1/v==-Infinity?1:0)<<7,e=0,m=0;varav=bs?-v:v;if(!isFinite(av)){e=2047;m=isNaN(v)?26985:0}else{e=Math.floor(Math.log(av)*Math.LOG2E);m=v*Math.pow(2,52-e);if(e<=-1023&&(!isFinite(m)||m<Math.pow(2,52))){e=-1022}else{m-=Math.pow(2,52);e+=1023}}for(vari=0;i<=5;++i,m/=256)b[idx+i]=m&255;b[idx+6]=(e&15)<<4|m&15;b[idx+7]=e>>4|bs}var__toBuffer,___toBuffer;__toBuffer=___toBuffer=functiontoBuffer_(bufs){varx=[];for(vari=0;i<bufs[0].length;++i){x.push.apply(x,bufs[0][i])}returnx};var__utf16le,___utf16le;__utf16le=___utf16le=functionutf16le_(b,s,e){varss=[];for(vari=s;i<e;i+=2)ss.push(String.fromCharCode(__readUInt16LE(b,i)));returnss.join("")};var__hexlify,___hexlify;__hexlify=___hexlify=functionhexlify_(b,s,l){returnb.slice(s,s+l).map(function(x){return(x<16?"0":"")+x.toString(16)}).join("")};var__utf8,___utf8;__utf8=___utf8=function(b,s,e){varss=[];for(vari=s;i<e;i++)ss.push(String.fromCharCode(__readUInt8(b,i)));returnss.join("")};var__lpstr,___lpstr;__lpstr=___lpstr=functionlpstr_(b,i){varlen=__readUInt32LE(b,i);returnlen>0?__utf8(b,i+4,i+4+len-1):""};var__lpwstr,___lpwstr;__lpwstr=___lpwstr=functionlpwstr_(b,i){varlen=2*__readUInt32LE(b,i);returnlen>0?__utf8(b,i+4,i+4+len-1):""};var__lpp4,___lpp4;__lpp4=___lpp4=functionlpp4_(b,i){varlen=__readUInt32LE(b,i);returnlen>0?__utf16le(b,i+4,i+4+len):""};var__8lpp4,___8lpp4;__8lpp4=___8lpp4=functionlpp4_8(b,i){varlen=__readUInt32LE(b,i);returnlen>0?__utf8(b,i+4,i+4+len):""};var__double,___double;__double=___double=function(b,idx){returnread_double_le(b,idx)};varis_buf=functionis_buf_a(a){returnArray.isArray(a)};if(has_buf){__utf16le=functionutf16le_b(b,s,e){if(!Buffer.isBuffer(b))return___utf16le(b,s,e);returnb.toString("utf16le",s,e)};__hexlify=function(b,s,l){returnBuffer.isBuffer(b)?b.toString("hex",s,s+l):___hexlify(b,s,l)};__lpstr=functionlpstr_b(b,i){if(!Buffer.isBuffer(b))return___lpstr(b,i);varlen=b.readUInt32LE(i);returnlen>0?b.toString("utf8",i+4,i+4+len-1):""};__lpwstr=functionlpwstr_b(b,i){
xmlns:XMLNS.CT,"xmlns:xsd":XMLNS.xsd,"xmlns:xsi":XMLNS.xsi});varCTYPE_DEFAULTS=[["xml","application/xml"],["bin","application/vnd.ms-excel.sheet.binary.macroEnabled.main"],["vml","application/vnd.openxmlformats-officedocument.vmlDrawing"],["bmp","image/bmp"],["png","image/png"],["gif","image/gif"],["emf","image/x-emf"],["wmf","image/x-wmf"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["tif","image/tiff"],["tiff","image/tiff"],["pdf","application/pdf"],["rels",type2ct.rels[0]]].map(function(x){returnwritextag("Default",null,{Extension:x[0],ContentType:x[1]})});functionwrite_ct(ct,opts){varo=[],v;o[o.length]=XML_HEADER;o[o.length]=CTYPE_XML_ROOT;o=o.concat(CTYPE_DEFAULTS);varf1=function(w){if(ct[w]&&ct[w].length>0){v=ct[w][0];o[o.length]=writextag("Override",null,{PartName:(v[0]=="/"?"":"/")+v,ContentType:CT_LIST[w][opts.bookType||"xlsx"]})}};varf2=function(w){(ct[w]||[]).forEach(function(v){o[o.length]=writextag("Override",null,{PartName:(v[0]=="/"?"":"/")+v,ContentType:CT_LIST[w][opts.bookType||"xlsx"]})})};varf3=function(t){(ct[t]||[]).forEach(function(v){o[o.length]=writextag("Override",null,{PartName:(v[0]=="/"?"":"/")+v,ContentType:type2ct[t][0]})})};f1("workbooks");f2("sheets");f2("charts");f3("themes");["strs","styles"].forEach(f1);["coreprops","extprops","custprops"].forEach(f3);f3("vba");f3("comments");f3("drawings");if(o.length>2){o[o.length]="</Types>";o[1]=o[1].replace("/>",">")}returno.join("")}varRELS={WB:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",SHEET:"http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument",HLINK:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",VML:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",VBA:"http://schemas.microsoft.com/office/2006/relationships/vbaProject"};functionget_rels_path(file){varn=file.lastIndexOf("/");returnfile.substr(0,n+1)+"_rels/"+file.substr(n+1)+".rels"}functionparse_rels(data,currentFilePath){if(!data)returndata;if(currentFilePath.charAt(0)!=="/"){currentFilePath="/"+currentFilePath}varrels={};varhash={};(data.match(tagregex)||[]).forEach(function(x){vary=parsexmltag(x);if(y[0]==="<Relationship"){varrel={};rel.Type=y.Type;rel.Target=y.Target;rel.Id=y.Id;rel.TargetMode=y.TargetMode;varcanonictarget=y.TargetMode==="External"?y.Target:resolve_path(y.Target,currentFilePath);rels[canonictarget]=rel;hash[y.Id]=rel}});rels["!id"]=hash;returnrels}XMLNS.RELS="http://schemas.openxmlformats.org/package/2006/relationships";varRELS_ROOT=writextag("Relationships",null,{xmlns:XMLNS.RELS});functionwrite_rels(rels){varo=[XML_HEADER,RELS_ROOT];keys(rels["!id"]).forEach(function(rid){o[o.length]=writextag("Relationship",null,rels["!id"][rid])});if(o.length>2){o[o.length]="</Relationships>";o[1]=o[1].replace("/>",">")}returno.join("")}functionadd_rels(rels,rId,f,type,relobj){if(!relobj)relobj={};if(!rels["!id"])rels["!id"]={};if(rId<0)for(rId=1;rels["!id"]["rId"+rId];++rId){}relobj.Id="rId"+rId;relobj.Type=type;relobj.Target=f;if(relobj.Type==RELS.HLINK)relobj.TargetMode="External";if(rels["!id"][relobj.Id])thrownewError("Cannot rewrite rId "+rId);rels["!id"][relobj.Id]=relobj;rels[("/"+relobj.Target).replace("//","/")]=relobj;returnrId}varCT_ODS="application/vnd.oasis.opendocument.spreadsheet";functionparse_manifest(d,opts){varstr=xlml_normalize(d);varRn;varFEtag;while(Rn=xlmlregex.exec(str))switch(Rn[3]){case"manifest":break;case"file-entry":FEtag=parsexmltag(Rn[0],false);if(FEtag.path=="/"&&FEtag.type!==CT_ODS)thrownewError("This OpenDocument is not a spreadsheet");break;case"encryption-data":;case"algorithm":;case"start-key-generation":;case"key-derivation":thrownewError("Unsupported ODS Encryption");default:if(opts&&opts.WTF)throwRn;}}functionwrite_manifest(manifest,opts){varo=[XML_HEADER];o.push('<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">\n');o.push('<manifest:file-entrymanifest:full-path="/"manifest:version="1.2"manifest:media-type="
if(str.indexOf("\t")>=0||str.indexOf(",")>=0)returndsv_to_sheet_str(str,opts);returnaoa_to_sheet(prn_to_aoa_str(str,opts),opts)}functionprn_to_sheet(d,opts){varstr="",bytes=firstbyte(d,opts);switch(opts.type){case"base64":str=Base64.decode(d);break;case"binary":str=d;break;case"buffer":str=d.toString("binary");break;case"array":str=cc2str(d);break;default:thrownewError("Unrecognized type "+opts.type);}if(bytes[0]==239&&bytes[1]==187&&bytes[2]==191)str=utf8read(str);returnprn_to_sheet_str(str,opts)}functionprn_to_workbook(str,opts){returnsheet_to_workbook(prn_to_sheet(str,opts),opts)}functionsheet_to_prn(ws,opts){varo=[];varr=decode_range(ws["!ref"]),cell;vardense=Array.isArray(ws);for(varR=r.s.r;R<=r.e.r;++R){varoo=[];for(varC=r.s.c;C<=r.e.c;++C){varcoord=encode_cell({r:R,c:C});cell=dense?(ws[R]||[])[C]:ws[coord];if(!cell||cell.v==null){oo.push(" ");continue}varw=(cell.w||(format_cell(cell),cell.w)||"").substr(0,10);while(w.length<10)w+=" ";oo.push(w+(C==0?" ":""))}o.push(oo.join(""))}returno.join("\n")}return{to_workbook:prn_to_workbook,to_sheet:prn_to_sheet,from_sheet:sheet_to_prn}}();functionread_wb_ID(d,opts){varo=opts||{},OLD_WTF=!!o.WTF;o.WTF=true;try{varout=SYLK.to_workbook(d,o);o.WTF=OLD_WTF;returnout}catch(e){o.WTF=OLD_WTF;if(!e.message.match(/SYLK bad record ID/)&&OLD_WTF)throwe;returnPRN.to_workbook(d,opts)}}varWK_=function(){functionlotushopper(data,cb,opts){if(!data)return;prep_blob(data,data.l||0);varEnum=opts.Enum||WK1Enum;while(data.l<data.length){varRT=data.read_shift(2);varR=Enum[RT]||Enum[255];varlength=data.read_shift(2);vartgt=data.l+length;vard=R.f(data,length,opts);data.l=tgt;if(cb(d,R.n,RT))return}}functionlotus_to_workbook(d,opts){switch(opts.type){case"base64":returnlotus_to_workbook_buf(s2a(Base64.decode(d)),opts);case"binary":returnlotus_to_workbook_buf(s2a(d),opts);case"buffer":;case"array":returnlotus_to_workbook_buf(d,opts);}throw"Unsupported type "+opts.type}functionlotus_to_workbook_buf(d,opts){if(!d)returnd;varo=opts||{};if(DENSE!=null&&o.dense==null)o.dense=DENSE;vars=o.dense?[]:{},n="Sheet1",sidx=0;varsheets={},snames=[n];varrefguess={s:{r:0,c:0},e:{r:0,c:0}};if(d[2]==2)o.Enum=WK1Enum;elseif(d[2]==26)o.Enum=WK3Enum;elseif(d[2]==14){o.Enum=WK3Enum;o.qpro=true;d.l=0}elsethrownewError("Unrecognized LOTUS BOF "+d[2]);lotushopper(d,function(val,Rn,RT){if(d[2]==2)switch(RT){case0:o.vers=val;if(val>=4096)o.qpro=true;break;case6:refguess=val;break;case15:if(!o.qpro)val[1].v=val[1].v.substr(1);case13:;case14:;case16:;case51:if(RT==14&&(val[2]&112)==112&&(val[2]&15)>1&&(val[2]&15)<15){val[1].z=o.dateNF||SSF._table[14];if(o.cellDates){val[1].t="d";val[1].v=numdate(val[1].v)}}if(o.dense){if(!s[val[0].r])s[val[0].r]=[];s[val[0].r][val[0].c]=val[1]}elses[encode_cell(val[0])]=val[1];break;}elseswitch(RT){case22:val[1].v=val[1].v.substr(1);case23:;case24:;case25:;case37:;case39:;case40:if(val[3]>sidx){s["!ref"]=encode_range(refguess);sheets[n]=s;s=o.dense?[]:{};refguess={s:{r:0,c:0},e:{r:0,c:0}};sidx=val[3];n="Sheet"+(sidx+1);snames.push(n)}s[encode_cell(val[0])]=val[1];if(refguess.e.c<val[0].c)refguess.e.c=val[0].c;if(refguess.e.r<val[0].r)refguess.e.r=val[0].r;break;default:break;}},o);s["!ref"]=encode_range(refguess);sheets[n]=s;return{SheetNames:snames,Sheets:sheets}}functionparse_RANGE(blob,length){varo={s:{c:0,r:0},e:{c:0,r:0}};o.s.c=blob.read_shift(2);o.s.r=blob.read_shift(2);o.e.c=blob.read_shift(2);o.e.r=blob.read_shift(2);if(o.s.c==65535)o.s.c=o.e.c=o.s.r=o.e.r=0;returno}functionparse_cell(blob,length,opts){varo=[{c:0,r:0},{t:"n",v:0},0];if(opts.qpro&&opts.vers!=20768){o[0].c=blob.read_shift(1);blob.l++;o[0].r=blob.read_shift(2);blob.l+=2}else{o[2]=blob.read_shift(1);o[0].c=blob.read_shift(2);o[0].r=blob.read_shift(2)}returno}functionparse_LABEL(blob,length,opts){vartgt=blob.l+length;varo=parse_cell(blob,length,opts);o[1].t="s";if(opts.vers==20768){blob.l++;varlen=blob.read_shift(1);o[1].v=blob.read_shift(len,"utf8");returno}if(opts.qpro)blob.l++;o[1].v=blob.read_shift(tgt-blob.l,"cstr");returno}functionpa
p={t:val[2]};switch(val[2]){case"n":p.v=val[1];break;case"s":sstr=strs[val[1]];p.v=sstr.t;p.r=sstr.r;break;case"b":p.v=val[1]?true:false;break;case"e":p.v=val[1];if(opts.cellText!==false)p.w=BErr[p.v];break;case"str":p.t="s";p.v=utf8read(val[1]);break;}if(cf=styles.CellXf[val[0].iStyleRef])safe_format(p,cf.ifmt,null,opts,themes,styles);C=val[0].c;if(opts.dense){if(!s[R])s[R]=[];s[R][C]=p}elses[encode_col(C)+rr]=p;if(opts.cellFormula){af=false;for(ai=0;ai<array_formulae.length;++ai){varaii=array_formulae[ai];if(row.r>=aii[0].s.r&&row.r<=aii[0].e.r)if(C>=aii[0].s.c&&C<=aii[0].e.c){p.F=encode_range(aii[0]);af=true}}if(!af&&val.length>3)p.f=val[3]}if(refguess.s.r>row.r)refguess.s.r=row.r;if(refguess.s.c>C)refguess.s.c=C;if(refguess.e.r<row.r)refguess.e.r=row.r;if(refguess.e.c<C)refguess.e.c=C;if(opts.cellDates&&cf&&p.t=="n"&&SSF.is_date(SSF._table[cf.ifmt])){var_d=SSF.parse_date_code(p.v);if(_d){p.t="d";p.v=newDate(_d.y,_d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u)}}break;case1:if(!opts.sheetStubs)break;p={t:"z",v:undefined};C=val[0].c;if(opts.dense){if(!s[R])s[R]=[];s[R][C]=p}elses[encode_col(C)+rr]=p;if(refguess.s.r>row.r)refguess.s.r=row.r;if(refguess.s.c>C)refguess.s.c=C;if(refguess.e.r<row.r)refguess.e.r=row.r;if(refguess.e.c<C)refguess.e.c=C;break;case176:mergecells.push(val);break;case494:varrel=rels["!id"][val.relId];if(rel){val.Target=rel.Target;if(val.loc)val.Target+="#"+val.loc;val.Rel=rel}for(R=val.rfx.s.r;R<=val.rfx.e.r;++R)for(C=val.rfx.s.c;C<=val.rfx.e.c;++C){if(opts.dense){if(!s[R])s[R]=[];if(!s[R][C])s[R][C]={t:"z",v:undefined};s[R][C].l=val}else{addr=encode_cell({c:C,r:R});if(!s[addr])s[addr]={t:"z",v:undefined};s[addr].l=val}}break;case426:if(!opts.cellFormula)break;array_formulae.push(val);cell=opts.dense?s[R][C]:s[encode_col(C)+rr];cell.f=stringify_formula(val[1],refguess,{r:row.r,c:C},supbooks,opts);cell.F=encode_range(val[0]);break;case427:if(!opts.cellFormula)break;shared_formulae[encode_cell(val[0].s)]=val[1];cell=opts.dense?s[R][C]:s[encode_col(C)+rr];cell.f=stringify_formula(val[1],refguess,{r:row.r,c:C},supbooks,opts);break;case60:if(!opts.cellStyles)break;while(val.e>=val.s){colinfo[val.e--]={width:val.w/256,hidden:!!(val.flags&1)};if(!seencol){seencol=true;find_mdw_colw(val.w/256)}process_col(colinfo[val.e+1])}break;case161:s["!autofilter"]={ref:encode_range(val)};break;case476:s["!margins"]=val;break;case175:;case644:;case625:;case562:;case396:;case1112:;case1146:;case471:;case1050:;case649:;case1105:;case49:;case589:;case607:;case564:;case1055:;case168:;case174:;case1180:;case499:;case64:;case1053:;case550:;case171:;case167:;case1177:;case169:;case1181:;case551:;case552:;case661:;case639:;case478:;case151:;case537:;case477:;case536:;case1103:;case680:;case1104:;case1024:;case152:;case663:;case535:;case678:;case504:;case1043:;case428:;case170:;case50:;case2070:;case485:;case1045:;case147:break;case35:pass=true;break;case36:pass=false;break;case37:break;case38:break;default:if((R_n||"").indexOf("Begin")>0){}elseif((R_n||"").indexOf("End")>0){}elseif(!pass||opts.WTF)thrownewError("Unexpected record "+RT+" "+R_n);}},opts);deleteopts.supbooks;deleteopts["!row"];if(!s["!ref"]&&(refguess.s.r<2e6||ref&&(ref.e.r>0||ref.e.c>0||ref.s.r>0||ref.s.c>0)))s["!ref"]=encode_range(ref||refguess);if(opts.sheetRows&&s["!ref"]){vartmpref=safe_decode_range(s["!ref"]);if(opts.sheetRows<+tmpref.e.r){tmpref.e.r=opts.sheetRows-1;if(tmpref.e.r>refguess.e.r)tmpref.e.r=refguess.e.r;if(tmpref.e.r<tmpref.s.r)tmpref.s.r=tmpref.e.r;if(tmpref.e.c>refguess.e.c)tmpref.e.c=refguess.e.c;if(tmpref.e.c<tmpref.s.c)tmpref.s.c=tmpref.e.c;s["!fullref"]=s["!ref"];s["!ref"]=encode_range(tmpref)}}if(mergecells.length>0)s["!merges"]=mergecells;if(colinfo.length>0)s["!cols"]=colinfo;if(rowinfo.length>0)s["!rows"]=rowinfo;returns}functionwrite_ws_bin_cell(ba,cell,R,C,opts,ws){if(cell.v===undefined)return"";varvv="";varolddate=null;switch(cell.t){case"b":vv=cell.v?"1":"0";break;case"d":cell.z=cell.z||SSF._table[14];olddate=cell.v;cell.v=datenum(cell.v);cell.t="n";break;case"
mR=parseInt(ctag["number-matrix-rows-spanned"],10)||0;mC=parseInt(ctag["number-matrix-columns-spanned"],10)||0;mrange={s:{r:R,c:C},e:{r:R+mR-1,c:C+mC-1}};q.F=encode_range(mrange);arrayf.push([mrange,q.F])}if(ctag.formula)q.f=ods_to_csf_formula(ctag.formula);elsefor(i=0;i<arrayf.length;++i)if(R>=arrayf[i][0].s.r&&R<=arrayf[i][0].e.r)if(C>=arrayf[i][0].s.c&&C<=arrayf[i][0].e.c)q.F=arrayf[i][1]}if(ctag["number-columns-spanned"]||ctag["number-rows-spanned"]){mR=parseInt(ctag["number-rows-spanned"],10)||0;mC=parseInt(ctag["number-columns-spanned"],10)||0;mrange={s:{r:R,c:C},e:{r:R+mR-1,c:C+mC-1}};merges.push(mrange)}if(ctag["number-columns-repeated"])rept=parseInt(ctag["number-columns-repeated"],10);switch(q.t){case"boolean":q.t="b";q.v=parsexmlbool(ctag["boolean-value"]);break;case"float":q.t="n";q.v=parseFloat(ctag.value);break;case"percentage":q.t="n";q.v=parseFloat(ctag.value);break;case"currency":q.t="n";q.v=parseFloat(ctag.value);break;case"date":q.t="d";q.v=parseDate(ctag["date-value"]);if(!opts.cellDates){q.t="n";q.v=datenum(q.v)}q.z="m/d/yy";break;case"time":q.t="n";q.v=parse_isodur(ctag["time-value"])/86400;break;case"number":q.t="n";q.v=parseFloat(ctag["数据数值"]);break;default:if(q.t==="string"||q.t==="text"||!q.t){q.t="s";if(ctag["string-value"]!=null)textp=unescapexml(ctag["string-value"])}elsethrownewError("Unsupported value type "+q.t);}}else{isstub=false;if(q.t==="s"){q.v=textp||"";isstub=textpidx==0}if(comments.length>0){q.c=comments;comments=[]}if(textp&&opts.cellText!==false)q.w=textp;if(!isstub||opts.sheetStubs){if(!(opts.sheetRows&&opts.sheetRows<R)){if(opts.dense){if(!ws[R])ws[R]=[];ws[R][C]=q;while(--rept>0)ws[R][++C]=dup(q)}else{ws[encode_cell({r:R,c:C})]=q;while(--rept>0)ws[encode_cell({r:R,c:++C})]=dup(q)}if(range.e.c<=C)range.e.c=C}}else{C+=rept;rept=0}q={};textp=""}break;case"document":;case"document-content":;case"电子表格文档":;case"spreadsheet":;case"主体":;case"scripts":;case"styles":;case"font-face-decls":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp}elseif(Rn[0].charAt(Rn[0].length-2)!=="/")state.push([Rn[3],true]);break;case"annotation":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp;comment.t=textp;comment.a=creator;comments.push(comment)}elseif(Rn[0].charAt(Rn[0].length-2)!=="/"){state.push([Rn[3],false])}creator="";creatoridx=0;textp="";textpidx=0;break;case"creator":if(Rn[1]==="/"){creator=str.slice(creatoridx,Rn.index)}elsecreatoridx=Rn.index+Rn[0].length;break;case"meta":;case"元数据":;case"settings":;case"config-item-set":;case"config-item-map-indexed":;case"config-item-map-entry":;case"config-item-map-named":;case"shapes":;case"frame":;case"text-box":;case"image":;case"data-pilot-tables":;case"list-style":;case"form":;case"dde-links":;case"event-listeners":if(Rn[1]==="/"){if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp}elseif(Rn[0].charAt(Rn[0].length-2)!=="/")state.push([Rn[3],false]);textp="";textpidx=0;break;case"scientific-number":break;case"currency-symbol":break;case"currency-style":break;case"number-style":;case"percentage-style":;case"date-style":;case"time-style":if(Rn[1]==="/"){number_format_map[NFtag.name]=NF;if((tmp=state.pop())[0]!==Rn[3])throw"Bad state: "+tmp}elseif(Rn[0].charAt(Rn[0].length-2)!=="/"){NF="";NFtag=parsexmltag(Rn[0],false);state.push([Rn[3],true])}break;case"script":break;case"libraries":break;case"automatic-styles":break;case"master-styles":break;case"default-style":;case"page-layout":break;case"style":break;case"map":break;case"font-face":break;case"paragraph-properties":break;case"table-properties":break;case"table-column-properties":break;case"table-row-properties":break;case"table-cell-properties":break;case"number":switch(state[state.length-1][0]){case"time-style":;case"date-style":tag=parsexmltag(Rn[0],false);NF+=number_formats[Rn[3]][tag.style==="long"?1:0];break;}break;case"fraction":break;case"day":;case"month":;case"year":;case"era":;case"day-of-week":;case"week-of-year":;case"quarter":;case"hours":;case"minutes":;case"seconds":;case"am-pm":switch(state[state.len
hdr[C]=C-r.s.c;break;case2:hdr[C]=cols[C];break;case3:hdr[C]=o.header[C-r.s.c];break;default:if(val==null)continue;vv=v=format_cell(val,null,o);counter=0;for(CC=0;CC<hdr.length;++CC)if(hdr[CC]==vv)vv=v+"_"+++counter;hdr[C]=vv;}}varrow=header===1?[]:{};for(R=r.s.r+offset;R<=r.e.r;++R){rr=encode_row(R);isempty=true;if(header===1)row=[];else{row={};if(Object.defineProperty)try{Object.defineProperty(row,"__rowNum__",{value:R,enumerable:false})}catch(e){row.__rowNum__=R}elserow.__rowNum__=R}if(!dense||sheet[R])for(C=r.s.c;C<=r.e.c;++C){val=dense?sheet[R][C]:sheet[cols[C]+rr];if(val===undefined||val.t===undefined){if(defval===undefined)continue;if(hdr[C]!=null){row[hdr[C]]=defval;isempty=false}continue}v=val.v;switch(val.t){case"z":if(v==null)break;continue;case"e":continue;case"s":;case"d":;case"b":;case"n":break;default:thrownewError("unrecognized type "+val.t);}if(hdr[C]!=null){if(v==null){if(defval!==undefined)row[hdr[C]]=defval;elseif(raw&&v===null)row[hdr[C]]=null;elsecontinue}else{row[hdr[C]]=raw?v:format_cell(val,v,o)}isempty=false}}if(isempty===false||(header===1?o.blankrows!==false:!!o.blankrows))out[outi++]=row}out.length=outi;returnout}varqreg=/"/g;functionmake_csv_row(sheet,r,R,cols,fs,rs,FS,o){varisempty=true;varrow="",txt="",rr=encode_row(R);for(varC=r.s.c;C<=r.e.c;++C){varval=o.dense?(sheet[R]||[])[C]:sheet[cols[C]+rr];if(val==null)txt="";elseif(val.v!=null){isempty=false;txt=""+format_cell(val,null,o);for(vari=0,cc=0;i!==txt.length;++i)if((cc=txt.charCodeAt(i))===fs||cc===rs||cc===34){txt='"'+txt.replace(qreg,'""')+'"';break}if(txt=="ID")txt='"ID"'}elseif(val.f!=null&&!val.F){isempty=false;txt="="+val.f;if(txt.indexOf(",")>=0)txt='"'+txt.replace(qreg,'""')+'"'}elsetxt="";row+=(C===r.s.c?"":FS)+txt}if(o.blankrows===false&&isempty)returnnull;returnrow}functionsheet_to_csv(sheet,opts){varout=[];varo=opts==null?{}:opts;if(sheet==null||sheet["!ref"]==null)return"";varr=safe_decode_range(sheet["!ref"]);varFS=o.FS!==undefined?o.FS:",",fs=FS.charCodeAt(0);varRS=o.RS!==undefined?o.RS:"\n",rs=RS.charCodeAt(0);varendregex=newRegExp((FS=="|"?"\\|":FS)+"+$");varrow="",cols=[];o.dense=Array.isArray(sheet);for(varC=r.s.c;C<=r.e.c;++C)cols[C]=encode_col(C);for(varR=r.s.r;R<=r.e.r;++R){row=make_csv_row(sheet,r,R,cols,fs,rs,FS,o);if(row==null){continue}if(o.strip)row=row.replace(endregex,"");out.push(row+RS)}deleteo.dense;returnout.join("")}functionsheet_to_txt(sheet,opts){if(!opts)opts={};opts.FS="\t";opts.RS="\n";vars=sheet_to_csv(sheet,opts);if(typeofcptable=="undefined")returns;varo=cptable.utils.encode(1200,s);return"ÿþ"+o}functionsheet_to_formulae(sheet){vary="",x,val="";if(sheet==null||sheet["!ref"]==null)return[];varr=safe_decode_range(sheet["!ref"]),rr="",cols=[],C;varcmds=newArray((r.e.r-r.s.r+1)*(r.e.c-r.s.c+1));vari=0;vardense=Array.isArray(sheet);for(C=r.s.c;C<=r.e.c;++C)cols[C]=encode_col(C);for(varR=r.s.r;R<=r.e.r;++R){rr=encode_row(R);for(C=r.s.c;C<=r.e.c;++C){y=cols[C]+rr;x=dense?(sheet[R]||[])[C]:sheet[y];val="";if(x===undefined)continue;elseif(x.F!=null){y=x.F;if(!x.f)continue;val=x.f;if(y.indexOf(":")==-1)y=y+":"+y}if(x.f!=null)val=x.f;elseif(x.t=="z")continue;elseif(x.t=="n"&&x.v!=null)val=""+x.v;elseif(x.t=="b")val=x.v?"TRUE":"FALSE";elseif(x.w!==undefined)val="'"+x.w;elseif(x.v===undefined)continue;elseif(x.t=="s")val="'"+x.v;elseval=""+x.v;cmds[i++]=y+"="+val}}cmds.length=i;returncmds}functionjson_to_sheet(js,opts){varo=opts||{};varws={};varcell;varrange={s:{c:0,r:0},e:{c:0,r:js.length}};varhdr=o.header||[],C=0;for(varR=0;R!=js.length;++R){Object.keys(js[R]).filter(function(x){returnjs[R].hasOwnProperty(x)}).forEach(function(k){if((C=hdr.indexOf(k))==-1)hdr[C=hdr.length]=k;varv=js[R][k];vart="z";varz="";if(typeofv=="number")t="n";elseif(typeofv=="boolean")t="b";elseif(typeofv=="string")t="s";elseif(vinstanceofDate){t="d";if(!o.cellDates){t="n";v=datenum(v)}z=o.dateNF||SSF._table[14]}ws[encode_cell({c:C,r:R+1})]=cell={t:t,v:v};if(z)cell.z=z})}range.e.c=hdr.length-1;for(C=0;C<hdr.length;++C)ws[encode_col(C)+"1"]={t:"s",v:hdr[C]}