File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
arpit patel
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your code?
 
Andre Patricio
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20199
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I need to find the number of rows in a specific column. How do I do that?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic