File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Passing object to excel spreadsheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing object to excel spreadsheet" Watch "Passing object to excel spreadsheet" New topic
Author

Passing object to excel spreadsheet

Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
Hi,
I have a jsp that calls a bean to get some data from the database. The bean returns an ArrayList. The jsp process the ArrayList and displays it in TABLE. I need to provide the user facility of viewing the same data in an excel spreadsheet. How can i pass this ArrayList object to another jsp page with the excel stuff. I dont want to use session.setAttribute. I tried using the request.setAttribute but since I make another request on submit I cannot retrieve by request.getAttribute.

Thanks,
Martin
Dmitry Melnik
Ranch Hand

Joined: Dec 18, 2003
Posts: 328
Out of your ArrayList you can generate a text in "comma separated values" (or CSV) format, which is viewable via Excel. You might need to make the URL end with ".csv"
Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
Actually I have a Hashtable and not an ArrayList. The hash table contains key/value pair ("Date", ArrayListOfValueObjectForThatDate).

-Martin
Dmitry Melnik
Ranch Hand

Joined: Dec 18, 2003
Posts: 328
It does not matter if you know how to make a .csv file out of it
Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
Dmitry,
I dont know how to create a .csv from Hashtable key,values. Any sample code will really help.

thanks,
Martin
Dmitry Melnik
Ranch Hand

Joined: Dec 18, 2003
Posts: 328
This should give you a general idea, optimize it as appropriate.

 
Consider Paul's rocket mass heater.
 
subject: Passing object to excel spreadsheet
 
Similar Threads
HTML To excel
What is available to replace the JFace TableViewer? Want "cut and paste" functionality!
Servlet MS Excel.
JSP and Excel
Oracle 9i to Excel Sheet