Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pdf,word,excell where to start

Status
Not open for further replies.

agoodrich

MIS
Jul 13, 2004
37
US
I have a webpage that pulls records from a database and displays them in the browser window.

I would like to have an option to download a similar page in adobe pdf format or word or excel format... I don't know where to begin. Can someone point me in the wright direction?

Thanks

-Aaron
 
its simple....
on the top of your page:
put something like this to get the report in the excel format....
<%
Response.ContentType = "application/vnd.ms-excel"
%>

similarly use other formats....

-L
 
Or if you use <A HREF>, then following code may help:

a href="<%=filename in any format%>" target="_blank" onClick="window.open('<%=filename in any format%>','','width=950,height=600, top=10,left=10,resizable=yes,toolbar=no,titlebar=no,location=no,directories=0,addressbar=no,scrollbars=yes,status=no,menubar=yes');return false;">
 
More Info about the page I'm loading.

mainpage.asp -->
This is a page that opens a database and selects the correct record, then does

<!--#include file="table_template.asp"-->

which is the table from <table> to </table> and it includes <% Response.write (trim(objrs("fields"))) %> that are displayed within the table.

Instead of having it just show up as a web page I would like to make it come up as a pdf.


 
Sorry.. Yes I did Lothario. It gave an error which I did not write down. Where do I put that in the mainpage.asp? Does the server or client have to have any special software to view the page with that. What would I put if I want it to be a pdf?

Thanks
 
When I just add line
<%
Response.ContentType = "application/vnd.ms-excel"
%>
My web browser says it can't download the file that is mainpage.asp.
 
add that line on the top of the page in whic you are trying to display your recordset...

-L
 
Lothario

I get a file download screen. I click open. I get this error.

Internet Explorer cannot download mainpage.asp from localhost.

Internet Explorer was not able to open this Internet side. The requested site is either unavailable or cannot be found. Please try again later.

This is my code:

<%@ Language=VBScript %>
<% OPTION EXPLICIT %>
<!--#include virtual="/adovbs.inc"-->
<%

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

Response.CacheControl = "no-cache"

Dim objConn
Set objConn = Server.CreateObject ("ADODB.Connection")
objConn.ConnectionString = "Driver=Microsoft Visual Foxpro Driver; SourceType=DBF; SourceDB=C:\datafolder\"
objConn.Open

Dim objRS
Set objRS=Server.CreateObject ("ADODB.recordset")
Dim strSQL
strSQL="select * FROM phonetable.dbf where phone = '5556248902'"

objRS.Open strSQL, objConn, 3

%>

<html>
<title></title>

<table>
<tr>
<td>
<% Response.write (objrs("phone")) %>

</td>
</tr>

</table>

</body>
</html>

<%

objRS.CLOSE
set objRS = nothing
objConn.CLOSE

%>
 
Try this:

<%@ Language=VBScript %>
<%
Response.ContentType = "application/vnd.ms-excel"
%>
<% OPTION EXPLICIT %>
<!--#include virtual="/adovbs.inc"-->
<%Response.CacheControl = "no-cache"%>
<%
Dim objConn
Set objConn = Server.CreateObject ("ADODB.Connection")
objConn.ConnectionString = "Driver=Microsoft Visual Foxpro Driver; SourceType=DBF; SourceDB=C:\datafolder\"
objConn.Open

Dim objRS
Set objRS=Server.CreateObject ("ADODB.recordset")
Dim strSQL
strSQL="select * FROM phonetable.dbf where phone = '5556248902'"

objRS.Open strSQL, objConn, 3

%>

<html>
<title></title>

<table>
<tr>
<td>
<% Response.write (objrs("phone")) %>

</td>
</tr>

</table>

</body>
</html>

<%

objRS.CLOSE
set objRS = nothing
objConn.CLOSE
%>

-L
 
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/datatransfer/psf/mainpage.asp, line 5
OPTION EXPLICIT
 
try this order..

<%@ Language=VBScript %>
<% OPTION EXPLICIT %>
<%Response.ContentType = "application/vnd.ms-excel"%>

-L
 
I get a file download screen. I click open.

I get the could not downlaod blah blah /psf/mainpage.asp
 
u r getting a file download screen because the asp page is trying to open a excel file and i thought you did not have excel on your machine.

Anyways run the program again and this time save the file and then open it with excel and see if its actually the report u r looking for you.

-L
 
trying to save it give the same error. Do I need to do somthing with permissions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top