• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing object to excel spreadsheet

 
Martin Lira
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I have a Hashtable and not an ArrayList. The hash table contains key/value pair ("Date", ArrayListOfValueObjectForThatDate).

-Martin
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not matter if you know how to make a .csv file out of it
 
Martin Lira
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should give you a general idea, optimize it as appropriate.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic