?
Solved

ASP to show Excel .xls file on the web

Posted on 2000-04-03
4
Medium Priority
?
1,770 Views
Last Modified: 2008-01-09
I am a newbie to ASP programming.  Can anyone show me a simple script that will read an Excel .xls file in the same directory as the ASP file and show the content on the web?

Maybe simple ASP script with sample xls file ready go would be perfect for me!

Thanks in advance.

So I need NT server to run this or can windows98 personal server can handle it?  Please excuse my ignorance... I am currently running Apache on Linux. Any luck with ASP?  
0
Comment
Question by:yjh123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Expert Comment

by:Flubbadub
ID: 2682168
If your client browser id IE then you don't need any special code to display an XLS!  Just point the browser at the URL of the xls file and Whammo! (nOTE On Navigator you will get an "Open File/Save File" dialog.
0
 

Expert Comment

by:enterume
ID: 2682484
What you mean is read the data from .XLS and view it brower? you want to do sth like database access to .XLS file or try to display only the .XLS file?
0
 

Author Comment

by:yjh123
ID: 2682581
I need to be able to read certain part of excel file and show on the web.  Not as a whole, but a certain fields based on certain criteria. (e.g, date=4/3/00)
I will be embedding this on a table on a webpage.  So downloding or open from the location is not what I had in mind.

Next phase would be getting input from the browser and write it back to the excel file...  I know it is getting complicated, but hope to achieve one at a time...

Thanks for your help.
0
 
LVL 1

Accepted Solution

by:
carled earned 300 total points
ID: 2683141
I've managed to do this - it's a very rough example but it works on IIS4 and personal web server.  The only way I could get it to work was by using named ranges in Excel, which means that each time you add a record you need to change the range to include that record (the Excel help file has info on named ranges).  Someone in this group can probably tell you a way of working around this.

The excel file is this: (hopefully this will reformat on your screen ok)

Property Ref      Address      Office      On sale since      Price
L9912      14 Latimer Close, Narborough, Leicester      Leicester      13-Jan-99      £45,950
L9918      3 Ridley Close, Birstall, Leicester      Leicester      9-Feb-99      £85,000
O2918      14 Trewitt Way, Beasdale, Shelthorpe      Loughborough      9-Dec-98      £55,000
B1102      17 Island Way, Burton-upon-Trent      Burton      4-Mar-99      £19,500
B1103      19 Breeze Way, Burton-upon-Trent      Burton      4-Mar-99      £19,500


The asp code I've used is this:
<html>


<head>
<title>Property List test - Excel link</title>
</head>


<body bgcolor="#CCCCFF">
<H1>Property List</H1>
<p> </p>
<%
' Set Variables
Dim DataSource, OnMenu, Query

'Set up name to call data returned (in this case it's 'DataSource')
Set DataSource =  Server.CreateObject("ADODB.Connection")
Set rsTemp =  Server.CreateObject("ADODB.Recordset")

'Set DSN-less connection (prevents the need for setting up dsn on server)
DSNtemp="DRIVER={Microsoft Excel Driver (*.xls)}; "

'set path to spreadsheet containing data (property.xls)
DSNtemp=dsntemp & "DBQ=" & server.mappath("property.xls")
'this sets the path to look in the current directory - you could give it an absolute path if you wanted, like c:\data\property.xls)


'Set fields you want to return - in this case '*' meaning all
Query = "SELECT * FROM propertylist"

'Open connection
DataSource.Open DSNtemp
rsTemp.open Query,Datasource,3,3

'Set recordset name (to 'OnMenu' in this case)
'Set OnMenu = DataSource.Execute(Query)
howmanyfields=rstemp.fields.count -1

%>
<table width="600" border="1" cellspacing="1" cellpadding="1">
<tr>
<%'Put Headings On The Table of Field Names
for i=0 to howmanyfields %>
<td><b><%=rstemp(i).name %></b></td>
<% next %>
</tr>

<%'Now lets grab all the records
%><tr>
<%do while not rstemp.eof %>
<%for i = 0 to howmanyfields%>
<td><%=rstemp(i)%></td>
<%next
rstemp.movenext%>
</tr>
<%loop %>
</table>
</body>
</html>



Hope this does the trick!

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question