diff --git a/src/documentation/content/xdocs/spreadsheet/quick-guide.xml b/src/documentation/content/xdocs/spreadsheet/quick-guide.xml index b2feca0679..a959090ac3 100644 --- a/src/documentation/content/xdocs/spreadsheet/quick-guide.xml +++ b/src/documentation/content/xdocs/spreadsheet/quick-guide.xml @@ -266,24 +266,14 @@ and Sheet provides a rowIterator() method to give an iterator over all the rows.

Alternately, Sheet and Row both implement java.lang.Iterable, - so if you're using Java 1.5, you can simply take advantage + so using Java 1.5 you can simply take advantage of the built in "foreach" support - see below.

Sheet sheet = wb.getSheetAt(0); - for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) { - Row row = (Row)rit.next(); - for (Iterator cit = row.cellIterator(); cit.hasNext(); ) { - Cell cell = (Cell)cit.next(); - // Do something here - } - } - - - HSSFSheet sheet = wb.getSheetAt(0); - for (Iterator<HSSFRow> rit = (Iterator<HSSFRow>)sheet.rowIterator(); rit.hasNext(); ) { - HSSFRow row = rit.next(); - for (Iterator<HSSFCell> cit = (Iterator<HSSFCell>)row.cellIterator(); cit.hasNext(); ) { - HSSFCell cell = cit.next(); + for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext(); ) { + Row row = rit.next(); + for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext(); ) { + Cell cell = cit.next(); // Do something here } }