Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 59561 invoked from network); 4 Dec 2007 12:05:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2007 12:05:55 -0000 Received: (qmail 73023 invoked by uid 500); 4 Dec 2007 12:05:43 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 72986 invoked by uid 500); 4 Dec 2007 12:05:43 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 72977 invoked by uid 99); 4 Dec 2007 12:05:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 04:05:43 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 12:05:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 417FD1A9832; Tue, 4 Dec 2007 04:05:34 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r600904 - /poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml Date: Tue, 04 Dec 2007 12:05:33 -0000 To: commits@poi.apache.org From: nick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071204120534.417FD1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@
  • 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
  • @@ -233,6 +234,26 @@ wb.write(fileOut); 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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org