There are basically two ways to write the sort of code that you are after.

One would be to use an iterator and write code using the hasNext() and
next() methods of that object. To get an Iterator for the rows on a sheet;

//Open a Workbook.
HSSFWorkbook book = new HSSFWorkbook(new FileInputStream(new
File("............")));
//Get a reference to a sheet - this would get the first sheet;
HSSFSheet = book.getSheetAt(0);
// Now get the row iterator
Iterator<Row> rowIterator = sheet.rowIterator();
// Use it to process the rows
while(rowIterator.hasNext()) {
.............
}

The other is to find out the numbers of the first and last rows on the sheet
and then use a simple for loop to step through this range.

//Open a Workbook.
HSSFWorkbook book = new HSSFWorkbook(new FileInputStream(new
File("............")));
//Get a reference to a sheet - this would get the first sheet;
HSSFSheet = book.getSheetAt(0);
// Get the index of the first and last rows
int firstRowNum = sheet.getFirstRowNum();
int lastRowNum = sheet.getLastRowNum();
for (int i = firstRowNum ; i < lastRowNum ; i++) {
    HSSFRow = sheet.getRow(i);
    ........................................
}


Andrey Rogov-2 wrote:
> 
> I want to write a cycle to get all values of Excel file.
> How can I define the number of the last entered line ?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Last-row---tp23114515p23124218.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to