This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Dowloading a Table as a csv File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dowloading a Table as a csv File" Watch "Dowloading a Table as a csv File" New topic
Author

Dowloading a Table as a csv File

Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
Hello:

In a JSF app, I am trying to find the best way to download a (HTML)table to the client as a CSV file (to be open with excel for example).

Any ideas?

Thanks!
Javo


I hate 'trial and error'<br />and I am doing it all the time
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Parse the table to output a comma delimited list name.csv, when excel saves it back to that file it will be in the correct excel format.

if you're doing it through struts you can have it as a link pointing to an action containing the following:



This will create a file with your data and send it to the browser which will automatically deal with it by popping up a download box or displaying if the client has an excel plug-in installed, hope this is what you were after
Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
Thanks!

I would really like to test that.
But I am using JavaServer Faces...

What is the parallel to "response" in JavaServer Faces?

Regs,
javoso
[ December 13, 2004: Message edited by: Javoso Torso ]
Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
:

FacesContext.getExternalContext().getResponse();

?
[ December 13, 2004: Message edited by: Javoso Torso ]
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

You might want to try JExcel API as well.

HTH,
- Manish
Javoso Torso
Ranch Hand

Joined: Aug 15, 2003
Posts: 88
Thank you,

I am giving Apache POI a try!

Rgs,
javo
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dowloading a Table as a csv File