Help with creating an excel file from a db

Discussion in 'ASP General' started by Dave, Jan 26, 2004.

  1. Dave

    Dave Guest

    I do not get an error, but I also do not get any data in the excel file. I
    know it is connecting to the db

    <!--#include file="../db.asp"-->
    <%

    Response.ContentType = "application/vnd.ms-excel"
    %>

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <%
    OpenDatabase dbc
    set objrs = server.createobject("ADODB.Recordset")
    SQL = "select * from title"
    Set objrs=dbc.execute(SQL)
    %>
    <TABLE BORDER=1>
    <TR>
    <%
    For i = 0 to objrs.fields.count - 1


    %>
    <TD><% = objrs(i).name %></TD>
    <% next %>
    </TR>
    <%

    while not objrs.eof
    %>
    <TR>
    <% For i = 0 to objrs.fields.count - 1
    %>
    <TD VALIGN=TOP><% = objrs(i) %></TD>
    <% Next %>

    </TR>
    <%
    objrs.MoveNext

    wend

    %>

    <body>

    </body>
    </html>
    Dave, Jan 26, 2004
    #1
    1. Advertising

  2. Dave

    Bob Barrows Guest

    Dave wrote:
    > I do not get an error, but I also do not get any data in the excel
    > file. I know it is connecting to the db
    >
    > <!--#include file="../db.asp"-->
    > <%
    >
    > Response.ContentType = "application/vnd.ms-excel"
    > %>

    If you remove the ContentType line, do you get the expected data in the
    resulting page?

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows, Jan 26, 2004
    #2
    1. Advertising

  3. Dave

    Dave Guest

    crap!!!! Thanks


    "TomB" <> wrote in message
    news:...
    > perhaps the output should be between the <body> </body> tags.
    >
    > "Dave" <> wrote in message
    > news:%...
    > > I do not get an error, but I also do not get any data in the excel file.

    I
    > > know it is connecting to the db
    > >
    > > <!--#include file="../db.asp"-->
    > > <%
    > >
    > > Response.ContentType = "application/vnd.ms-excel"
    > > %>
    > >
    > > <html>
    > > <head>
    > > <title>Untitled Document</title>
    > > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    > > </head>
    > > <%
    > > OpenDatabase dbc
    > > set objrs = server.createobject("ADODB.Recordset")
    > > SQL = "select * from title"
    > > Set objrs=dbc.execute(SQL)
    > > %>
    > > <TABLE BORDER=1>
    > > <TR>
    > > <%
    > > For i = 0 to objrs.fields.count - 1
    > >
    > >
    > > %>
    > > <TD><% = objrs(i).name %></TD>
    > > <% next %>
    > > </TR>
    > > <%
    > >
    > > while not objrs.eof
    > > %>
    > > <TR>
    > > <% For i = 0 to objrs.fields.count - 1
    > > %>
    > > <TD VALIGN=TOP><% = objrs(i) %></TD>
    > > <% Next %>
    > >
    > > </TR>
    > > <%
    > > objrs.MoveNext
    > >
    > > wend
    > >
    > > %>
    > >
    > > <body>
    > >
    > > </body>
    > > </html>
    > >
    > >
    > >

    >
    >
    Dave, Jan 26, 2004
    #3
  4. Dave

    TomB Guest

    perhaps the output should be between the <body> </body> tags.

    "Dave" <> wrote in message
    news:%...
    > I do not get an error, but I also do not get any data in the excel file. I
    > know it is connecting to the db
    >
    > <!--#include file="../db.asp"-->
    > <%
    >
    > Response.ContentType = "application/vnd.ms-excel"
    > %>
    >
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    > </head>
    > <%
    > OpenDatabase dbc
    > set objrs = server.createobject("ADODB.Recordset")
    > SQL = "select * from title"
    > Set objrs=dbc.execute(SQL)
    > %>
    > <TABLE BORDER=1>
    > <TR>
    > <%
    > For i = 0 to objrs.fields.count - 1
    >
    >
    > %>
    > <TD><% = objrs(i).name %></TD>
    > <% next %>
    > </TR>
    > <%
    >
    > while not objrs.eof
    > %>
    > <TR>
    > <% For i = 0 to objrs.fields.count - 1
    > %>
    > <TD VALIGN=TOP><% = objrs(i) %></TD>
    > <% Next %>
    >
    > </TR>
    > <%
    > objrs.MoveNext
    >
    > wend
    >
    > %>
    >
    > <body>
    >
    > </body>
    > </html>
    >
    >
    >
    TomB, Jan 27, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,383
    Carl Prothman [MVP]
    Jan 12, 2005
  2. Anonieko
    Replies:
    2
    Views:
    7,312
    JackStraw73
    Feb 12, 2008
  3. =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=

    Export to Excel (Default File Type - Excel)

    =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    15
    Views:
    17,519
    syed hassan
    May 21, 2009
  4. Replies:
    1
    Views:
    1,794
    extentechjohn
    Nov 21, 2006
  5. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,499
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
Loading...

Share This Page