OrigamiEye
OrigamiEye

Reputation: 1035

Jexcelapi Getting the number of rows in one column

I can find the number of rows in the excel document using sheet.getRows(); however the rows in my excel file are of different lengths, how could I get the number of rows in only 1 column. I've found getting rows in file and List of methods in the library but neither have the answer.

Upvotes: 1

Views: 2882

Answers (1)

Leo Ufimtsev
Leo Ufimtsev

Reputation: 6492

I ran into the same problem. I got it by getting the array of cells and then count the length of the array.Where 'int row' is the row that you want to count.

..
workbook = Workbook.getWorkbook(new File(SheetPath));
    .. 
Sheet sheet = workbook.getSheet(0);  //adjust depending on which sheet you need. 
//find out how many cells there are on this row.
Cell[] cellColumn = sheet.getRow(row);
int cellCount = cellColumn.length;
System.out.println("cells in col: " + cellCount);

Here is extra api: http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/

Let me know if you need additional clarification

Upvotes: 2

Related Questions