469,323 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Render HTML doc as Excel

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>
Jul 22 '05 #1
2 2921
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>

Jul 22 '05 #2
<<
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!
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by George Ter-Saakov | last post: by
6 posts views Thread by vandalo | last post: by
2 posts views Thread by Andrea Williams | last post: by
1 post views Thread by ad | last post: by
2 posts views Thread by Just Me | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.