Re: Open XML in excel with javascript?



On Jan 29, 3:09 pm, JaxDawg <jaxd...@xxxxxxxxx> wrote:
I have a spread*** saved as an XML spread*** so I can manipulate
it easier (and don't need COM). When I'm done, I want to display to
the user. Currently, I'm using simple JavaScript in my PHP file to
display the file when complete:
echo '<script type="text/javascript"> window.open("'.$file_nm.'")</
script>';

Since the file is .XML, which defaults to the browser to open - the
above code will display the XML as raw XML (text) in a new browser
window - rather than opening with excel.
In the XML is:
<?mso-application progid="Excel.***"?>
So, if the XML is saved locally - then opened, it will default to
Excel to open.

Is there anyway for the script to indicate that excel should be used
to open, rather than the (default) for XML - which is the browser?

Thanks in advance.

Not much to do with javascript but a content type of "application/
vnd.ms-excel" set by the server should do the trick.

A simple python cgi script on server: printxls.pyg

#!/python25/python
import sys
print "Content-type: application/vnd.ms-excel"
print
for line in file("/helloworld.html"): print line

An Excel file saved as extremely simple HTML: helloworld.html

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40";>
<head>
<meta http-equiv=Content-Type content="text/html;
charset=windows-1252">
<meta name=ProgId content=Excel.***>
<meta name=Generator content="Microsoft Excel 10">
</head>
<body><table><col><tr><td>Hello World!</td></tr></table></body>
</html>

The browser directed to Apache web server: "http://localhost:8080/cgi-
bin/printxls.pyg"

See the link below for a screenshot.

http://www.postyourimage.com/view_image.php?img_id=j8R0xh9VhUlfUCM1201667857

Let me know if this solves the issue or if I'm way off. :)

-Tom Woz
.


Quantcast