asp classic - Download Excel not working properly in ASP -
i new asp.i need write script download excel in asp.i tried downloading entire page content need download table database.
here code:
<%@language="vbscript"%> <form name="form1" id="form1" method="post"> <input type="hidden" name="action" value="sel"> <table> <tr> <td><input type="submit" name="submit" id="submit" value="download excel"></td> </tr> </table> hello world <% action = request.form("action") if action="sel" response.contenttype = "application/octet-stream" response.contenttype = "application/vnd.ms-excel" set conn = server.createobject("adodb.connection") conn.open "provider=sqloledb;data source=10.1.1.1;uid=sa;pwd=root;database=student" dim conn,rs set rs=server.createobject("adodb.recordset") rs.open "select * studentdetails",conn response.addheader "content-disposition", "attachment; filename=xl_data.xls" %> <table border=1> <tr> <% j = 2 = 0 rs.fields.count - 1 %> <td width="18"><b> <% = rs(i).name %></b></td> <% next %> <td width="42"></td> <td width="53"></td> </tr> <% while not rs.eof %> <tr> <% = 0 rs.fields.count - 1 %> <td valign=top><% = rs(i) %></td> <% next %> </tr> <% rs.movenext j = j + 1 loop rs.close end if %> </table>
in program have included hello world line while downloading downloading also.so please give me suggestions.thanks in advance.
replace
response.contenttype = "application/octet-stream"
with
response.clear
otherwise sending form , table excel
Comments
Post a Comment