Connecting Tech Pros Worldwide Forums | Help | Site Map

Need help with code to download table to excel

lxrocks
Guest
 
Posts: n/a
#1: May 14 '07
Hi
I have always downloaded table data to excel using a perl_cgi. The perl
cgi will simpley print("Content-Type: application/vnd.ms-excel");
followed by the usual html table formatted data.

However if I try the same with javascript it does not seem to work.

ie document.write("Content-Type: application/vnd.ms-excel");
document.write("<html><table><thead>bla bla...</html>);


This never triggers the save file as/ or open with excel. It displays
the data in the browser but does not trigger an excel save.


What am I doing wrong?

Thanks

ASM
Guest
 
Posts: n/a
#2: May 14 '07

re: Need help with code to download table to excel


lxrocks a écrit :
Quote:
Hi
I have always downloaded table data to excel using a perl_cgi. The perl
cgi will simpley print("Content-Type: application/vnd.ms-excel");
followed by the usual html table formatted data.
where does-it print that ?
Quote:
However if I try the same with javascript it does not seem to work.
where do you try the following ?
Quote:
ie document.write("Content-Type: application/vnd.ms-excel");
document.write("<html><table><thead>bla bla...</html>);
That would have to write an "html" file ( *.html )
Quote:
This never triggers the save file as/ or open with excel. It displays
the data in the browser but does not trigger an excel save.
>
>
What am I doing wrong?
To do not produce an Excel file ( *.xls ) ?

My last play with this idea (Excel document) :
http://perso.orange.fr/stephane.mori...o_xls_op.shtml

Perhaps with XML and JS-DOM ?

And read or re-read here in c.l.javascript the thread :
"FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?"
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ca13c70349b96de6/75c7b581bb814f10?#75c7b581bb814f10>

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
lxrocks
Guest
 
Posts: n/a
#3: May 14 '07

re: Need help with code to download table to excel


ASM wrote:
Quote:
lxrocks a écrit :
Quote:
>Hi
>I have always downloaded table data to excel using a perl_cgi. The
>perl cgi will simpley print("Content-Type: application/vnd.ms-excel");
>followed by the usual html table formatted data.
>
where does-it print that ?
>
Quote:
>However if I try the same with javascript it does not seem to work.
>
where do you try the following ?
>
Quote:
>ie document.write("Content-Type: application/vnd.ms-excel");
> document.write("<html><table><thead>bla bla...</html>);
>
That would have to write an "html" file ( *.html )
>
Quote:
>This never triggers the save file as/ or open with excel. It displays
>the data in the browser but does not trigger an excel save.
>>
>>
>What am I doing wrong?
>
To do not produce an Excel file ( *.xls ) ?
>
My last play with this idea (Excel document) :
http://perso.orange.fr/stephane.mori...o_xls_op.shtml
>
Perhaps with XML and JS-DOM ?
>
And read or re-read here in c.l.javascript the thread :
"FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?"
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ca13c70349b96de6/75c7b581bb814f10?#75c7b581bb814f10>
>
>
I realise now that there is a difference between client and server side
code when dealing with Mime. Thank you for the example it is most helpful.
Closed Thread