| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 766 人关注过本帖
标题:导出EXCEL时都是所有数据!不能按搜索的数据导出。
只看楼主 加入收藏
lxb0592
Rank: 1
等 级:新手上路
帖 子:108
专家分:0
注 册:2012-5-28
结帖率:86.67%
收藏
已结贴  问题点数:20 回复次数:3 
导出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%>&nbsp;<%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%>&nbsp;<%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%>&nbsp;<%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>
搜索更多相关主题的帖子: 数据 request keyword 时间段 
2012-07-13 17:32
lxb0592
Rank: 1
等 级:新手上路
帖 子:108
专家分:0
注 册:2012-5-28
收藏
得分:0 
可以单独 对某个下拉框选择 数据导出EXCEL
怎么对2个或3个下拉框 选择的数据同时 选择导出EXCLE
2012-07-13 23:06
netlin
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:24
帖 子:544
专家分:4308
注 册:2012-4-9
收藏
得分:14 
对于这种在查询网页上导出Excel格式的查询结果,用下面的思路,开发效率高,且不易出错:

直接把查询页拷贝成excel_money.asp,把查询页的参数传过来,把网页输出类型改为Excel要求的类型。

做自己喜欢的事!
2012-07-14 06:39
wangzhi8515
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2013-1-12
收藏
得分:0 
楼上的 那具体要怎样改呢!
2013-01-13 16:28
快速回复:导出EXCEL时都是所有数据!不能按搜索的数据导出。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037587 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved