poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r600904 - /poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml
Date Tue, 04 Dec 2007 12:05:33 GMT
Author: nick
Date: Tue Dec  4 04:05:33 2007
New Revision: 600904

URL: http://svn.apache.org/viewvc?rev=600904&view=rev
Log:
Note about iterators

Modified:
    poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml

Modified: poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml?rev=600904&r1=600903&r2=600904&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml Tue Dec  4 04:05:33 2007
@@ -41,6 +41,7 @@
                     <li><link href="#CreateCells">How to create cells</link></li>
                     <li><link href="#CreateDateCells">How to create date cells</link></li>
                     <li><link href="#CellTypes">Working with different types
of cells</link></li>
+                    <li><link href="#Iterator">Iterate over rows and cells</link></li>
                     <li><link href="#TextExtraction">Text Extraction</link></li>
                     <li><link href="#Alignment">Aligning cells</link></li>
                     <li><link href="#Borders">Working with borders</link></li>
@@ -233,6 +234,26 @@
     wb.write(fileOut);
     fileOut.close();
                     </source>
+                </section>
+                <anchor id="Iterator"/>
+                <section><title>Iterate over rows and cells (including Java 5
foreach loops)</title>
+				<p>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.</p>
+				<p>Luckily, this is very easy. HSSFRow defines a 
+				<em>CellIterator</em> inner class to handle iterating over 
+				the cells (get one with a call to <em>row.cellIterator()</em>),
+				and HSSFSheet provides a <em>rowIterator()</em> method to
+				give an iterator over all the rows.</p>
+				<source>
+    HSSFSheet sheet = wb.getSheetAt(0);
+	for (HSSFRow row : sheet.rowIterator()) {
+		for (HSSFCell cell : row.cellIterator()) {
+			// Do something here
+		}
+	}
+				</source>
                 </section>
                 <anchor id="TextExtraction"/>
                 <section><title>Text Extraction</title>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message