View | Details | Raw Unified | Return to bug 58245
Collapse All | Expand All

(-)poi-site/src/documentation/content/xdocs/spreadsheet/eval.xml (-5 / +4 lines)
Lines 214-224 Link Here
214
FileInputStream fis = new FileInputStream("/somepath/test.xls");
214
FileInputStream fis = new FileInputStream("/somepath/test.xls");
215
Workbook wb = new HSSFWorkbook(fis); //or new XSSFWorkbook("/somepath/test.xls")
215
Workbook wb = new HSSFWorkbook(fis); //or new XSSFWorkbook("/somepath/test.xls")
216
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
216
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
217
for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
217
for (Sheet sheet : wb) {
218
    Sheet sheet = wb.getSheetAt(sheetNum);
218
    for (Row r : sheet) {
219
    for(Row r : sheet) {
219
        for (Cell c : r) {
220
        for(Cell c : r) {
220
            if (c.getCellType() == Cell.CELL_TYPE_FORMULA) {
221
            if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
222
                evaluator.evaluateFormulaCell(c);
221
                evaluator.evaluateFormulaCell(c);
223
            }
222
            }
224
        }
223
        }
(-)poi-site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml (-14 / +14 lines)
Lines 324-345 Link Here
324
                </section>
324
                </section>
325
                <anchor id="Iterator"/>
325
                <anchor id="Iterator"/>
326
                <section><title>Iterate over rows and cells</title>
326
                <section><title>Iterate over rows and cells</title>
327
				<p>Sometimes, you'd like to just iterate over all the rows in
327
				<p>Sometimes, you'd like to just iterate over all the sheets in 
328
				a sheet, or all the cells in a row. This is possible with
328
				a workbook, all the rows in a sheet, or all the cells in a row.
329
				a simple for loop.</p>
329
				This is possible with a simple for loop.</p>
330
				<p>Luckily, this is very easy. Row defines a 
330
				<p>These iterators are available by calling <em>workbook.sheetIterator()</em>,
331
				<em>CellIterator</em> inner class to handle iterating over 
331
				<em>sheet.rowIterator()</em>, and <em>row.cellIterator()</em>, or
332
				the cells (get one with a call to <em>row.cellIterator()</em>),
332
				implicitly using a for-each loop.
333
				and Sheet provides a <em>rowIterator()</em> method to
333
				Note that a rowIterator and cellIterator iterate over rows or
334
				give an iterator over all the rows. These implement the 
334
				cells that have been created, skipping empty rows and cells.</p>
335
            <em>java.lang.Iterable</em> interface to allow foreach loops.</p>
336
335
337
				<source>
336
				<source>
338
    Sheet sheet = wb.getSheetAt(0);
337
    for (Sheet sheet : wb ) {
339
    for (Row row : sheet) {
338
        for (Row row : sheet) {
340
      for (Cell cell : row) {
339
            for (Cell cell : row) {
341
        // Do something here
340
                // Do something here
342
      }
341
            }
342
        }
343
    }
343
    }
344
				</source>
344
				</source>
345
            </section>
345
            </section>

Return to bug 58245