• 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

Excelsheet content reading

 
Greenhorn
Posts: 15
MyEclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am trying to read an excel sheet for the purpose of writing it into database.By the below code ,I am getting the contents of the cell in first row,first column..Can you please help me to iterate it for the number of rows and columns.Little bit urgent...

 
Ranch Hand
Posts: 144
MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After you have the first sheet you can iterate using the for loop

for (int j = 0; j < sheet.getColumns(); j++) { //get columns
for (int i = 0; i < sheet.getRows(); i++) { //get rows
//whatever you want to do
 
Arun vel
Greenhorn
Posts: 15
MyEclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay...Now I am getting the values of all the rows and columns..How can I store the value of each columns(as a field) for the purpose of storing in the database..
Thanks for the reply..
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What difficulty are you facing in storing those values in the DB? Are you familiar with the JDBC API?
 
Arun vel
Greenhorn
Posts: 15
MyEclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya..I do have a knowledge in JDBC Api...But the thing is,I dont know how to store the values which I get from the excelsheet cells to some variables,so that only I can use them in my queries..
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't "String stringa1 = a1.getContents()" do that? I'm not familiar with jExcelAPI, buit if that's not the right method then the Cell class should have other methods that do return the correct data from the cell.
 
Arun vel
Greenhorn
Posts: 15
MyEclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya...this is working...I have already tried...But it will retrieve the contents of a particular cell only...But I want to read all the cell(records) to a number of rows...
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a loop (or maybe two nested loops) would be involved.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic