POI

POI api Projects

POI api Project 1

Iterate the data over row and cell in POI API
Previous Home Next

 

In this page of the example we are going to show you how we can iterate the data over row and cell.This is possible with a simple for loop. Luckily, It is very easy. Row defines a CellIterator inner class to handle iterating over the cells (get one with a call to row.cellIterator()), and Sheet provides a rowIterator() method to give an iterator over all the rows. Alternately, Sheet and Row both implement java.lang.Iterable, so using Java 1.5 you can simply take advantage of the built in "foreach" support.


 


 

Workbook wkb=
new Workbook(); sheet shit = wkb.getsheetat(0); for (iterator<row> rit = sheet.rowiterator(); rit.hasnext(); ) { row row = rit.next(); for (iterator<cell> cit = row.celliterator(); cit.hasnext(); ) { cell cell = cit.next(); // Write next code here which you want } }

 



Previous Home Next