K
kj
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
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