Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exporting ResultSet data to MS Excel

 
Easwar Murthi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to write a List into an Excel file. The List is essentially retrieved from a MySQL DB. Is there a code that can be used to achieve this? Please help...

Thank you,
Easwar
 
Campbell Ritchie
Sheriff
Pie
Posts: 49770
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Sorry that nobody has replied earlier. Don't know about direct input to Excel, but it is quite easy to change the output to comma separated format; Excel opens csv files by default.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easwar,
Welcome to JavaRanch!

If you just need a file that opens in Excel, I second the CSV format. If you need to have Excel formatting, you can use an Excel library. The open source POI HSSF is a good one.

You still have to loop through the result set and output the results in CSV/HSSF. You could do generically in one place for your app though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic