Yes, we used a server-side script to get this done (steps are outlined
below). If anyone wants the code just reply to this thread and I'll
post it here.
The function we're calling from the chart object itself, in our case,
is passing two parameters: a reference to the table dom element
(this.spreadsheet.datagrid) and a dataname parameter. In our case the
dataname is being derived from the chart container id. Ultimately
we're using this as part of the exported file name, though that's not
needed to make this work. Also note that our function is designed to
accept either a table dom id or the element reference itself...in the
case of the charts we're using the latter.
The javascript is doing the following:
1) It initialized an empty array and traverses the tr tags of the
table. For each tr, it traverses all th and td tags and adds an
element to the array which itself is an array of the text in the th/td
tags. Therefore the array ends up with data something like this:
[
['col head 1', 'col head 1', 'col head 3'], [12, 55, 300], [5, 77,
230] ]
2) It JSON encodes that data into a string. We include the json2
javascript library for this, but this is where we discovered that
prototype breaks that when it comes to arrays. This will happen when
using flotr, so instead we use the prototype method of json encoding:
encdata = Object.toJSON(data);
...in place of the json2 JSON.stringify(data) method.
3) We add a form inside of a hidden span tag, whose action points to
the server side script url, to the dom containing a hidden input tag
with this data, submit the form, and delete all of that from the dom
when we're done.
4) The server side script json decodes that data (in the case of php
using json_decode) which gets an array or arrays. It prints the
appropriate headers for the desired content type and, most
importantly, the "Content-Disposition: attachment;
filename=<some_file_name>" header. It then traverses the array
printing out the data with the appropriate tab delimiters and newlines
at the end of each row.