• Post Reply Bookmark Topic Watch Topic
  • New Topic

using jsp to generate excel file

 
Anthony Leroy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'd like to use a jsp to generate an excel table from data in a database. Does anyone know how to do this?
Thanks,
Ryan
 
Brian E
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
 
Anthony Leroy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian, can you please explain how to use this?
thanks,
Ant
Originally posted by Brian E:
[B]Try this:
[/B]

 
Brian E
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go ahead and create your database connection and the like as you would in a normal JSP. Make sure that it works and returns the HTML you want it to. Then just put that line of code in the page and it will launch excel and grab the values from the database. I used basically the same code in my database call for HTML and Excel. I used this code:

to sort out what format I wanted. Basically, if I appended the URL to read format=excel, it would execute the code. Otherwise, it would return it as HTML.
One thing you might want to be careful about is how the Excel Spreadsheet is formatted. The version my company uses (97) does not support CSS, so I had to use and tags and the like. Just play around with it until you've got the look you want.
Good luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!