导出EXCEL时都是所有数据!不能按搜索的数据导出。
如图:点击导出EXCEL时导出的EXCLE表格出现了所有数据!不能按搜索的数据导出(只能按工区搜索正常)。比如我只要某个时间段的,或某个类型的数据?怎么改正啊?
1:前台点击 导出excel的代码
导出excel
<a href="excel_money.asp?page=<%=currentpage%>&startdate=<%=nowstartdate%>&enddate=<%=nowenddate%>&type=<%=nowtype%>&bank=<%=nowbank%>&keyword=<%=nowkeyword%>&order1=<%=request("order1")%>&order2=<%=request("order2")%>&order3=<%=request("order3")%>&order4=<%=request("order4")%>&order5=<%=request("order5")%>&order6=<%=request("order6")%>&order7=<%=request("order7")%>&order8=<%=request("order8")%>&order9=<%=request("order9")%>&order10=<%=request("order10")%>&order11=<%=request("order11")%>&order12=<%=request("order12")%>&order13=<%=request("order13")%>&order14=<%=request("order14")%>&order15=<%=request("order15")%>" target="_blank"><img src="../images/excel.jpg" border="0" align="absmiddle" alt="导出Excel表格">
2:excel_money.asp页面 的代码
<!--#include file="../conn2.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<%
nowfilename=replace(replace(replace(now,":","")," ",""),"/","")
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "inline; filename = "&nowfilename&".xls"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
<%
'取得当前页码
currentpage=request("page")
'response.write currentpage
'response.end
if currentpage<1 or currentpage="" then
currentpage="1"
end if
'取得搜索关键字
nowbank=request("bank")
nowkeyword=request("keyword")
if request.Cookies("shiwei_id")="1" or fla88="1" then
sql="select * from bank order by id"
set rs_bank=conn.execute(sql)
else
sql="select * from bank where instr(login,',"&request.Cookies("shiwei_id")&",')>0 order by id"
set rs_bank=conn.execute(sql)
if rs_bank.eof then
nowbank="0"
elseif request("bank")="" then
nowbank=rs_bank("id")
end if
end if
sql="select * from shiwei_money where 1=1"
if nowkeyword<>"" then
sql=sql&" and (id_login like '%"&nowkeyword&"%' or tcz like '%"&nowkeyword&"%' or id_bigclass like '%"&nowkeyword&"%' or type like '%"&nowkeyword&"%' or id_bank like '%"&nowkeyword&"%')"
end if
if nowbank<>"" then
sql=sql&" and id_bank="&nowbank
end if
if request("order1")<>"" then
sql=sql&" order by id_bank "&request("order1")
elseif request("order2")<>"" then
sql=sql&" order by tcz "&request("order2")
elseif request("order3")<>"" then
sql=sql&" order by type "&request("order3")
elseif request("order4")<>"" then
sql=sql&" order by id_bigclass "&request("order4")
elseif request("order5")<>"" then
sql=sql&" order by id_smallclass "&request("order5")
elseif request("order6")<>"" then
sql=sql&" order by id_login "&request("order6")
elseif request("order7")<>"" then
sql=sql&" order by selldate "&request("order7")
elseif request("order8")<>"" then
sql=sql&" order by gztz "&request("order8")
elseif request("order9")<>"" then
sql=sql&" order by gzcl "&request("order9")
elseif request("order10")<>"" then
sql=sql&" order by gzhf "&request("order10")
elseif request("order11")<>"" then
sql=sql&" order by dbdd "&request("order11")
else
sql=sql&" order by id desc"
end if
set rs_shiwei_money =server.createobject("ADODB.RecordSet")
rs_shiwei_money.open sql,conn,1,3
%>
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<th>所属工区</th>
<th>探测站</th>
<th>设备类型</th>
<th>故障大类</th>
<th>故障小类</th>
<th>维修员</th>
<th>故障发生日期</th>
<th>故障通知时间</th>
<th>开始处理时间</th>
<th>故障恢复时间</th>
<th>值班调度</th>
</tr>
<%
i=0
do while rs_shiwei_money.eof=false
i=i+1
%>
<tr class="TD2">
<td align="center"><%
sql="select * from bank where id="&rs_shiwei_money("id_bank")
set rs_bank=conn.execute(sql)
%>
<%if rs_bank.eof=false then%><%=rs_bank("bank")%><%else%> <%end if%></td>
<td align="center"><%=rs_shiwei_money("tcz")%></td>
<td align="center"><%if rs_shiwei_money("type")=0 then%>
THDS<%else%><%if rs_shiwei_money("type")=1 then%>TFDS<%else%><%if rs_shiwei_money("type")=2 then%>TPDS<%else%><%if rs_shiwei_money("type")=3 then%>TADS<%else%><%if rs_shiwei_money("type")=4 then%>AEI<%else%><%if rs_shiwei_money("type")=5 then%>HMIS<%else%><%if rs_shiwei_money("type")=6 then%>电动脱轨器<%else%><%if rs_shiwei_money("type")=7 then%>手持机<%else%><%if rs_shiwei_money("type")=8 then%>智能风表
<%end if%><%end if%><%end if%><%end if%><%end if%><%end if%><%end if%><%end if%><%end if%></td>
<td align="center"><%
sql="select * from money_bigclass where id="&rs_shiwei_money("id_bigclass")
set rs_bigclass=conn.execute(sql)
%>
<%if rs_bigclass.eof=false then%><%=rs_bigclass("bigclass")%><%else%> <%end if%></td>
<td align="center"><%
sql="select * from money_smallclass where id="&rs_shiwei_money("id_smallclass")
set rs_smallclass=conn.execute(sql)
%>
<%if rs_smallclass.eof=false then%><%=rs_smallclass("smallclass")%><%else%> <%end if%></td>
<td align="center"><%
sql="select * from login where id="&rs_shiwei_money("id_login")
set rs_login=conn.execute(sql)
%>
<%if rs_login.eof then%><%=rs_shiwei_money("login")%><%else%><%=rs_login("username")%><%end if%></td>
<td align="center"><%=rs_shiwei_money("selldate")%></td>
<td align="center"><%=left(rs_shiwei_money("gztz"),5)%></td>
<td align="center"><%=left(rs_shiwei_money("gzcl"),5)%></td>
<td align="center"><%=left(rs_shiwei_money("gzhf"),5)%></td>
<td align="center"><%=left(rs_shiwei_money("dbdd"),5)%></td>
</tr>
<%
rs_shiwei_money.movenext
loop
%>
</table>
</body>
</html>