if((size&3)>0)blob.l+=4-(size&3)&3;returnbytes}functionparse_ClipboardData(blob){varo={};o.Size=blob.read_shift(4);blob.l+=o.Size;returno}functionparse_VtVector(blob,cb){}functionparse_TypedPropertyValue(blob,type,_opts){vart=blob.read_shift(2),ret,opts=_opts||{};blob.l+=2;if(type!==VT_VARIANT)if(t!==type&&VT_CUSTOM.indexOf(type)===-1)thrownewError("Expected type "+type+" saw "+t);switch(type===VT_VARIANT?t:type){case2:ret=blob.read_shift(2,"i");if(!opts.raw)blob.l+=2;returnret;case3:ret=blob.read_shift(4,"i");returnret;case11:returnblob.read_shift(4)!==0;case19:ret=blob.read_shift(4);returnret;case30:returnparse_lpstr(blob,t,4).replace(chr0,"");case31:returnparse_lpwstr(blob);case64:returnparse_FILETIME(blob);case65:returnparse_BLOB(blob);case71:returnparse_ClipboardData(blob);case80:returnparse_VtString(blob,t,!opts.raw&&4).replace(chr0,"");case81:returnparse_VtUnalignedString(blob,t,4).replace(chr0,"");case4108:returnparse_VtVecHeadingPair(blob);case4126:returnparse_VtVecUnalignedLpstr(blob);default:thrownewError("TypedPropertyValue unrecognized type "+type+" "+t);}}functionparse_PropertySet(blob,PIDSI){varstart_addr=blob.l;varsize=blob.read_shift(4);varNumProps=blob.read_shift(4);varProps=[],i=0;varCodePage=0;varDictionary=-1,DictObj={};for(i=0;i!=NumProps;++i){varPropID=blob.read_shift(4);varOffset=blob.read_shift(4);Props[i]=[PropID,Offset+start_addr]}varPropH={};for(i=0;i!=NumProps;++i){if(blob.l!==Props[i][1]){varfail=true;if(i>0&&PIDSI)switch(PIDSI[Props[i-1][0]].t){case2:if(blob.l+2===Props[i][1]){blob.l+=2;fail=false}break;case80:if(blob.l<=Props[i][1]){blob.l=Props[i][1];fail=false}break;case4108:if(blob.l<=Props[i][1]){blob.l=Props[i][1];fail=false}break;}if(!PIDSI&&blob.l<=Props[i][1]){fail=false;blob.l=Props[i][1]}if(fail)thrownewError("Read Error: Expected address "+Props[i][1]+" at "+blob.l+" :"+i)}if(PIDSI){varpiddsi=PIDSI[Props[i][0]];PropH[piddsi.n]=parse_TypedPropertyValue(blob,piddsi.t,{raw:true});if(piddsi.p==="version")PropH[piddsi.n]=String(PropH[piddsi.n]>>16)+"."+String(PropH[piddsi.n]&65535);if(piddsi.n=="CodePage")switch(PropH[piddsi.n]){case0:PropH[piddsi.n]=1252;case874:;case932:;case936:;case949:;case950:;case1250:;case1251:;case1253:;case1254:;case1255:;case1256:;case1257:;case1258:;case1e4:;case1200:;case1201:;case1252:;case65e3:;case-536:;case65001:;case-535:set_cp(CodePage=PropH[piddsi.n]);break;default:thrownewError("Unsupported CodePage: "+PropH[piddsi.n]);}}else{if(Props[i][0]===1){CodePage=PropH.CodePage=parse_TypedPropertyValue(blob,VT_I2);set_cp(CodePage);if(Dictionary!==-1){varoldpos=blob.l;blob.l=Props[Dictionary][1];DictObj=parse_dictionary(blob,CodePage);blob.l=oldpos}}elseif(Props[i][0]===0){if(CodePage===0){Dictionary=i;blob.l=Props[i+1][1];continue}DictObj=parse_dictionary(blob,CodePage)}else{varname=DictObj[Props[i][0]];varval;switch(blob[blob.l]){case65:blob.l+=4;val=parse_BLOB(blob);break;case30:blob.l+=4;val=parse_VtString(blob,blob[blob.l-4]);break;case31:blob.l+=4;val=parse_VtString(blob,blob[blob.l-4]);break;case3:blob.l+=4;val=blob.read_shift(4,"i");break;case19:blob.l+=4;val=blob.read_shift(4);break;case5:blob.l+=4;val=blob.read_shift(8,"f");break;case11:blob.l+=4;val=parsebool(blob,4);break;case64:blob.l+=4;val=parseDate(parse_FILETIME(blob));break;default:thrownewError("unparsed value: "+blob[blob.l]);}PropH[name]=val}}}blob.l=start_addr+size;returnPropH}functionparse_PropertySetStream(file,PIDSI){varblob=file.content;prep_blob(blob,0);varNumSets,FMTID0,FMTID1,Offset0,Offset1=0;blob.chk("feff","Byte Order: ");varvers=blob.read_shift(2);varSystemIdentifier=blob.read_shift(4);blob.chk(CFB.utils.consts.HEADER_CLSID,"CLSID: ");NumSets=blob.read_shift(4);if(NumSets!==1&&NumSets!==2)thrownewError("Unrecognized #Sets: "+NumSets);FMTID0=blob.read_shift(16);Offset0=blob.read_shift(4);if(NumSets===1&&Offset0!==blob.l)thrownewError("Length mismatch: "+Offset0+" !== "+blob.l);elseif(NumSets===2){FMTID1=blob.read_shift(16);Offset1=blob.read_shift(4)}varPSet0=parse_PropertyS
varparse_Surf=parsenoop;varparse_RadarArea=parsenoop;varparse_AxisParent=parsenoop;varparse_LegendException=parsenoop;varparse_SerToCrt=parsenoop;varparse_AxesUsed=parsenoop;varparse_SBaseRef=parsenoop;varparse_SerParent=parsenoop;varparse_SerAuxTrend=parsenoop;varparse_IFmtRecord=parsenoop;varparse_Pos=parsenoop;varparse_AlRuns=parsenoop;varparse_BRAI=parsenoop;varparse_SerAuxErrBar=parsenoop;varparse_SerFmt=parsenoop;varparse_Chart3DBarShape=parsenoop;varparse_Fbi=parsenoop;varparse_BopPop=parsenoop;varparse_AxcExt=parsenoop;varparse_Dat=parsenoop;varparse_PlotGrowth=parsenoop;varparse_SIIndex=parsenoop;varparse_GelFrame=parsenoop;varparse_BopPopCustom=parsenoop;varparse_Fbi2=parsenoop;functionparse_ImData(blob,length,opts){vartgt=blob.l+length;varcf=blob.read_shift(2);varenv=blob.read_shift(2);varlcb=blob.read_shift(4);varo={fmt:cf,env:env,len:lcb,data:blob.slice(blob.l,blob.l+lcb)};blob.l+=lcb;returno}functionparse_BIFF5String(blob){varlen=blob.read_shift(1);returnblob.read_shift(len,"sbcs-cont")}functionparse_BIFF2STR(blob,length,opts){varcell=parse_XLSCell(blob,6);++blob.l;varstr=parse_XLUnicodeString2(blob,length-7,opts);cell.t="str";cell.val=str;returncell}functionparse_BIFF2NUM(blob,length,opts){varcell=parse_XLSCell(blob,6);++blob.l;varnum=parse_Xnum(blob,8);cell.t="n";cell.val=num;returncell}functionparse_BIFF2INT(blob,length){varcell=parse_XLSCell(blob,6);++blob.l;varnum=blob.read_shift(2);cell.t="n";cell.val=num;returncell}functionparse_BIFF2STRING(blob,length){varcch=blob.read_shift(1);if(cch===0){blob.l++;return""}returnblob.read_shift(cch,"sbcs-cont")}functionparse_BIFF2FONTXTRA(blob,length){blob.l+=6;blob.l+=2;blob.l+=1;blob.l+=3;blob.l+=1;blob.l+=length-13}functionparse_RString(blob,length,opts){varend=blob.l+length;varcell=parse_XLSCell(blob,6);varcch=blob.read_shift(2);varstr=parse_XLUnicodeStringNoCch(blob,cch,opts);blob.l=end;cell.t="str";cell.val=str;returncell}varDBF=function(){vardbf_codepage_map={1:437,2:850,3:1252,4:1e4,100:852,101:866,102:865,103:861,104:895,105:620,106:737,107:857,120:950,121:949,122:936,123:932,124:874,125:1255,126:1256,150:10007,151:10029,152:10006,200:1250,201:1251,202:1254,203:1253,0:20127,8:865,9:437,10:850,11:437,13:437,14:850,15:437,16:850,17:437,18:850,19:932,20:850,21:437,22:850,23:865,24:437,25:437,26:850,27:437,28:863,29:850,31:852,34:852,35:852,36:860,37:850,38:866,55:850,64:852,77:936,78:949,79:950,80:874,87:1252,88:1252,89:1252,255:16969};functiondbf_to_aoa(buf,opts){varout=[];vard=new_raw_buf(1);switch(opts.type){case"base64":d=s2a(Base64.decode(buf));break;case"binary":d=s2a(buf);break;case"buffer":;case"array":d=buf;break;}prep_blob(d,0);varft=d.read_shift(1);varmemo=false;varvfp=false;switch(ft){case2:;case3:break;case48:vfp=true;memo=true;break;case49:vfp=true;break;case131:memo=true;break;case139:memo=true;break;case245:memo=true;break;default:thrownewError("DBF Unsupported Version: "+ft.toString(16));}varfiledate=newDate,nrow=0,fpos=0;if(ft==2)nrow=d.read_shift(2);filedate=newDate(d.read_shift(1)+1900,d.read_shift(1)-1,d.read_shift(1));if(ft!=2)nrow=d.read_shift(4);if(ft!=2)fpos=d.read_shift(2);varrlen=d.read_shift(2);varflags=0,current_cp=1252;if(ft!=2){d.l+=16;flags=d.read_shift(1);if(d[d.l]!==0)current_cp=dbf_codepage_map[d[d.l]];d.l+=1;d.l+=2}varfields=[],field={};varhend=fpos-10-(vfp?264:0);while(ft==2?d.l<d.length&&d[d.l]!=13:d.l<hend){field={};field.name=cptable.utils.decode(current_cp,d.slice(d.l,d.l+10)).replace(/[\u0000\r\n].*$/g,"");d.l+=11;field.type=String.fromCharCode(d.read_shift(1));if(ft!=2)field.offset=d.read_shift(4);field.len=d.read_shift(1);if(ft==2)field.offset=d.read_shift(2);field.dec=d.read_shift(1);if(field.name.length)fields.push(field);if(ft!=2)d.l+=14;switch(field.type){case"C":break;case"D":break;case"F":break;case"I":break;case"L":break;case"M":break;case"N":break;case"T":break;case"Y":break;case"0":break;case"+":break;case"@":break;default:thrownewError("Unknown Field Type: "+field.type);}}if(d[d.l]!==13)d.l=fpos-1;elseif(ft==2)d.l=521;if(f
;}thrownewError("ECMA-376 Encryped file unrecognized Version: "+vers.Minor)}functionparse_EncInfoStd(blob,vers){varflags=blob.read_shift(4);if((flags&63)!=36)thrownewError("EncryptionInfo mismatch");varsz=blob.read_shift(4);vartgt=blob.l+sz;varhdr=parse_EncryptionHeader(blob,sz);varverifier=parse_EncryptionVerifier(blob,blob.length-blob.l);return{t:"Std",h:hdr,v:verifier}}functionparse_EncInfoExt(blob,vers){thrownewError("File is password-protected: ECMA-376 Extensible")}functionparse_EncInfoAgl(blob,vers){thrownewError("File is password-protected: ECMA-376 Agile")}functionparse_RC4CryptoHeader(blob,length){varo={};varvers=o.EncryptionVersionInfo=parse_CRYPTOVersion(blob,4);length-=4;if(vers.Minor!=2)throw"unrecognized minor version code: "+vers.Minor;if(vers.Major>4||vers.Major<2)throw"unrecognized major version code: "+vers.Major;o.Flags=blob.read_shift(4);length-=4;varsz=blob.read_shift(4);length-=4;o.EncryptionHeader=parse_EncryptionHeader(blob,sz);length-=sz;o.EncryptionVerifier=parse_EncryptionVerifier(blob,length);returno}functionparse_RC4Header(blob,length){varo={};varvers=o.EncryptionVersionInfo=parse_CRYPTOVersion(blob,4);length-=4;if(vers.Major!=1||vers.Minor!=1)throw"unrecognized version code "+vers.Major+" : "+vers.Minor;o.Salt=blob.read_shift(16);o.EncryptedVerifier=blob.read_shift(16);o.EncryptedVerifierHash=blob.read_shift(16);returno}functioncrypto_CreatePasswordVerifier_Method1(Password){varVerifier=0,PasswordArray;varPasswordDecoded=_JS2ANSI(Password);varlen=PasswordDecoded.length+1,i,PasswordByte;varIntermediate1,Intermediate2,Intermediate3;PasswordArray=new_raw_buf(len);PasswordArray[0]=PasswordDecoded.length;for(i=1;i!=len;++i)PasswordArray[i]=PasswordDecoded[i-1];for(i=len-1;i>=0;--i){PasswordByte=PasswordArray[i];Intermediate1=(Verifier&16384)===0?0:1;Intermediate2=Verifier<<1&32767;Intermediate3=Intermediate1|Intermediate2;Verifier=Intermediate3^PasswordByte}returnVerifier^52811}varcrypto_CreateXorArray_Method1=function(){varPadArray=[187,255,255,186,255,255,185,128,0,190,15,0,191,15,0];varInitialCode=[57840,7439,52380,33984,4364,3600,61902,12606,6258,57657,54287,34041,10252,43370,20163];varXorMatrix=[44796,19929,39858,10053,20106,40212,10761,31585,63170,64933,60267,50935,40399,11199,17763,35526,1453,2906,5812,11624,23248,885,1770,3540,7080,14160,28320,56640,55369,41139,20807,41614,21821,43642,17621,28485,56970,44341,19019,38038,14605,29210,60195,50791,40175,10751,21502,43004,24537,18387,36774,3949,7898,15796,31592,63184,47201,24803,49606,37805,14203,28406,56812,17824,35648,1697,3394,6788,13576,27152,43601,17539,35078,557,1114,2228,4456,30388,60776,51953,34243,7079,14158,28316,14128,28256,56512,43425,17251,34502,7597,13105,26210,52420,35241,883,1766,3532,4129,8258,16516,33032,4657,9314,18628];varRor=function(Byte){return(Byte/2|Byte*128)&255};varXorRor=function(byte1,byte2){returnRor(byte1^byte2)};varCreateXorKey_Method1=function(Password){varXorKey=InitialCode[Password.length-1];varCurrentElement=104;for(vari=Password.length-1;i>=0;--i){varChar=Password[i];for(varj=0;j!=7;++j){if(Char&64)XorKey^=XorMatrix[CurrentElement];Char*=2;--CurrentElement}}returnXorKey};returnfunction(password){varPassword=_JS2ANSI(password);varXorKey=CreateXorKey_Method1(Password);varIndex=Password.length;varObfuscationArray=new_raw_buf(16);for(vari=0;i!=16;++i)ObfuscationArray[i]=0;varTemp,PasswordLastChar,PadIndex;if((Index&1)===1){Temp=XorKey>>8;ObfuscationArray[Index]=XorRor(PadArray[0],Temp);--Index;Temp=XorKey&255;PasswordLastChar=Password[Password.length-1];ObfuscationArray[Index]=XorRor(PasswordLastChar,Temp)}while(Index>0){--Index;Temp=XorKey>>8;ObfuscationArray[Index]=XorRor(Password[Index],Temp);--Index;Temp=XorKey&255;ObfuscationArray[Index]=XorRor(Password[Index],Temp)}Index=15;PadIndex=15-Password.length;while(PadIndex>0){Temp=XorKey>>8;ObfuscationArray[Index]=XorRor(PadArray[PadIndex],Temp);--Index;--PadIndex;Temp=XorKey&255;ObfuscationArray[Index]=XorRor(Password[Index],Temp);--Index;--PadIndex}returnObfuscationArray}}();varcrypto_DecryptData_Method1=
if(write_names){o[o.length]="<definedNames>";if(wb.Workbook&&wb.Workbook.Names)wb.Workbook.Names.forEach(function(n){vard={name:n.Name};if(n.Comment)d.comment=n.Comment;if(n.Sheet!=null)d.localSheetId=""+n.Sheet;if(!n.Ref)return;o[o.length]=writextag("definedName",String(n.Ref),d)});o[o.length]="</definedNames>"}if(o.length>2){o[o.length]="</workbook>";o[1]=o[1].replace("/>",">")}returno.join("")}functionparse_BrtBundleSh(data,length){varz={};z.Hidden=data.read_shift(4);z.iTabID=data.read_shift(4);z.strRelID=parse_RelID(data,length-8);z.name=parse_XLWideString(data);returnz}functionwrite_BrtBundleSh(data,o){if(!o)o=new_buf(127);o.write_shift(4,data.Hidden);o.write_shift(4,data.iTabID);write_RelID(data.strRelID,o);write_XLWideString(data.name.substr(0,31),o);returno.length>o.l?o.slice(0,o.l):o}functionparse_BrtWbProp(data,length){data.read_shift(4);vardwThemeVersion=data.read_shift(4);varstrName=length>8?parse_XLWideString(data):"";return[dwThemeVersion,strName]}functionwrite_BrtWbProp(data,o){if(!o)o=new_buf(72);o.write_shift(4,0);o.write_shift(4,0);write_XLSBCodeName("ThisWorkbook",o);returno.slice(0,o.l)}functionparse_BrtFRTArchID$(data,length){varo={};data.read_shift(4);o.ArchID=data.read_shift(4);data.l+=length-8;returno}functionparse_BrtName(data,length,opts){varend=data.l+length;varflags=data.read_shift(4);varchKey=data.read_shift(1);varitab=data.read_shift(4);varname=parse_XLNameWideString(data);varformula=parse_XLSBNameParsedFormula(data,0,opts);varcomment=parse_XLNullableWideString(data);data.l=end;varout={Name:name,Ptg:formula,Comment:comment};if(itab<268435455)out.Sheet=itab;returnout}functionparse_wb_bin(data,opts){varwb={AppVersion:{},WBProps:{},WBView:[],Sheets:[],CalcPr:{},xmlns:""};varpass=false,z;if(!opts)opts={};opts.biff=12;varNames=[];varsupbooks=[];supbooks.SheetNames=[];recordhopper(data,functionhopper_wb(val,R_n,RT){switch(RT){case156:supbooks.SheetNames.push(val.name);wb.Sheets.push(val);break;case39:val.Ref=stringify_formula(val.Ptg,null,null,supbooks,opts);deleteval.Ptg;Names.push(val);break;case1036:break;case2071:;case534:;case677:;case158:;case157:;case610:;case2050:;case362:;case155:;case548:;case676:;case128:;case665:;case2128:;case2125:;case549:;case2053:;case361:;case596:;case667:;case355:;case358:;case357:;case2076:;case2075:;case2082:;case397:;case154:;case153:;case1117:;case553:;case2091:break;case35:pass=true;break;case36:pass=false;break;case37:break;case38:break;case16: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);parse_wb_defaults(wb);wb.Names=Names;returnwb}functionwrite_BUNDLESHS(ba,wb,opts){write_record(ba,"BrtBeginBundleShs");for(varidx=0;idx!=wb.SheetNames.length;++idx){varviz=wb.Workbook&&wb.Workbook.Sheets&&wb.Workbook.Sheets[idx]&&wb.Workbook.Sheets[idx].Hidden||0;vard={Hidden:viz,iTabID:idx+1,strRelID:"rId"+(idx+1),name:wb.SheetNames[idx]};write_record(ba,"BrtBundleSh",write_BrtBundleSh(d))}write_record(ba,"BrtEndBundleShs")}functionwrite_BrtFileVersion(data,o){if(!o)o=new_buf(127);for(vari=0;i!=4;++i)o.write_shift(4,0);write_XLWideString("SheetJS",o);write_XLWideString(XLSX.version,o);write_XLWideString(XLSX.version,o);write_XLWideString("7262",o);o.length=o.l;returno.length>o.l?o.slice(0,o.l):o}functionwrite_BrtBookView(idx,o){if(!o)o=new_buf(29);o.write_shift(-4,0);o.write_shift(-4,460);o.write_shift(4,28800);o.write_shift(4,17600);o.write_shift(4,500);o.write_shift(4,idx);o.write_shift(4,idx);varflags=120;o.write_shift(1,flags);returno.length>o.l?o.slice(0,o.l):o}functionwrite_BOOKVIEWS(ba,wb,opts){if(!wb.Workbook||!wb.Workbook.Sheets)return;varsheets=wb.Workbook.Sheets;vari=0,vistab=-1,hidden=-1;for(;i<sheets.length;++i){if(!sheets[i]||!sheets[i].Hidden&&vistab==-1)vistab=i;elseif(sheets[i].Hidden==1&&hidden==-1)hidden=i}if(hidden>vistab)return;write_record(ba,"BrtBeginBookViews");write_record(ba,"BrtBookView",write_BrtBookView(vistab));write_record(ba,"BrtEndBoo