Render HTML doc as Excel

Discussion in 'ASP General' started by Alien2_51, Mar 14, 2005.

  1. Alien2_51

    Alien2_51 Guest

    This is a simple report that is supposed to render as an Excel document, for
    some reason it's not anymore, not sure why, I think it's related to
    permissions, we recently added a domain user as the anonymous user for the
    site, everyone has permissions to the virtual directory where the asp page is
    executed.... Can someone give an idea as to why this is not working...?

    Here's the error message I'm getting, from Excel:
    Microsoft Excel cannot access the file 'http://BLAHBLAH.ASP?queryparams'
    There are several possible reasons
    * The file name or path does not exist
    * The file you are trying to open is being used by another program.


    Here's the ASP code...

    <%@ LANGUAGE="VBSCRIPT"%>
    <%
    option explicit
    Response.Expires = 0
    Response.ContentType = "application/vnd.ms-excel"
    %>

    <!--#include virtual="/Include/odbvbs.asp"-->

    <%
    dim sSQL, anon, begdate, enddate, sortby, oRS

    call ConnInit(cINTERNET)

    anon = Request("ADDRESSED")
    if anon = "Anonymous" then
    anon = "true"
    end if

    begdate = Request("BEGINDATE")
    enddate = Request("ENDDATE")
    sortby = Request("SORTBY")

    if sortby = "Date" then
    sortby = "request_date"
    end if

    sSQL = "Select * "_
    & "from requests (nolock) "_
    & "where (request_date) >= '" +begdate+ "' AND (request_date) <= '"
    +enddate+ "' "
    if anon = "true" then
    sSQL = sSQL + "AND (email) = 'blank' "
    else
    sSQL = sSQL + "AND (email) <> 'blank' "
    end if

    sSQL = sSQL + "ORDER BY " + sortby

    'response.write(sSQL)
    set oRS = obINTERNET.Execute(sSQL)

    call QueueRS(oRS)

    if not oRS.EOF then
    %>

    <html>
    <table border=2>
    <tr>
    <td><b>Request Date</b></td>
    <td><b>Email</b></td>
    <td><b>Name</b></td>
    <td><b>Product</b></td>
    </tr>
    <% Do While Not oRS.EOF %>
    <tr>
    <td><% = oRS("request_date")%></td>
    <td><% = oRS("email")%></td>
    <td><% = oRS("name")%></td>
    <td><% = oRS("product")%></td>
    </tr>

    <%
    oRS.MoveNext
    Loop
    %>
    <%
    end if
    %>
    <%
    oRS.Close
    obCC
    %>
    </html>
     
    Alien2_51, Mar 14, 2005
    #1
    1. Advertising

  2. Alien2_51

    Alien2_51 Guest

    I commented the ContentType declaration out and found it somebody removed the
    database... The nerve of some people...;)

    "Alien2_51" wrote:

    > This is a simple report that is supposed to render as an Excel document, for
    > some reason it's not anymore, not sure why, I think it's related to
    > permissions, we recently added a domain user as the anonymous user for the
    > site, everyone has permissions to the virtual directory where the asp page is
    > executed.... Can someone give an idea as to why this is not working...?
    >
    > Here's the error message I'm getting, from Excel:
    > Microsoft Excel cannot access the file 'http://BLAHBLAH.ASP?queryparams'
    > There are several possible reasons
    > * The file name or path does not exist
    > * The file you are trying to open is being used by another program.
    >
    >
    > Here's the ASP code...
    >
    > <%@ LANGUAGE="VBSCRIPT"%>
    > <%
    > option explicit
    > Response.Expires = 0
    > Response.ContentType = "application/vnd.ms-excel"
    > %>
    >
    > <!--#include virtual="/Include/odbvbs.asp"-->
    >
    > <%
    > dim sSQL, anon, begdate, enddate, sortby, oRS
    >
    > call ConnInit(cINTERNET)
    >
    > anon = Request("ADDRESSED")
    > if anon = "Anonymous" then
    > anon = "true"
    > end if
    >
    > begdate = Request("BEGINDATE")
    > enddate = Request("ENDDATE")
    > sortby = Request("SORTBY")
    >
    > if sortby = "Date" then
    > sortby = "request_date"
    > end if
    >
    > sSQL = "Select * "_
    > & "from requests (nolock) "_
    > & "where (request_date) >= '" +begdate+ "' AND (request_date) <= '"
    > +enddate+ "' "
    > if anon = "true" then
    > sSQL = sSQL + "AND (email) = 'blank' "
    > else
    > sSQL = sSQL + "AND (email) <> 'blank' "
    > end if
    >
    > sSQL = sSQL + "ORDER BY " + sortby
    >
    > 'response.write(sSQL)
    > set oRS = obINTERNET.Execute(sSQL)
    >
    > call QueueRS(oRS)
    >
    > if not oRS.EOF then
    > %>
    >
    > <html>
    > <table border=2>
    > <tr>
    > <td><b>Request Date</b></td>
    > <td><b>Email</b></td>
    > <td><b>Name</b></td>
    > <td><b>Product</b></td>
    > </tr>
    > <% Do While Not oRS.EOF %>
    > <tr>
    > <td><% = oRS("request_date")%></td>
    > <td><% = oRS("email")%></td>
    > <td><% = oRS("name")%></td>
    > <td><% = oRS("product")%></td>
    > </tr>
    >
    > <%
    > oRS.MoveNext
    > Loop
    > %>
    > <%
    > end if
    > %>
    > <%
    > oRS.Close
    > obCC
    > %>
    > </html>
     
    Alien2_51, Mar 14, 2005
    #2
    1. Advertising

  3. Alien2_51

    Bullschmidt Guest

    <<
    I commented the ContentType declaration out and found it somebody
    removed the database... The nerve of some people...;)
    >>


    Thanks for letting everyone know what the answer was! :)

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Bullschmidt, Mar 15, 2005
    #3
    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. John Wallace
    Replies:
    0
    Views:
    483
    John Wallace
    Jul 22, 2003
  2. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,091
    Lau Lei Cheong
    May 15, 2004
  3. Matt
    Replies:
    3
    Views:
    530
    Tor Iver Wilhelmsen
    Sep 17, 2004
  4. Q. John Chen

    Render to Excel - only one excel instance

    Q. John Chen, Aug 28, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    212
    Q. John Chen
    Aug 28, 2006
  5. Glenn Gillen
    Replies:
    0
    Views:
    287
    Glenn Gillen
    Nov 17, 2006
Loading...

Share This Page