Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 12491 invoked from network); 28 Jun 2008 17:13:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jun 2008 17:13:30 -0000 Received: (qmail 93008 invoked by uid 500); 28 Jun 2008 17:13:31 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 92969 invoked by uid 500); 28 Jun 2008 17:13:31 -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 92960 invoked by uid 99); 28 Jun 2008 17:13:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Jun 2008 10:13:31 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Jun 2008 17:12:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7A12623889F3; Sat, 28 Jun 2008 10:12:39 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r672553 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java Date: Sat, 28 Jun 2008 17:12:39 -0000 To: commits@poi.apache.org From: nick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080628171239.7A12623889F3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nick Date: Sat Jun 28 10:12:38 2008 New Revision: 672553 URL: http://svn.apache.org/viewvc?rev=672553&view=rev Log: Update changelog about EventWorkbookBuilder, and tweak XLS2CSVmra to use it if formulas required Modified: poi/trunk/src/documentation/content/xdocs/changes.xml poi/trunk/src/documentation/content/xdocs/status.xml poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java Modified: poi/trunk/src/documentation/content/xdocs/changes.xml URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=672553&r1=672552&r2=672553&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/changes.xml (original) +++ poi/trunk/src/documentation/content/xdocs/changes.xml Sat Jun 28 10:12:38 2008 @@ -36,8 +36,8 @@ - - + + Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder 30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d Modified: poi/trunk/src/documentation/content/xdocs/status.xml URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=672553&r1=672552&r2=672553&view=diff ============================================================================== --- poi/trunk/src/documentation/content/xdocs/status.xml (original) +++ poi/trunk/src/documentation/content/xdocs/status.xml Sat Jun 28 10:12:38 2008 @@ -33,8 +33,8 @@ - - + + Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder 30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java?rev=672553&r1=672552&r2=672553&view=diff ============================================================================== --- poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java (original) +++ poi/trunk/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java Sat Jun 28 10:12:38 2008 @@ -30,9 +30,11 @@ import org.apache.poi.hssf.eventusermodel.HSSFListener; import org.apache.poi.hssf.eventusermodel.HSSFRequest; import org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener; +import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener; import org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord; import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord; import org.apache.poi.hssf.model.FormulaParser; +import org.apache.poi.hssf.record.BOFRecord; import org.apache.poi.hssf.record.BlankRecord; import org.apache.poi.hssf.record.BoolErrRecord; import org.apache.poi.hssf.record.CellValueRecordInterface; @@ -46,6 +48,7 @@ import org.apache.poi.hssf.record.SSTRecord; import org.apache.poi.hssf.record.StringRecord; import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** @@ -64,6 +67,10 @@ /** Should we output the formula, or the value it has? */ private boolean outputFormulaValues = true; + /** For parsing Formulas */ + private SheetRecordCollectingListener workbookBuildingListener; + private HSSFWorkbook stubWorkbook; + // Records we pick up as we process private SSTRecord sstRecord; private FormatTrackingHSSFListener formatListener; @@ -108,7 +115,13 @@ HSSFEventFactory factory = new HSSFEventFactory(); HSSFRequest request = new HSSFRequest(); - request.addListenerForAllRecords(formatListener); + + if(outputFormulaValues) { + request.addListenerForAllRecords(formatListener); + } else { + workbookBuildingListener = new SheetRecordCollectingListener(formatListener); + request.addListenerForAllRecords(workbookBuildingListener); + } factory.processWorkbookEvents(request, fs); } @@ -124,6 +137,16 @@ switch (record.getSid()) { + case BOFRecord.sid: + BOFRecord br = (BOFRecord)record; + if(br.getType() == BOFRecord.TYPE_WORKSHEET) { + // Create sub workbook if required + if(workbookBuildingListener != null && stubWorkbook == null) { + stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook(); + } + } + break; + case SSTRecord.sid: sstRecord = (SSTRecord) record; break; @@ -161,7 +184,7 @@ } } else { thisStr = '"' + - FormulaParser.toFormulaString(null, frec.getParsedExpression()) + '"'; + FormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"'; } break; case StringRecord.sid: --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org