• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code for transfering data from JSP to Excel Sheet

 
nageshwar reddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

can any one send me the details what to do to tranfer tha JSP data(which is from database) to the excel sheet.
Actually i have a set of data records(from Database) in the JSP page and i have a button like "PRINT".When i click the "PRINT" button i need to transfer the records to an MS-Excel Sheet.

I need the full details regarding this(including the code) please.


Thanks& Regards,

C.G.Nageshwar Redddy
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nageshwar reddy wrote: I need the full details regarding this(including the code) please.

Making things a bit too trivial now aren't we?
While I'm not really inclined to sit down and write the whole implementation for you, I can only suggest that the most logical thing to achieve what you need to do is - make another query to the database, recreate your data structures, and create an XLS datasheet using an XLS based Java API like POI.
You could also put the data-structures you created for displaying on the JSP in your session as an attribute. This way you won't have to re-create them. But that would be really bad [assuming you're not dealing with small sized data here]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you need to preserve whatever formatting (fonts, bold, alignment, etc.) is used as well? If so, a library like POI is indeed your only choice. If it's only the actual values you're interested in, you might as well just create a CSV file and stream that to the client (using one of the many available Java CSV libraries).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic