}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
cell.t="b";cell.v=true}elseif(s=="FALSE"){cell.t="b";cell.v=false}elseif(!isNaN(v=+s)){cell.t="n";cell.w=s;cell.v=v}elseif(!isNaN(fuzzydate(s).getDate())||_re&&s.match(_re)){cell.z=o.dateNF||SSF._table[14];vark=0;if(_re&&s.match(_re)){s=dateNF_fix(s,o.dateNF,s.match(_re)||[]);k=1}if(o.cellDates){cell.t="d";cell.v=parseDate(s,k)}else{cell.t="n";cell.v=datenum(parseDate(s,k))}cell.w=SSF.format(cell.z,cell.vinstanceofDate?datenum(cell.v):cell.v)}else{cell.t="s";if(s.charAt(0)=='"'&&s.charAt(s.length-1)=='"')s=s.slice(1,-1).replace(/""/g,'"');cell.v=s}if(o.dense){if(!ws[R])ws[R]=[];ws[R][C]=cell}elsews[encode_cell({c:C,r:R})]=cell;start=end+1;if(range.e.c<C)range.e.c=C;if(range.e.r<R)range.e.r=R;if(cc==sepcc)++C;else{C=0;++R}}for(;end<str.length;++end)switch(cc=str.charCodeAt(end)){case34:instr=!instr;break;casesepcc:;case10:;case13:if(!instr)finish_cell();break;default:break;}if(end-start>0)finish_cell();ws["!ref"]=encode_range(range);returnws}functionprn_to_sheet_str(str,opts){if(str.substr(0,4)=="sep=")returndsv_to_sheet_str(str,opts);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(d,opts){returnsheet_to_workbook(prn_to_sheet(d,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
temp_val.f=""+stringify_formula(last_formula.formula,range,last_formula.cell,supbooks,opts)}if(BIFF2Fmt>0)temp_val.z=BIFF2FmtTable[temp_val.ixfe>>8&31];safe_format_xf(temp_val,options,wb.opts.Date1904);addcell(last_formula.cell,temp_val,options);last_formula=null}elsethrownewError("String record expects Formula")}break;case"Array":{array_formulae.push(val);var_arraystart=encode_cell(val[0].s);cc=options.dense?(out[val[0].s.r]||[])[val[0].s.c]:out[_arraystart];if(options.cellFormula&&cc){if(!last_formula)break;if(!_arraystart||!cc)break;cc.f=""+stringify_formula(val[1],range,val[0],supbooks,opts);cc.F=encode_range(val[0])}}break;case"ShrFmla":{if(!cell_valid)break;if(!options.cellFormula)break;if(last_cell){if(!last_formula)break;shared_formulae[encode_cell(last_formula.cell)]=val[0];cc=options.dense?(out[last_formula.cell.r]||[])[last_formula.cell.c]:out[encode_cell(last_formula.cell)];(cc||{}).f=""+stringify_formula(val[0],range,lastcell,supbooks,opts)}}break;case"LabelSst":temp_val=make_cell(sst[val.isst].t,val.ixfe,"s");temp_val.XF=XFs[temp_val.ixfe];if(BIFF2Fmt>0)temp_val.z=BIFF2FmtTable[temp_val.ixfe>>8&31];safe_format_xf(temp_val,options,wb.opts.Date1904);addcell({c:val.c,r:val.r},temp_val,options);break;case"Blank":if(options.sheetStubs){temp_val={ixfe:val.ixfe,XF:XFs[val.ixfe],t:"z"};if(BIFF2Fmt>0)temp_val.z=BIFF2FmtTable[temp_val.ixfe>>8&31];safe_format_xf(temp_val,options,wb.opts.Date1904);addcell({c:val.c,r:val.r},temp_val,options)}break;case"MulBlank":if(options.sheetStubs){for(var_j=val.c;_j<=val.C;++_j){var_ixfe=val.ixfe[_j-val.c];temp_val={ixfe:_ixfe,XF:XFs[_ixfe],t:"z"};if(BIFF2Fmt>0)temp_val.z=BIFF2FmtTable[temp_val.ixfe>>8&31];safe_format_xf(temp_val,options,wb.opts.Date1904);addcell({c:_j,r:val.r},temp_val,options)}}break;case"RString":;case"Label":;case"BIFF2STR":temp_val=make_cell(val.val,val.ixfe,"s");temp_val.XF=XFs[temp_val.ixfe];if(BIFF2Fmt>0)temp_val.z=BIFF2FmtTable[temp_val.ixfe>>8&31];safe_format_xf(temp_val,options,wb.opts.Date1904);addcell({c:val.c,r:val.r},temp_val,options);break;case"Dimensions":{if(file_depth===1)range=val}break;case"SST":{sst=val}break;case"Format":{SSF.load(val[1],val[0])}break;case"BIFF2FORMAT":{BIFF2FmtTable[BIFF2Fmt++]=val;for(varb2idx=0;b2idx<BIFF2Fmt+163;++b2idx)if(SSF._table[b2idx]==val)break;if(b2idx>=163)SSF.load(val,BIFF2Fmt+163)}break;case"MergeCells":mergecells=mergecells.concat(val);break;case"Obj":objects[val.cmo[0]]=opts.lastobj=val;break;case"TxO":opts.lastobj.TxO=val;break;case"ImData":opts.lastobj.ImData=val;break;case"HLink":{for(rngR=val[0].s.r;rngR<=val[0].e.r;++rngR)for(rngC=val[0].s.c;rngC<=val[0].e.c;++rngC){cc=options.dense?(out[rngR]||[])[rngC]:out[encode_cell({c:rngC,r:rngR})];if(cc)cc.l=val[1]}}break;case"HLinkTooltip":{for(rngR=val[0].s.r;rngR<=val[0].e.r;++rngR)for(rngC=val[0].s.c;rngC<=val[0].e.c;++rngC){cc=options.dense?(out[rngR]||[])[rngC]:out[encode_cell({c:rngC,r:rngR})];if(cc)cc.l.Tooltip=val[1]}}break;case"Note":{if(opts.biff<=5&&opts.biff>=2)break;cc=options.dense?(out[val[0].r]||[])[val[0].c]:out[encode_cell(val[0])];varnoteobj=objects[val[2]];if(!cc)break;if(!cc.c)cc.c=[];cmnt={a:val[1],t:noteobj.TxO.t};cc.c.push(cmnt)}break;default:switch(R.n){case"ClrtClient":break;case"XFExt":update_xfext(XFs[val.ixfe],val.ext);break;case"DefColWidth":defwidth=val;break;case"DefaultRowHeight":defheight=val[1];break;case"ColInfo":{if(!opts.cellStyles)break;while(val.e>=val.s){colinfo[val.e--]={width:val.w/256};if(!seencol){seencol=true;find_mdw_colw(val.w/256)}process_col(colinfo[val.e+1])}}break;case"Row":{varrowobj={};if(val.hidden){rowinfo[val.r]=rowobj;rowobj.hidden=true}if(val.hpt){rowinfo[val.r]=rowobj;rowobj.hpt=val.hpt;rowobj.hpx=pt2px(val.hpt)}}break;case"LeftMargin":;case"RightMargin":;case"TopMargin":;case"BottomMargin":if(!out["!margins"])default_margins(out["!margins"]={});out["!margins"][Rn.slice(0,-6).toLowerCase()]=val;break;case"Setup":if(!out["!margins"])default_margins(out["!margins"]={});out["!margins"].header=val.header;out["!margins"].footer=val.footer;break;case"Header":break;case"Footer":break;case"HCenter":brea
returnsheet_to_workbook(parse_dom_table(table,opts),opts)}varparse_content_xml=function(){varparse_text_p=function(text,tag){returnunescapexml(text.replace(/<text:s\/>/g," ").replace(/<[^>]*>/g,""))};varnumber_formats={day:["d","dd"],month:["m","mm"],year:["y","yy"],hours:["h","hh"],minutes:["m","mm"],seconds:["s","ss"],"am-pm":["A/P","AM/PM"],"day-of-week":["ddd","dddd"]};returnfunctionpcx(d,_opts){varopts=_opts||{};if(DENSE!=null&&opts.dense==null)opts.dense=DENSE;varstr=xlml_normalize(d);varstate=[],tmp;vartag;varNFtag={name:""},NF="",pidx=0;varsheetag;varrowtag;varSheets={},SheetNames=[];varws=opts.dense?[]:{};varRn,q;varctag={value:""};vartextp="",textpidx=0,textptag;varR=-1,C=-1,range={s:{r:1e6,c:1e7},e:{r:0,c:0}};varnumber_format_map={};varmerges=[],mrange={},mR=0,mC=0;vararrayf=[];varcomments=[],comment={};varcreator="",creatoridx=0;varrept=1,isstub=false;vari=0;xlmlregex.lastIndex=0;str=str.replace(/<!--([\s\S]*?)-->/gm,"").replace(/<!DOCTYPE[^\[]*\[[^\]]*\]>/gm,"");while(Rn=xlmlregex.exec(str))switch(Rn[3]=Rn[3].replace(/_.*$/,"")){case"table":;case"工作表":if(Rn[1]==="/"){if(range.e.c>=range.s.c&&range.e.r>=range.s.r)ws["!ref"]=encode_range(range);if(merges.length)ws["!merges"]=merges;sheetag.name=utf8read(sheetag["名称"]||sheetag.name);SheetNames.push(sheetag.name);Sheets[sheetag.name]=ws}elseif(Rn[0].charAt(Rn[0].length-2)!=="/"){sheetag=parsexmltag(Rn[0],false);R=C=-1;range.s.r=range.s.c=1e7;range.e.r=range.e.c=0;ws=opts.dense?[]:{};merges=[]}break;case"table-row":;case"行":if(Rn[1]==="/")break;rowtag=parsexmltag(Rn[0],false);if(rowtag["行号"])R=rowtag["行号"]-1;else++R;C=-1;break;case"covered-table-cell":++C;if(opts.sheetStubs){if(opts.dense){if(!ws[R])ws[R]=[];ws[R][C]={t:"z"}}elsews[encode_cell({r:R,c:C})]={t:"z"}}break;case"table-cell":;case"数据":if(Rn[0].charAt(Rn[0].length-2)==="/"){ctag=parsexmltag(Rn[0],false);if(ctag["number-columns-repeated"])C+=parseInt(ctag["number-columns-repeated"],10);else++C}elseif(Rn[1]!=="/"){++C;rept=1;if(C>range.e.c)range.e.c=C;if(R>range.e.r)range.e.r=R;if(C<range.s.c)range.s.c=C;if(R<range.s.r)range.s.r=R;ctag=parsexmltag(Rn[0],false);comments=[];comment={};q={t:ctag["数据类型"]||ctag["value-type"],v:null};if(opts.cellFormula){if(ctag.formula)ctag.formula=unescapexml(ctag.formula);if(ctag["number-matrix-columns-spanned"]&&ctag["number-matrix-rows-spanned"]){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_c
;case"csv":returnwrite_string_type(write_csv_str(wb,o),o);case"dif":returnwrite_string_type(write_dif_str(wb,o),o);case"prn":returnwrite_string_type(write_prn_str(wb,o),o);case"fods":returnwrite_string_type(write_ods(wb,o),o);case"biff2":returnwrite_binary_type(write_biff_buf(wb,o),o);case"xlsx":;case"xlsm":;case"xlsb":;case"ods":returnwrite_zip_type(wb,o);default:thrownewError("Unrecognized bookType |"+o.bookType+"|");}}functionresolve_book_type(o){if(!o.bookType)switch(o.file.slice(o.file.lastIndexOf(".")).toLowerCase()){case".xlsx":o.bookType="xlsx";break;case".xlsm":o.bookType="xlsm";break;case".xlsb":o.bookType="xlsb";break;case".fods":o.bookType="fods";break;case".xlml":o.bookType="xlml";break;case".sylk":o.bookType="sylk";break;case".html":o.bookType="html";break;case".xls":o.bookType="biff2";break;case".xml":o.bookType="xml";break;case".ods":o.bookType="ods";break;case".csv":o.bookType="csv";break;case".txt":o.bookType="txt";break;case".dif":o.bookType="dif";break;case".prn":o.bookType="prn";break;case".slk":o.bookType="sylk";break;case".htm":o.bookType="html";break;}}functionwriteFileSync(wb,filename,opts){varo=opts||{};o.type="file";o.file=filename;resolve_book_type(o);returnwriteSync(wb,o)}functionwriteFileAsync(filename,wb,opts,cb){varo=opts||{};o.type="file";o.file=filename;resolve_book_type(o);o.type="buffer";var_cb=cb;if(!(_cbinstanceofFunction))_cb=opts;return_fs.writeFile(filename,writeSync(wb,o),_cb)}functionsheet_to_json(sheet,opts){if(sheet==null||sheet["!ref"]==null)return[];varval={t:"n",v:0},header=0,offset=1,hdr=[],isempty=true,v=0,vv="";varr={s:{r:0,c:0},e:{r:0,c:0}};varo=opts!=null?opts:{};varraw=o.raw;vardefval=o.defval;varrange=o.range!=null?o.range:sheet["!ref"];if(o.header===1)header=1;elseif(o.header==="A")header=2;elseif(Array.isArray(o.header))header=3;switch(typeofrange){case"string":r=safe_decode_range(range);break;case"number":r=safe_decode_range(sheet["!ref"]);r.s.r=range;break;default:r=range;}if(header>0)offset=0;varrr=encode_row(r.s.r);varcols=newArray(r.e.c-r.s.c+1);varout=newArray(r.e.r-r.s.r-offset+1);varouti=0,counter=0;vardense=Array.isArray(sheet);varR=r.s.r,C=0,CC=0;if(dense&&!sheet[R])sheet[R]=[];for(C=r.s.c;C<=r.e.c;++C){cols[C]=encode_col(C);val=dense?sheet[R][C]:sheet[cols[C]+rr];switch(header){case1: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.blan