S
Sharon
Hi!
I need help. I have a variable which is just a string containing the
output of a transform from XML to CSV format. I want the client to be
able to download this as a file (.csv), so I used this piece of code:
function SaveVarAsFile(someVar){
alert(someVar);
SaveFrame.document.open("text/plain","replace");
SaveFrame.document.write(someVar);
SaveFrame.document.close();
SaveFrame.document.charset="UTF-8";
SaveFrame.focus();
SaveFrame.document.execCommand('SaveAs','false','test.csv');
SaveFrame is an iframe in the body of my page:
<iframe id="SaveFrame" style="display:none"></iframe>
Now I don't want the encoding to be UTF-8 but I need it to be ASCII,
in order to display the file properly in Excel instead of having all
the data in one column. But when I change charset into "ASCII", the
file that is saved is not the document in the iframe but the whole
html page the iframe is part of! How is this possible and what can I
do to fix it?
Secondly, the saved file begins and ends with html tags that I don't
want, I want it to be just plain text. How do I get rid of these tags?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=utf-8"></HEAD>
<BODY><PRE>
Hope someone can help 'cause I'm getting really frustrated! Thanks.
I need help. I have a variable which is just a string containing the
output of a transform from XML to CSV format. I want the client to be
able to download this as a file (.csv), so I used this piece of code:
function SaveVarAsFile(someVar){
alert(someVar);
SaveFrame.document.open("text/plain","replace");
SaveFrame.document.write(someVar);
SaveFrame.document.close();
SaveFrame.document.charset="UTF-8";
SaveFrame.focus();
SaveFrame.document.execCommand('SaveAs','false','test.csv');
SaveFrame is an iframe in the body of my page:
<iframe id="SaveFrame" style="display:none"></iframe>
Now I don't want the encoding to be UTF-8 but I need it to be ASCII,
in order to display the file properly in Excel instead of having all
the data in one column. But when I change charset into "ASCII", the
file that is saved is not the document in the iframe but the whole
html page the iframe is part of! How is this possible and what can I
do to fix it?
Secondly, the saved file begins and ends with html tags that I don't
want, I want it to be just plain text. How do I get rid of these tags?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=utf-8"></HEAD>
<BODY><PRE>
Hope someone can help 'cause I'm getting really frustrated! Thanks.