aspose file tools*
The moose likes Other Open Source Projects and the fly likes Excelsheet content reading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Excelsheet content reading" Watch "Excelsheet content reading" New topic
Author

Excelsheet content reading

Arun vel
Greenhorn

Joined: Feb 06, 2012
Posts: 15

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...



Regards,
Arun.K
Zeeshan Sheikh
Ranch Hand

Joined: Nov 20, 2011
Posts: 144

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


MySQL Blog
http://mysqlearner.blogspot.com/
Arun vel
Greenhorn

Joined: Feb 06, 2012
Posts: 15

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..
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What difficulty are you facing in storing those values in the DB? Are you familiar with the JDBC API?
Arun vel
Greenhorn

Joined: Feb 06, 2012
Posts: 15

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Feb 06, 2012
Posts: 15

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
Sounds like a loop (or maybe two nested loops) would be involved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Excelsheet content reading