You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2007/10/15 12:34:49 UTC

svn commit: r584721 - in /poi/trunk/src: java/org/apache/poi/hssf/model/FormulaParser.java java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java

Author: nick
Date: Mon Oct 15 03:34:40 2007
New Revision: 584721

URL: http://svn.apache.org/viewvc?rev=584721&view=rev
Log:
Allow users to get a FormulaParser armed only with a HSSFWorkbook, through a convenience method on HSSFFormulaEvaluator

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java?rev=584721&r1=584720&r2=584721&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/FormulaParser.java Mon Oct 15 03:34:40 2007
@@ -74,10 +74,17 @@
    private Workbook book;
     
     
-    /** create the parser with the string that is to be parsed
-     *    later call the parse() method to return ptg list in rpn order
-     *    then call the getRPNPtg() to retrive the parse results
-     *  This class is recommended only for single threaded use
+    /** 
+     * Create the formula parser, with the string that is to be
+     *  parsed against the supplied workbook.
+     * A later call the parse() method to return ptg list in
+     *  rpn order, then call the getRPNPtg() to retrive the
+     *  parse results.
+     * This class is recommended only for single threaded use.
+     * 
+     * If you only have a usermodel.HSSFWorkbook, and not a
+     *  model.Workbook, then use the convenience method on
+     *  usermodel.HSSFFormulaEvaluator 
      */
     public FormulaParser(String formula, Workbook book){
         formulaString = formula;

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=584721&r1=584720&r2=584721&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Mon Oct 15 03:34:40 2007
@@ -1019,7 +1019,7 @@
         return workbook.getSSTString(index).getString();
     }
 
-    Workbook getWorkbook()
+    protected Workbook getWorkbook()
     {
         return workbook;
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java?rev=584721&r1=584720&r2=584721&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java Mon Oct 15 03:34:40 2007
@@ -166,6 +166,17 @@
 
     
     /**
+     * Returns an underlying FormulaParser, for the specified
+     *  Formula String and HSSFWorkbook.
+     * This will allow you to generate the Ptgs yourself, if
+     *  your needs are more complex than just having the
+     *  formula evaluated. 
+     */
+    public static FormulaParser getUnderlyingParser(HSSFWorkbook workbook, String formula) {
+    	return new FormulaParser(formula, workbook.getWorkbook());
+    }
+    
+    /**
      * If cell contains a formula, the formula is evaluated and returned,
      * else the CellValue simply copies the appropriate cell value from
      * the cell and also its cell type. This method should be preferred over



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