p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   problem exporting to excel (http://p2p.wrox.com/showthread.php?t=44050)

neversummer84 June 15th, 2006 11:53 AM

problem exporting to excel
I'm query an access database, which is working fine displaying as web content. I would like to export the results to excel, and basically just added the lines below to the one displaying to the web

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"

I have the code below, which does not give errors, but produces an empty exel file. the only thing it produces are the table headings and the links Any ideas?

<%@ Language=VBScript %>
<%Option explicit
Dim oRs,oRs2, conn, conn2, connect, strSQL, count, oddeven, bgcolor

set conn=server.CreateObject("ADODB.connection")
set conn2=server.CreateObject("ADODB.connection")

connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("sheep.mdb") & ";Persist Security Info=False"
conn.Open connect
conn2.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("info.mdb") & ";Persist Security

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"

<center>Search Results</center><br>
<table border=1 cellspacing=0 cellpadding=3>
<tr bgcolor="#ADD8E6">
<td nowrap><b>1</b></td>
<td nowrap><b>2</b></td>
<td nowrap><b>3</b></td>



    Set oRs=server.CreateObject("adodb.recordset")

    strSQL = "SELECT DISTINCT * FROM tblInfo WHERE Name= '" & request("name") & "'AND Description = '" &

request("description") & "'AND Location = '" & request("location") & "' "

    oRs.Open strSQL, conn2

    Do while not oRs.EOF

    select case oddeven
    case "1","3","5","7","9"
    bgcolor = "#E8E8E8"

    case else
    bgcolor = "#FFFFFF"
    end select

    Response.Write "<tr bgcolor='" & bgcolor & "'><td nowrap> " & oRs ("Name") & "</td><td nowrap>" & oRs ("Description") & "</td><td nowrap>" & oRs ("Location") & "</td></tr>"


    Set oRs = Nothing


<a href="sheepexcel.asp">[Export to Excel]</a>
<center><a href="sheepquery.asp">[Search for another product]</a> <a href="index.htm">[Home]</a></center>

neversummer84 June 15th, 2006 12:55 PM

i tested with a
Response.Write "<tr><td nowrap>blah</td></tr>"

i can get that to to show up in the Excel except for inside the

Do while not oRs2.EOF


All times are GMT -4. The time now is 07:19 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.