diff --git a/src/documentation/content/xdocs/hssf/quick-guide.xml b/src/documentation/content/xdocs/hssf/quick-guide.xml index 6dc4dc909..eb48074df 100644 --- a/src/documentation/content/xdocs/hssf/quick-guide.xml +++ b/src/documentation/content/xdocs/hssf/quick-guide.xml @@ -41,6 +41,7 @@
  • How to create cells
  • How to create date cells
  • Working with different types of cells
  • +
  • Iterate over rows and cells
  • Text Extraction
  • Aligning cells
  • Working with borders
  • @@ -234,6 +235,26 @@ fileOut.close(); + +
    Iterate over rows and cells (including Java 5 foreach loops) +

    Sometimes, you'd like to just iterate over all the rows in + a sheet, or all the cells in a row. If you are using Java + 5 or later, then this is especially handy, as it'll allow the + new foreach loop support to work.

    +

    Luckily, this is very easy. HSSFRow defines a + CellIterator inner class to handle iterating over + the cells (get one with a call to row.cellIterator()), + and HSSFSheet provides a rowIterator() method to + give an iterator over all the rows.

    + + HSSFSheet sheet = wb.getSheetAt(0); + for (HSSFRow row : sheet.rowIterator()) { + for (HSSFCell cell : row.cellIterator()) { + // Do something here + } + } + +
    Text Extraction

    For most text extraction requirements, the standard