Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Render HTML doc as Excel

Reply
Thread Tools

Render HTML doc as Excel

 
 
Alien2_51
Guest
Posts: n/a
 
      03-14-2005
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>
 
Reply With Quote
 
 
 
 
Alien2_51
Guest
Posts: n/a
 
      03-14-2005
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>

 
Reply With Quote
 
 
 
 
Bullschmidt
Guest
Posts: n/a
 
      03-15-2005
<<
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing rails render method outside of view / Decorating render Glenn Gillen Ruby 0 11-17-2006 02:30 PM
Render to Excel - only one excel instance Q. John Chen ASP .Net Datagrid Control 0 08-28-2006 04:06 AM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
Page.Render do not render complete page Lau Lei Cheong ASP .Net 1 05-15-2004 04:10 AM
Parsing MS Word client doc into server-side doc... John Wallace ASP .Net 0 07-22-2003 06:49 PM



Advertisments