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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying an Excel file in a webpage

Status
Not open for further replies.

FatalExceptionError

Technical User
Apr 10, 2001
100
0
0
US
Im basically trying to clean up a stone age way of reading old excel files. Im making the web page user friendly. This is my first web project. I have the page setup, now i need to display the actual files.
The following code should display a table and items from an excel file. But it isnt working right. The tutorial i got this code from did not label what each part does so im going off guesses. Can some one tell me what each part does and how i can get this to work right.

Code:
<%
Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment;filename=\\Fmsweb\ExcelReports\CallTakerReport\CallTakerReport_01-07-2002.xls.xls&quot;
Response.ContentType = &quot;application/vnd.ms-excel&quot;

Dim dlogin, dtotal, dfrom, dto

dlogin = Request.Form(&quot;login&quot;)
dtotal = Request.Form(&quot;total&quot;)
dfrom = Request.Form(&quot;from&quot;)
dto = Request.Form(&quot;to&quot;)

%>
<table width=&quot;90%&quot; border=&quot;2&quot; bordercolor=&quot;green&quot;>
<tr>
<th width=&quot;40%&quot;><b>Login Name</b></th>
<th width=&quot;20%&quot;><b></b>Total Jobs</th>
<th width=&quot;20%&quot;><b></b>From</th>
<th width=&quot;20%&quot;><b></b>To</th>
</tr>
<tr>
<th width=&quot;40%&quot;><b>%=login%</b></th>
<th width=&quot;20%&quot;><b></b>%=total%</th>
<th width=&quot;20%&quot;><b></b>%=from%</th>
<th width=&quot;20%&quot;><b></b>%=to%</th>
</tr>
<tr>

</tr>
If cats always land on their feet
and Toast always lands buttered side up
What happens if you tape toast, buttered side up on a cat's back??????
 
Have you tried it without the AddHeader line?

I've just run this on mine and it worked:

<%
Response.Expires = 0
Response.ContentType = &quot;application/vnd.ms-excel&quot;
%>
<html>
<head>
</head>
<body>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;>
<tr>
<td>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;>
<tr>
<th align=&quot;left&quot;>Region</th>
<th align=&quot;left&quot;>Account Code</th>
<th align=&quot;right&quot;>Ordered</th>
<th align=&quot;right&quot;>Receipted</th>
<th align=&quot;right&quot;>Invoiced</th>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
 
My issue wasn't the table it was the data from the spread sheet not being displayed. I don't know what im doing really as i have yet to find a detailed knowledge base for ASP and ActiveX functions. If cats always land on their feet
and Toast always lands buttered side up
What happens if you tape toast, buttered side up on a cat's back??????
 
Sorry for the misunderstanding. Could an ODBC connection to the excel files be used so you could access the data in the excel similar to the way you would access a database?

As for what each part does:

Response.AddHeader adds a http header to the HTML page and I'm not sure on how the one you got works.

Response.ContentType indicates to IE that the page is an xls file. It will then prompt for download or open from current location before loading.

The &quot;dim&quot; line defines some variables and the following lines assign values to the variables the web form values that have been posted to the page.

Looking at the html table, no values would be outputted as:

%=login%

should probably be

<%=dlogin%>

Simon
 
For some reason my inetpub directory wont let me save stuff(craptacular implementation of security). Is there any other way to run asp If cats always land on their feet
and Toast always lands buttered side up
What happens if you tape toast, buttered side up on a cat's back??????
 
Are you having problems saving asp files you are creating to the inetpub folder?

Simon
 
No troubles, I just can't do it w2k won't allow me. I think the admins disabled write access to that folder. They do stupid stuff like that. They think people will mess stuff up and they absolutely hate doing work. Its an issue I will have to work out with managers cause its plain silly to do this to an IT&S department. If cats always land on their feet
and Toast always lands buttered side up
What happens if you tape toast, buttered side up on a cat's back??????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top