Solved

ASP to show Excel .xls file on the web

Posted on 2000-04-03
4
1,768 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 100 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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