首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

ASP导出excel有关问题,各位请帮忙,多谢

2012-05-14 
ASP导出excel问题,各位请帮忙,谢谢!form nameform1 methodpost actionsrqfexcel.aspinput nam

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……

热点排行