This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing object to excel spreadsheet  RSS feed

 
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
Boost this thread!