• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Export Result of query to Excel file by Jexcel API

 
Ranch Hand
Posts: 32
MyEclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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));
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic