Stupid.Fat.Cat
Stupid.Fat.Cat

Reputation: 11325

Iterate through a specific range of rows in java (apache poi)

Right now I'm iterating through all rows and finding the index, then if the index is within bounds, I do something with it

for (Row r: sheet) {
    if(r.getRowNum()>x)
        Cell cell = r.getCell(1);
    something something something
}

But is there a way to iterate through a specific range without having to go through the comparison?

Upvotes: 2

Views: 6543

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

A HSSFSheet object has a getRow(int index) method you can use to retrieve any row.

for (int i=start_row; i<=end_row; i++)
{
    HSSFRow = sheet.getRow(i);
    something something something
}

Upvotes: 4

Related Questions