Reputation: 1
please advise is there any way lets say if I am getting a row Object as s parameter that is i know the row number now within that row i want to track the count of number of cells that are filed for that particular row.
lets say if the row number is 67 now in that row it can happen that only 2 cells are filled or it can happen that 4 cells are filled with value at last what i want is the count of cells that are filled as i have to implement some logic based on the count
below is the method where i am getting the row object and inside this method i need to get the count of cells
public boolean isCountOfCellsFilledForARow(Row row1) {
for (int c = row1.getFirstCellNum(); c < row1.getLastCellNum(); c++)
{
}
}
Upvotes: 0
Views: 2220
Reputation: 11493
You could try this
public long countCells(Row r) {
long count = 0;
for(Cell c : r) {
if (!c.toString().equals("")) {
count++;
}
}
return count;
}
Upvotes: 0
Reputation: 3368
As far as I understand you would like to find non-empty cells of the row. There is already an answered question regarding finding empty cells via apache-poi. You can use one of the provided answers to check if the cell is empty or not.
Upvotes: 2