mirror of
https://github.com/apache/poi.git
synced 2025-02-08 11:04:53 +00:00
Tweak the iterator section to avoid casts as we have generics, and then ditch the hssf duplicate bit (everyone should be pointed at the ss.usermodel version)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@898750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0779f79cc7
commit
b9621dfb14
@ -266,24 +266,14 @@
|
|||||||
and Sheet provides a <em>rowIterator()</em> method to
|
and Sheet provides a <em>rowIterator()</em> method to
|
||||||
give an iterator over all the rows.</p>
|
give an iterator over all the rows.</p>
|
||||||
<p>Alternately, Sheet and Row both implement java.lang.Iterable,
|
<p>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.</p>
|
of the built in "foreach" support - see below.</p>
|
||||||
<source>
|
<source>
|
||||||
Sheet sheet = wb.getSheetAt(0);
|
Sheet sheet = wb.getSheetAt(0);
|
||||||
for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {
|
for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext(); ) {
|
||||||
Row row = (Row)rit.next();
|
Row row = rit.next();
|
||||||
for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {
|
for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext(); ) {
|
||||||
Cell cell = (Cell)cit.next();
|
Cell cell = cit.next();
|
||||||
// Do something here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</source>
|
|
||||||
<source>
|
|
||||||
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();
|
|
||||||
// Do something here
|
// Do something here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user