S
Sharon
Hi!
I'm trying to add an export option to my application. I use Javascript
DOM to transform XHTML-tables displayed in the browser window to
CSV-format (client-side) using a simple XSL. All works fine, except
that I can't seem to get any further than alerting the output
*sigh*... Who can give me hints on how to get the output to the client
somehow? Should I save it to the server first and then allow the
client to get it from there, or can I pass it directly back to the
client who pressed the export button and requested it? I tried writing
the output to a document and then do execCommand to let the client
save it but
1) I don't want the output in a new window, I just want the 'save as'
dialog to appear directly. But the execcommand method needs an object
e.g. the document and I don't know how to circumvent this...
2) the 'save as' dialog only allows me to save the output as *txt or
*html and does not have ANSI coding as an option. As a result, when I
save the file as html using the default coding (Unicode) and open it
in Excel all data are displayed in one column. I need ANSI. (When I
open the csv in Notepad and save it with ANSI coding it is displayed
correctly in Excel).
Who can give me a hint on what to do next? I'm desperately waiting for
your replies, TIA!
This is the DOM function:
function buttonExportClick()
{
var xslt = new ActiveXObject('Msxml2.XSLTemplate.3.0');
var s = new ActiveXObject('msxml2.FreeThreadedDOMDocument.3.0');
s.async=false;
s.load("/lib/xtable/convert.xsl");
var xslProc;
xslt.stylesheet = s;
var xmlDoc = document.XMLDocument;
if (xmlDoc==null)
{xmlDoc=navigator.XMLDocument};
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.transform();
var output = xslProc.output;
alert(output);
}
I'm trying to add an export option to my application. I use Javascript
DOM to transform XHTML-tables displayed in the browser window to
CSV-format (client-side) using a simple XSL. All works fine, except
that I can't seem to get any further than alerting the output
*sigh*... Who can give me hints on how to get the output to the client
somehow? Should I save it to the server first and then allow the
client to get it from there, or can I pass it directly back to the
client who pressed the export button and requested it? I tried writing
the output to a document and then do execCommand to let the client
save it but
1) I don't want the output in a new window, I just want the 'save as'
dialog to appear directly. But the execcommand method needs an object
e.g. the document and I don't know how to circumvent this...
2) the 'save as' dialog only allows me to save the output as *txt or
*html and does not have ANSI coding as an option. As a result, when I
save the file as html using the default coding (Unicode) and open it
in Excel all data are displayed in one column. I need ANSI. (When I
open the csv in Notepad and save it with ANSI coding it is displayed
correctly in Excel).
Who can give me a hint on what to do next? I'm desperately waiting for
your replies, TIA!
This is the DOM function:
function buttonExportClick()
{
var xslt = new ActiveXObject('Msxml2.XSLTemplate.3.0');
var s = new ActiveXObject('msxml2.FreeThreadedDOMDocument.3.0');
s.async=false;
s.load("/lib/xtable/convert.xsl");
var xslProc;
xslt.stylesheet = s;
var xmlDoc = document.XMLDocument;
if (xmlDoc==null)
{xmlDoc=navigator.XMLDocument};
xslProc = xslt.createProcessor();
xslProc.input = xmlDoc;
xslProc.transform();
var output = xslProc.output;
alert(output);
}