Index: poi-site/src/documentation/content/xdocs/spreadsheet/eval.xml =================================================================== --- poi-site/src/documentation/content/xdocs/spreadsheet/eval.xml (revision 1701435) +++ poi-site/src/documentation/content/xdocs/spreadsheet/eval.xml (working copy) @@ -214,11 +214,10 @@ FileInputStream fis = new FileInputStream("/somepath/test.xls"); Workbook wb = new HSSFWorkbook(fis); //or new XSSFWorkbook("/somepath/test.xls") FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); -for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) { - Sheet sheet = wb.getSheetAt(sheetNum); - for(Row r : sheet) { - for(Cell c : r) { - if(c.getCellType() == Cell.CELL_TYPE_FORMULA) { +for (Sheet sheet : wb) { + for (Row r : sheet) { + for (Cell c : r) { + if (c.getCellType() == Cell.CELL_TYPE_FORMULA) { evaluator.evaluateFormulaCell(c); } } Index: poi-site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml =================================================================== --- poi-site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml (revision 1701435) +++ poi-site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml (working copy) @@ -324,22 +324,22 @@
Iterate over rows and cells -

Sometimes, you'd like to just iterate over all the rows in - a sheet, or all the cells in a row. This is possible with - a simple for loop.

-

Luckily, this 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. These implement the - java.lang.Iterable interface to allow foreach loops.

+

Sometimes, you'd like to just iterate over all the sheets in + a workbook, all the rows in a sheet, or all the cells in a row. + This is possible with a simple for loop.

+

These iterators are available by calling workbook.sheetIterator(), + sheet.rowIterator(), and row.cellIterator(), or + implicitly using a for-each loop. + Note that a rowIterator and cellIterator iterate over rows or + cells that have been created, skipping empty rows and cells.

- Sheet sheet = wb.getSheetAt(0); - for (Row row : sheet) { - for (Cell cell : row) { - // Do something here - } + for (Sheet sheet : wb ) { + for (Row row : sheet) { + for (Cell cell : row) { + // Do something here + } + } }