Show XML as excel sheet
I have a program that creates xml that can be loaded into excel and viewed as a spreadsheet. It is to be viewed as a web page and I set the mime type, no problem. But garbage is output - something is being lost in translation. Any ideas?
# 1 Re: Show XML as excel sheet
You need some style :)
It is to be viewed as a web page and I set the mime type, no problem.
I assume you mean that you set the mime type to HTML for the XML files.
This is a bad idear.
You need an XSL stylesheet, that will transform your XML files to pretty looking HTML which can then be rendered. The XSL transformation can take place at either the client side or the server side.
To run the transformation on the clientside (I don't recommend this for real world use) you need something like this at the head of you XML files
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
This tells the browser to apply the stylesheet.xsl file to the XML file.
To run the transform on the serverside you need to tell your server to do it, how this is done of course depends on the server.
khp at 2007-11-10 3:27:45 >

# 2 Re: Show XML as excel sheet
What I'm doing is setting the mimetype to application/vnd.ms-excel before producing the xml. Your method seems to produce the same result.
Yes, I have figured out the problem is server side. We use an Apache server and it looks like it is not translating before sending it to the web page. Since I know absolutely diddly-squat about Apache I'm basically up the creek without a paddle...
# 3 Re: Show XML as excel sheet
What I'm doing is setting the mimetype to application/vnd.ms-excel before producing the xml.
That probably only works for proper Excel files.
Your method seems to produce the same result.
Absolutly not. My method most definetly works. Assuming of course that you have a proper stylesheet for it (which I would suspect you don't), if you don't have one you would of course have to write one.
Yes, I have figured out the problem is server side. We use an Apache server and it looks like it is not translating before sending it to the web page. Since I know absolutely diddly-squat about Apache I'm basically up the creek without a paddle.
Ehhh ?.
How do you expect apache to translate the file. Do you even have a stylesheet for it ?.
I'am not aware of any apache plugins that will do XSL transforms for you directly (I haven't really looked for it). Blaming apache for your problems seems about as reasonable as blaming it on the network cables between your computer and the server.
You can run XSL transform through php and a number of other ways using apache. I of course run most of my transforms through Cocoon.
khp at 2007-11-10 3:29:44 >

# 4 Re: Show XML as excel sheet
Based on the fact that I have no idea what an Apache server is (just that we use one) I can't answer your question. But apparently we have some sort of AddType thingy in it and what we do is translate from ASCII to EPSIDEC and vice versa.