This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Export Result of query to Excel file by Jexcel API  RSS feed

 
peter aerts
Ranch Hand
Posts: 32
MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
peter aerts
Ranch Hand
Posts: 32
MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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));
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!