]> source.dussan.org Git - poi.git/commitdiff
Update changelog about EventWorkbookBuilder, and tweak XLS2CSVmra to use it if formul...
authorNick Burch <nick@apache.org>
Sat, 28 Jun 2008 17:12:38 +0000 (17:12 +0000)
committerNick Burch <nick@apache.org>
Sat, 28 Jun 2008 17:12:38 +0000 (17:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@672553 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java

index e82fa59db5af61766df4cf57b275a620ba8e873f..3789216d2d3182319786977ce02557bb09ee3200 100644 (file)
@@ -36,8 +36,8 @@
     </devs>
 
                <!-- Don't forget to update status.xml too! -->
-        <release version="3.2-alpha1" date="2008-??-??">
-          <action dev="POI-DEVELOPERS" type="add"><!-- to keep forrest dtd quiet--></action>
+        <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder</action>
         </release>
         <release version="3.1-final" date="2008-06-29">
            <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d</action>
index 56f909718afd4d5b865268c7bf9d161b8f169aaf..a226686c0d4092f6ec18790882e00ba0276452bd 100644 (file)
@@ -33,8 +33,8 @@
 
        <!-- Don't forget to update changes.xml too! -->
     <changes>
-        <release version="3.2-alpha1" date="2008-??-??">
-          <action dev="POI-DEVELOPERS" type="add"><!-- to keep forrest dtd quiet--></action>
+        <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder</action>
         </release>
         <release version="3.1-final" date="2008-06-29">
            <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d</action>
index 9bebd3a837b71209f9735a9159b3208a89d992b1..1c9b220356b736dc7d025ec1c6f76ec617110fb0 100644 (file)
@@ -30,9 +30,11 @@ import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
 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.Record;
 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 @@ public class XLS2CSVmra implements HSSFListener {
        /** 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 @@ public class XLS2CSVmra implements HSSFListener {
                
                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 @@ public class XLS2CSVmra implements HSSFListener {
                
                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 @@ public class XLS2CSVmra implements HSSFListener {
                        }
                } else {
                        thisStr = '"' + 
-                               FormulaParser.toFormulaString(null, frec.getParsedExpression()) + '"';
+                               FormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
                }
             break;
         case StringRecord.sid: