File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Exporting ResultSet data to MS Excel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Exporting ResultSet data to MS Excel" Watch "Exporting ResultSet data to MS Excel" New topic

Exporting ResultSet data to MS Excel

Easwar Murthi

Joined: Jan 11, 2008
Posts: 3
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,
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41531
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

Joined: May 26, 2003
Posts: 31634

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Exporting ResultSet data to MS Excel