把table导出为EXCEL的问题
RT
使用 Response.ContentType = "application/vnd.ms-excel" 通过客户端安装的excel把网页中的内容导出为EXCEL。。现在可以导出为excel,但是有些问题,我要导出成excel的table是用从数据库中取出的值得到的table ,每次导出之前会从前一个页面发送两个日期到导出页面,然后根据两个日期来取得数据库中对应的两个日期之间的数据组成table,然后导出为EXCEL,,,,从查询分析器中运行根据日期变量组成的sql语句可以正确的得出要用的数据,但是在导出excel的时候却总是把数据库中的所有数据都导出了,,请大家帮忙看看原因,谢谢!
代码如下:
*************************************
<%
kaishi=trim(request("kaishi"))
jieshu=trim(request("jieshu"))
sql="select * from dinggou where (1=1)"
if kaishi<>"" and jieshu<>"" then
sql=sql&" and (subtime between '"&kaishi&" 00:00:00' and '"&jieshu&" 23:59:59')"
end if
sql=sql&" order by id asc"
'response.write(sql)
'response.End()
set rs=conn.execute(sql)
%>
<%
response.Clear()
Response.ContentType = "application/vnd.ms-excel"
%>
<table width="114%" border="0">
<tr>
<td colspan="10" align="center">订 单 下载</td>
</tr>
<tr>
<td width="12%" align="center">日期</td>
<td width="9%" align="center">客户姓名</td>
<td width="10%" align="center">性别</td>
<td width="11%" align="center">订购数量</td>
<td width="11%" align="center">固定电话</td>
<td width="7%" align="center">手机</td>
<td width="9%" align="center">收货地址</td>
<td width="8%" align="center">邮编</td>
<td width="10%" align="center">发货方式</td>
<td width="13%" align="center">其他要求</td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td width="12%" align="center"><%=rs("subtime")%></td>
<td width="9%" align="center"><%=rs("username")%></td>
<td width="10%" align="center"><% if clng(rs("usersex"))=0 then%>男<%else%>女<%end if%></td>
<td width="11%" align="center"><%=rs("shuliang")%></td>
<td width="11%" align="center"><%=rs("phone")%></td>
<td width="7%" align="center"><%=rs("mobile")%></td>
<td width="9%" align="center"><%=rs("address")%></td>
<td width="8%" align="center"><%=rs("postcode")%></td>
<td width="10%" align="center"><%=rs("fahuo")%></td>
<td width="13%" align="center"><%=rs("message")%></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
*************************************************************