aspose file tools*
The moose likes JDBC 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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Exporting ResultSet data to MS Excel" Watch "Exporting ResultSet data to MS Excel" New topic
Author

Exporting ResultSet data to MS Excel

Easwar Murthi
Greenhorn

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

Joined: Oct 13, 2005
Posts: 36592
    
  16
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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.


[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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Exporting ResultSet data to MS Excel
 
Similar Threads
Problem in exporting data using Displaytag
File name for Excel sheel not showing correctly in Japanese locale
How to insert data from file excel into DB?
WA #1.....word association
What is the best way to store List<List<String>> in database?