aspose file tools*
The moose likes Other Open Source Projects and the fly likes Getting number of rows and column from Excel, using JXL library 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 "Getting number of rows and column from Excel, using JXL library" Watch "Getting number of rows and column from Excel, using JXL library" New topic
Author

Getting number of rows and column from Excel, using JXL library

arpit patel
Greenhorn

Joined: Feb 16, 2008
Posts: 6
Hi All,

I need to upload data from excel file to database. I am using JXL library for the same. For this i need to get data from my Excel( rows and columns).

I am using following code to get this:-
jxl.Workbook workbook=null;
jxl.Sheet sheet =null;
workbook = jxl.Workbook.getWorkbook(new File("SOVTest.xls"));
sheet = workbook.getSheet(0);

int rows=0;
int cols=0;
rows=sheet.getRows();
cols=sheet.getColumns();

So i get the number if rows and columns and then i loop to get data from the cells.

Here i assume that i have 100 row's in my excel file.
Now my question is, if i re-use the same Excel file and delete 50 existing row's and then try to run my program, i get the value for variable rows=100. So it is not getting refreshed.

Has any one encountered this issue before? PLease let me knw, it is urgent.

Cheers,
Arpit Patel
arpit patel
Greenhorn

Joined: Feb 16, 2008
Posts: 6
People,

Please take out some time of your schedule and try to give me a solution to my query.

It is really urgent.

Cheers,
Arpit
Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Can you post your code?
Andre Patricio
Greenhorn

Joined: Jun 08, 2009
Posts: 1
arpit patel wrote:Hi All,

Hi All,

I'm a beginner so I'm sorry if my questions are to easy... Sorry also with my English that is not the best...
Where does I get the XLS library for Java? I've been looking throu the net and I cann't reachead that...
cheers,
Andre Patricio




I need to upload data from excel file to database. I am using JXL library for the same. For this i need to get data from my Excel( rows and columns).

I am using following code to get this:-
jxl.Workbook workbook=null;
jxl.Sheet sheet =null;
workbook = jxl.Workbook.getWorkbook(new File("SOVTest.xls"));
sheet = workbook.getSheet(0);

int rows=0;
int cols=0;
rows=sheet.getRows();
cols=sheet.getColumns();

So i get the number if rows and columns and then i loop to get data from the cells.

Here i assume that i have 100 row's in my excel file.
Now my question is, if i re-use the same Excel file and delete 50 existing row's and then try to run my program, i get the value for variable rows=100. So it is not getting refreshed.

Has any one encountered this issue before? PLease let me knw, it is urgent.

Cheers,
Arpit Patel
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

arpit patel wrote:
Here i assume that i have 100 row's in my excel file.
Now my question is, if i re-use the same Excel file and delete 50 existing row's and then try to run my program, i get the value for variable rows=100. So it is not getting refreshed.

But that's just how Excel works. Try this:

(1) Fill in 100 rows. Put your cursor in A1. Press Ctrl-Shift-End. Notice how it highlights 100 rows and however many columns you entered data into?

(2) Delete 50 rows of those 100.

(3) Put your cursor in A1. Press Ctrl-Shift-End. Notice how it still highlights 100 rows?

So, if Excel is telling your software that there are 100 rows, you can't expect it to tell you anything else.
Bhargava Parthasarathy
Greenhorn

Joined: Jun 24, 2009
Posts: 1
Hi All

I need to find the number of rows in a specific column. How do I do that?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting number of rows and column from Excel, using JXL library