aspose file tools*
The moose likes Other Open Source Projects and the fly likes Export Result of query to Excel file by Jexcel API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Export Result of query to Excel file by Jexcel API" Watch "Export Result of query to Excel file by Jexcel API" New topic
Author

Export Result of query to Excel file by Jexcel API

peter aerts
Ranch Hand

Joined: Jan 22, 2009
Posts: 32

Hi Dears,

I want to export the result of a query to excel file by Jexcel API but don't know how to add header to excel file and how to iterate on rs and write data to the cells.headers of excel files are as follows:

USER_NAME,LOCK_USER,BLOCK_USER,CREATION_DATE,EMAIL,DESCRIPTION,FIRST_NAME_V,LAST_NAME_V

Please refer to the while (rs.next()) { } that i have problem to write.

Can anyone please help me on this.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

You can get a ResultSetMetaData object from the ResultSet, and use it to get the column names. As for the iterating, you're already doing that - using rs.next().


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
peter aerts
Ranch Hand

Joined: Jan 22, 2009
Posts: 32

Dear Rob,

Thanks a lot for your support.Issue resolved with the help of below for clause.


for(int j=1;rs.next();j++) {

workSheet.addCell(new jxl.write.Label(0,j,rs.getString("USER_NAME"),normalFormat));

workSheet.addCell(new jxl.write.Label(1,j,rs.getString("LOCK_USER"),normalFormat));
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Export Result of query to Excel file by Jexcel API