Click to See Complete Forum and Search --> : problem saving html in excel


alidar777
05-30-2006, 08:20 PM
If i save this code as .xls file why cant i see it in Excel. This code is generated by my jsp. It was working fine past few years in our production.

I fig out if i remove the prolog it works. We havent made any change in code. Except we upgraded our office. Will that be a reason?
I dont have older office to test it. Can some one save this code and open it in office other than 2003.
Thanks


<Script language="javascript">

function SaveMe() {
document.execCommand("SaveAs",false,"untitled.xls");
window.close();
}
</Script>

<HTML>
<BODY onload="javascript:SaveMe();">
<Center>
<?xml version="1.0" encoding="UTF-8"?>
<table border=1 width="100%">
<tr>
<TH>Name2</TH>
<TH>NameId</TH>
<TH>Name 3</TH>
<TH>Res Cd</TH>
<TH>Currency</TH>
<TH>Sr Cd</TH>
</tr>
<tr>
<TD class="odd">Cur1</TD>
<TD class="odd">1302242268</TD>
<TD class="odd">GCH Ltd</TD>
<TD class="odd">MR</TD>
<TD class="odd">USD</TD>
<TD class="odd">SNR</TD>
</tr>


<tr>
<TD class="even">Cur 3<TD>
<TD class="even">1073073863</TD>
<TD class="even">ZCH</TD>
<TD class="even">MMR</TD>
<TD class="even">EUR</TD>
<TD class="even">SNR</TD>
</tr>
</table>

</Center>
</BODY>
</HTML>

the tree
05-31-2006, 05:50 AM
A few things spring to mind, from reading your code. The XML declaration is placed in the middle of the document. The javascript appears to try to close the window upon opening. Event handlers don't need the 'javascript:' bit. XML is case sensitive. Scripts can only appear in the head and body elements of an HTML document. A tag's attributes must be contained in quotation marks.