HighDots Forums  

How to mimic Excel download?

Javascript JavaScript language (comp.lang.javascript)


Discuss How to mimic Excel download? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kj
 
Posts: n/a

Default How to mimic Excel download? - 05-22-2008 , 11:34 AM









Executive summary:

Is there a way for the client side JavaScript to tell the browser
to use MS Excel to view some data?



The question:

I'm changing an webapp from standard CGI to pure AJAX. I.e. only
one page gets loaded at startup, and all subsequent interaction is
done exclusively via JavaScript or AJAX.

The original app had a "Send results as spreadsheet" checkbox that
when checked would instruct the server to send the results in the
form of an Excel spreadsheet (setting the Content-type header of
the response to application/vnd.ms-excel).

(Actually, the table that gets returned is very simple. It does
not include any Excel-specific features. I understand that even
if it were sent as a plain-text TSV table, as long as the Content-type
header was set as above, Excel would be able to handle it. But I
have not tested this in depth.)

In the new version of the app, normally (i.e. when the spreadsheet
box is not checked) the data is retrieved from a web service through
an AJAX call. This web service knows nothing of CGI. It just
returns some JSON-encoded data in tabular form.

One (admittedly disgusting) way I could achieve the same effect as
before when the spreadsheet box is checked is simply to bounce the
data back to a server-side CGI script whose only job is to bounce
the data again to the client, with the appropriate Content-type
headers.

But I was wondering if there is a way to achieve the same effect
without this otherwise unnecessary extra round-trip of the data.
In other words, is there a way for the client side JavaScript to
tell the browser to use Excel to view some data?

TIA!

Kynn




--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.

Reply With Quote
  #2  
Old   
kj
 
Posts: n/a

Default Re: How to mimic Excel download? - 05-24-2008 , 08:29 AM







In <d4a284f3-7f35-4741-b4f3-d38784db95d9 (AT) u36g2000prf (DOT) googlegroups.com> "gimme_this_gimme_that (AT) yahoo (DOT) com" <gimme_this_gimme_that (AT) yahoo (DOT) com> writes:

Quote:
Hi Kynn,

I see variations of this post often - and my experience is that people
that don't know Excel get lost when it comes to understanding my
solution.
Thanks! I'll give it a go.

k.

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.