|
CodeAve.com - ASP - Miscellaneous | ||||
|
|
|||||
| Output To MSExcel | |||||
|
|
|||||
<% dim accessdb, cn, rs, sql ' Name of the Accessdb being read accessdb="fidrych" ' Connect to the db with a DSN-less connection cn="DRIVER={Microsoft Access Driver (*.mdb)};" cn=cn & "DBQ=" & server.mappath(accessdb) ' Create a server recordset object Set rs = Server.CreateObject("ADODB.Recordset") ' Select all data from the table the_bird sql = "select * from the_bird " ' Execute the sql rs.Open sql, cn %> <% ' Tells the browser to open excel Response.ContentType = "application/vnd.ms-excel" %> <html> <body> <table BORDER="1" align="center"> <tr> <td>Year</td> <td>Team</td> <td>W</td> <td>L</td> <td>G</td> <td>GS</td> <td>CG</td> <td>IP</td> <td>H</td> <td>BB</td> <td>SO</td> <td>ShO</td> <td>ERA</td> </tr> <% ' Move to the first record rs.movefirst ' Start a loop that will end with the last record do while not rs.eof %> <tr> <td> <%= rs("year") %> </td> <td> <%= rs("team") %> </td> <td> <%= rs("w") %> </td> <td> <%= rs("l") %> </td> <td> <%= rs("g") %> </td> <td> <%= rs("gs") %> </td> <td> <%= rs("cg") %> </td> <td> <%= rs("ip") %> </td> <td> <%= rs("h") %> </td> <td> <%= rs("bb") %> </td> <td> <%= rs("so") %> </td> <td> <%= rs("sho") %> </td> <td> <%= rs("era") %> </td> </tr> <% ' Move to the next record rs.movenext ' Loop back to the do statement loop %> </table> </body> </html> <% ' Close and set the recordset to nothing rs.close set rs=nothing %>
|
|||||
|
|
|||||