为什么下载按钮不是在点击时候起作用,而是打开页面自动下载啊?
“下载数据”那个按钮,为什么不是点击时候能用啊,而是打开这个页面自动就下载数据了?
<!--#include file="conn.asp" -->
<%
dim i,intPage,page,pre,last,filepath
exec="select * from jbxx order by bh"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
if rs.recordcount>=1 then
rs.PageSize =10
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%><style type="text/css">
<!--
body {
background-color: #E4E4ED;
}
.STYLE1 {font-size: medium}
-->
</style>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="7" bordercolor="#000000" bgcolor="#34A6DC" class="bg"><span class="STYLE1">基本信息 <a href="xb1-1-add.asp" target="_self">添加记录 </a><input name="下载数据" type="button" id="下载数据"
onclick="<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from jbxx "
rs1.open sql1,conn,1,1
Set ExcelApp =CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Add
ExcelBook.WorkSheets(1).cells(1,1).value ="用户表"
ExcelBook.WorkSheets(1).cells(2,1).value = "姓名"
ExcelBook.WorkSheets(1).cells(2,2).value = "职务"
ExcelBook.WorkSheets(1).cells(2,3).value = "出生日期"
ExcelBook.WorkSheets(1).cells(2,4).value = "性别"
cnt =3
do while not rs1.eof
ExcelBook.WorkSheets(1).cells(cnt,1).value = rs1("xm")
ExcelBook.WorkSheets(1).cells(cnt,2).value = rs1("zw")
ExcelBook.WorkSheets(1).cells(cnt,3).value = rs1("csrq")
ExcelBook.WorkSheets(1).cells(cnt,4).value = rs1("xb")
rs1.movenext
cnt = cint(cnt) + 1
loop
Excelbook.SaveAs "d:\yourfile.xls" '这个是数据导出完毕以后在D盘存成文件
ExcelApp.Application.Quit '导出以后退出Excel
Set ExcelApp = Nothing '注销Excel对象
rs1.Close
set rs1 = nothing
%>
" value="保存到EXCEL" />
</span></td>
</tr>
<tr>
<td width="5%" height="29" bordercolor="#000000" class="bg"><div align="center"><strong>序号</strong></div></td>
<td width="10%" bordercolor="#000000" class="bg"><div align="center"><strong>姓名</strong></div></td>
<td width="24%" bordercolor="#000000" class="bg"><div align="center"><strong>职务</strong></div></td>
<td width="9%" bordercolor="#000000" class="bg"><div align="center"><strong>出生日期</strong></div></td>
<td width="6%" bordercolor="#000000" class="bg"><div align="center"><strong>性别</strong></div></td>
</tr>
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%>
<tr bordercolor="#E6F7FB" bgColor=#FFFFFF onMouseOver="javascript:this.bgColor='#8080FF';"onMouseOut="javascript:this.bgColor='#FFFFFF';" >
<td height="29" bordercolor="#000000"><a href="xb1-1-list.asp?id=<%=rs("xh")%>" target="_self"><%=rs("bh")%></a></td>
<td bordercolor="#000000"><%=rs("xm")%></td>
<td bordercolor="#000000"><%=rs("zw")%></td>
<td bordercolor="#000000"><%=rs("csrq")%></td>
<td bordercolor="#000000"><%=rs("xb")%></td>
</tr>
<%
rs.movenext
next
%>
<tr>
<%if rs.pagecount > 0 then%>
<td width="5%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="10%" align="left">当前页0/0</td>
<%end if%>
<td colspan="4" align="right"> <a href="xb1-1.asp?page=1">首页</a>|
<%if pre then%>
<a href="xb1-1.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="xb1-1.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="xb1-1.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="xb1-1.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="xb1-1.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font> </td>
</tr>
</table>
<%else if rs.recordcount=0 then%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="8" bgcolor="#34A6DC"