• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Export Result of query to Excel file by Jexcel API

 
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.
 
Sheriff
Posts: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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));
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!