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

excel and apache

Status
Not open for further replies.

junkjones

Programmer
Jul 14, 2000
52
GB
I am trying to turn a query into an excel sheet. I've done this a zillion times on an NT server, but today I'm doing it on an apache server for the first time. Is that why it's not working? Is there something I have to do on the server to make it work?
 
No... I've done it on Apache as well.

What, in particular, isn't working? What error (or other results) are you receiving?



-Carl
 
No error - it's just outputting it as a regular page with a regular table for my information.
 
Dumb question: do I have to have MS Office installed on the Apache server? Does it need Excel to create the file, or does the user just need excel to open the file? I'm sure my NT box (that it works fine on) doesn't have excel installed on it, but that could be because NT knows what excel is...
 
Sorry - an update... the server is a Linux server, so it's running OpenOffice, not MS Office.
 
Let's step back a minute.

Are you:
a) trying to run the query and have it display to the user (in the browser) as an Excel spreadsheet/file?

or
b) trying to run the query and then save it to the server's file system as an .xls file (then can then be opened on the server by Excel/OpenOffice/whatever or downloaded)?

I had assumed a)... but now it's sounding more like b)?

If it is a), then, no, what the server has installed (MS Office/OpenOffice/WordPerfect Office) makes no difference... as the handling of the file is actually on the client's machine. They would need MS Office... or, at least the plug-in or control that understands the Excel mimetype.

If it's b), then, yes, obviously whatever system you're trying to view the Excel file on (in this case, it sounds like it's your server??? *see below) would need something that understands an .xls.

The trick with b), however, is writting the .xls. It's not a simple file type... and you'd have to understand a great deal about the file format to actually be able to write one using ColdFusion (if it's even possible). Usually it's better to save yourself the headache and write your data out as a .csv file, which is a simple file type (comma-separated values... about as simple as one could get). Excel can easily import a .csv... though in some cases it isn't as easy as simply double-clicking the file and letting it load... Excel may need a pointer or two to figure out what data types it's looking at.

That being said, * you really shouldn't have OpenOffice running on your server unless it's absolutely necessary. Nothing gobbles up system resources faster than office applications (okay... so maybe Photoshop gobbles them up faster). And you really don't want that sort of drain on the same box that's running a web server (particularly if it's, in turn, running ColdFusion). Better to copy the file (whether it's .xls or .csv) to a local system (not a server) and opening it there.

Just my $0.02,




-Carl
 
The answer is a).... I just want them to be able to view the data as an excel sheet.

The custom tag(s) I normally use on NT are not working here - the page is just displaying as an HTML table instead of an xls form. So could this be a problem on my computer instead of the server?? I do have excel on my computer.
 
Hmmmm... Custom Tags, you say? What custom tags are you calling? There could certainly be something in the custom tag that precludes it from running correctly under Unix/Linux.

Usually, to display a page as an Excel file, all you do is make two calls to ColdFusion methods:
Code:
<cfcontent type=&quot;application/vnd.ms-excel&quot;>
<cfheader name=&quot;Content-Disposition&quot; value=&quot;inline; filename='myFileName.xls';&quot;>

I've found that it's most reliable when you place the calls to these two tags as the two topmost lines on your page, and you don't use
Code:
<html>
,
Code:
<head>
,or
Code:
<body>
(or
Code:
<!DOCTYPE...>
) tags anywhere on the page.

But any standard HTML table will then open as an Excel spreadsheet. If the client is using InternetExplorer, it will usually open directly in the browser using IE's Office ActiveX control. If the client is using Netscape, it will generally launch Excel (if it can find it) and automatically load the file in.



-Carl
 
Thanks for the code... I've been trying variants of this all morning, but yours is the most clear. It still doesn't work, but based on what you said about Netscape, I decided to download it and test it on Netscape. And voila! It works! Which tells me something is wrong with my IE browser. I'm going to go try to find another computer to test it on to see if anyone else is having this problem!

Thanks for your help!!
 
You can try to export the excel as a csv (Comma separated value) file. I believe that Excel takes ownership of that extension when it is installed, so anyone who downloads a csv file who has excel will probably be able to just dbl click on it and excel will open.

That's how I've done it at least, hope that helps.

MG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top