日期:2014-05-17  浏览次数:21059 次

ASP导出excel问题,各位请帮忙,谢谢!
<form name="form1" method="post" action="srqfexcel.asp">
<input name="select_date" type="hidden" onfocus="javascript:ShowCalendar(this.id)" id="select_date"/>
<input type="submit" name="Submit" value="保存excel">
</form>

srqfexcel.asp如下:
Response.ContentType="application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment;filename="111.xls"

select_date=request.form("select_date")  
set conn=Server.CreateObject("ADODB.Connection")  
conn.open "","",""
set rs=conn.Execute("select * from bj_sr_qf where tj_date='"+select_date+"'")

if rs.eof and rs.bof then  
Response.Write"<div align=center><br>无数据</div>"  
else  
%>  
<TABLE cellSpacing=0 cellPadding=0 width="66%" border=1>  
。。。。。。

为何保存出来的excel都无数据,select_date这个条件没有传递过来吗?应该怎么写啊?新手在此请教各位,谢谢!!!

------解决方案--------------------
1 select_date=request.form("select_date")
你可以调试是否已接收到"select_date"
在IF 前 加上
Response.Write ("select * from bj_sr_qf where tj_date='"+select_date+"'")
进行查看
2 打开方式 不对 应指明打开方式 不要用默认
我的习惯用法
Set rs = Server.CreateObject("ADODB.Recordset")
 rs.ActiveConnection = MM_GW_STRING
 rs.Source =sSQL 
 rs.CursorType = 0
 rs.CursorLocation = 2
 rs.LockType = 1
 rs.Open()



------解决方案--------------------
探讨
参考:
<%Option Explicit
Class ExcelGen
Private objSpreadsheet
Private iColOffset

Private iRowOffset
Sub Class_Initialize()
Set objSpreadsheet = Server.CreateObject("OWC.Spreadsheet")
iR……