Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying recordset in Excel  RSS feed

 
Karl Green
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was handed a legacy web app and asked to add some new features. Currently the app gets some data from the database and displays it in IE. There is a save option on the page, but it saves it as an HTML file not as a CSV as it is supposed to. Is there a way that I can save it as an Excel file, or better yet have IE open up Excel and display the data? I have looked into HSSF at Apache, but I�m not sure if this is the way that I want to go. My Java is rusty it, has been almost 2 years since I�ve done much in it, and the original developer didn�t know/understand/or use MVC so her code is messy. Any help or suggestions would be greatly appreciated

Thanks


Karl
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have the export link hit a servlet that emits the data in CSV format. Set the content-type to the appropriate setting for Excel (some searching through this forum should yield that -- I'm not somewhere where I can look it up at the moment).
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to minimise Java coding I have a suggestion for a quick and possibly not-too-dirty alternative. It shouldn't be too tricky to modify the servlet to serve the data in CSV format, say when a "View in Excel" button is clicked. If you set the content type to application/vnd.ms-excel I wonder what would happen? If that doesn't work out of the box then you may well be able to contrive it so that it does.

Of course the ideal solution is to serve a proper Excel spreadsheet. I've seen POI mentioned in response to similar posts but I'm not sure if it's relevant here.

Jules
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!