Thanks.
There's no way (that I know) of getting the browser the pop up the
download popup except as a result of an HTTPResponse. So if you want
to grab the data out of the FlexTable on the client side, you've got
to post the data to the server (such as via a GWT Service), then
create a new HttpRequest that gets the data from the server and sets
the MIME type to CSV so the browser opens the download popup.
You might want to consider just calling the server for the data in the
first place and forget about getting it out of the FlexTable. That
would be simpler, but then you lose any formatting the user has done,
such as client-side sorting of the table.
Info on the CSV format can be found here -
http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat
Here's the awkward sequence of events I had to go through:
1. Iterate through the table and accumulate the cell values (in CSV
format) in a StringBuffer.
2. Push the String to the server via a GWT service, which puts the
data in the HttpSession.
3. In the service callback's onSuccess() method, call a servlet (I
used Window.open(url, "_self", "");) that retrieves the data from the
HttpSession, sets the HttpResponse MIME type to text/csv, and streams
the data back on the HttpResponse. Don't forget to remove the data
from the HttpSession ;-)
Hope this helps.
Michael
- Brill Pappin
On Mar 26, 4:38 pm, "ewtsm" <miller.elli...@gmail.com> wrote:
1st
Generate a html table and save the file with a .xls extension and send
that to the client. It really works.
2nd
Jasper reports. Generate a report and export it to many formats,
including pdf, xls and csv
http://www.jasperforge.org/
greetings
Get!em
write a plain old servlet, override the service method, change the
content-type to "application-x/xls" and write in the
response.getOutputStream.
Since you are on the server, make the search again... its faster...
map the servlet you've made to a pattern like this "*.xls" so whatever
you the servlet will end up like a xls file and the client will think
you have generated a excel file for him but you don't need to worry
about files its just the response... :)
thats it :)
hope it works for you :)
On Mar 27, 5:51 am, "Get!em" <Get...@gmail.com> wrote:
> All nice answers, but there are 2 really simple solutions:
>
> 1st
> Generate a html table and save the file with a .xls extension and send
> that to the client. It really works.
>
> 2nd
> Jasper reports. Generate a report and export it to many formats,
> including pdf, xls and csvhttp://www.jasperforge.org/
-ewtsm
On Mar 27, 6:03 am, "Maarten Volders" <maarten.vold...@gmail.com>
wrote:
> The point I wanted to make with offline / async generation of reports is
> that you add extra convenience to to client. In plain old page reload
> application the user would have to wait for the response, or having a second
> browser window open which is waiting for the server response. With async
> communication you can really inform the user when the report is ready and
> give him the possibility to choose when he wants to see the report ... just
> think about it ;-)
>