Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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
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: 44608
    
  34
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

Joined: May 26, 2003
Posts: 32636
    
216

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.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exporting ResultSet data to MS Excel
 
It's not a secret anymore!