Re: Open XML in excel with javascript?



JaxDawg 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?

I would do something like this:

1. Perform the xml2xls conversion server-side
2. Rename the .php extension into .xls
3. Make .xls extensions execute as PHP
4. Output binary xls with Excel header

This way you should obtain maximum compatibility with all kinds of
programs that deal with .xls-extensions (and not only the typical
Microsoft workarounds which are often problematic).

I have one question though. You start with xls, then save it as xml,
and then want to open it again as xls at the client machine... why
don't you just store the initial xls-file ? (but maybe I'm missing
something)

--
Bart
.