日期:2014-05-17 浏览次数:21292 次
Response.Charset="gb2313" adminarray=session("permission") sqlstr=session("sqlstr") mainkey=request("mainkey") modkey=request("modkey") Set fs=server.CreateObject("scripting.filesystemobject") newname="sales_date_export_"&year(date())&month(date())&day(date())&hour(time())&Minute(time())&second(time())&".xls" filepath="excel\"&newname filename=Server.MapPath(filepath) if fs.FileExists(filename) then fs.DeleteFile(filename) end if set myfile=fs.CreateTextFile(filename,true) selectid=request("selectid") if selectid="" then response.write "<script>alert('Error,Can't found record');self.close();</script>" response.end end if mainkey=mid(mainkey,1,len(mainkey)-1) selectid=mid(selectid,1,len(selectid)-1) sqlstr="select * from salesview where id in ("&selectid&")" set rs=conn.execute (sqlstr,0,1) mainarr=split(mainkey,",") strLine="" for i=0 to ubound(mainarr) sqlstr="select exportname from permissionlist where permissionfield='"&mainarr(i)&"'" set temprs=conn.execute (sqlstr,0,1) if not temprs.eof and not temprs.bof then strline=strline&temprs("exportname")&chr(9) else strline=strline&mainarr(i)&chr(9) end if set temprs=nothing next myfile.writeline strLine do while not rs.eof strline="" for i=0 to ubound(mainarr) if mainarr(i)="pricevar" then tempstr="rsfields=rs(""pricevarchar"")" else tempstr="rsfields=rs("""&mainarr(i)&""")" end if execute tempstr strline=strline&rsfields&chr(9) next myfile.writeline strLine '这里是出错位置的语句。 rs.movenext loop set rs=nothing conn.close set conn=nothing set myfile=nothing Set fs=Nothing if err then response.write "<script>alert('Error,Pls Check your selected"&err.number&"');self.close()</script>" response.end else response.write "<a href='"&filepath&"'>pls,right hit save as to download your export file:"&newname&" </a>" response.end end if