ASF Bugzilla – Attachment 33067 Details for
Bug 58245
[PATCH] Make Workbook interface iterable over sheets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
site documentation updates
sitedocs_iterable_workbook.patch (text/plain), 2.89 KB, created by
Javen O'Neal
on 2015-09-06 09:24:21 UTC
(
hide
)
Description:
site documentation updates
Filename:
MIME Type:
Creator:
Javen O'Neal
Created:
2015-09-06 09:24:21 UTC
Size:
2.89 KB
patch
obsolete
>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 @@ > </section> > <anchor id="Iterator"/> > <section><title>Iterate over rows and cells</title> >- <p>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.</p> >- <p>Luckily, this is very easy. Row defines a >- <em>CellIterator</em> inner class to handle iterating over >- the cells (get one with a call to <em>row.cellIterator()</em>), >- and Sheet provides a <em>rowIterator()</em> method to >- give an iterator over all the rows. These implement the >- <em>java.lang.Iterable</em> interface to allow foreach loops.</p> >+ <p>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.</p> >+ <p>These iterators are available by calling <em>workbook.sheetIterator()</em>, >+ <em>sheet.rowIterator()</em>, and <em>row.cellIterator()</em>, 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.</p> > > <source> >- 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 >+ } >+ } > } > </source> > </section>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 58245
:
33001
|
33066
|
33067
|
33068