DO NOT REPLY [Bug 34828] New: - [PATCH] FormulaEvaluator Partial Implementation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

DO NOT REPLY [Bug 34828] New: - [PATCH] FormulaEvaluator Partial Implementation

Bugzilla from bugzilla@apache.org
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG?
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34828>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND?
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34828

           Summary: [PATCH] FormulaEvaluator Partial Implementation
           Product: POI
           Version: 2.5
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: [hidden email]
        ReportedBy: [hidden email]


This is the preview of the HSSFFormulaEvaluator. The design is modular, so
anybody should be able to contribute the Excel function library implementation.
Currently about 20-30 functions are implemented (admittedly buggy).
Comments invited.

README.txt follows:
*** WARNING: This is a work in progress  :) ***



*********************** TESTING *********************
Quick Test:
No JUnit tests are provided as of now. For a quick test (and guaranteed results)
use eclipse!
After applying patch to HEAD, go to
                   xxxxxx.hssf.usermodel.HSSFFormulaEvaluator
This class has a main method so it can be run from eclipse.
Be sure you adjust the file path that is hard coded in the main method to point
to the included
test excel.

The HSSFFormulaEvaluator interface is not complete so as of now there is only
one method that
you can use in case you want to do custom testing:
                   evaluateToString(formula, sheet, wb)



****************** BLAH *******************

Basic description:
1. Take the cell formula string, parse it into RPN tokens using FormulaParser.
2. For each RPN token:
   If it is operation token, pop the numberOfOperands reqd by this operation
     Create approproate OperationEval instance and perform the operation by
calling "evaluate"
   If it is an AreaPtg token, evaluate every cell in the area, create 1D Array
of values, put values there
     For area tokens, use AreaEval to store the reference to AreaPtg and the
array of values.
     Push AreaEval.
   If it is ReferencePtg token, evaluate it, put the ReferencePtg and the value
in RefEval.
     Push RefEval.
   Else, it is one of IntPtg, NumberPtg, StringPtg, BoolPtg -> these are pushed on
     Push a ValueEval
3. Eventually there will be just one token on stack (if all goes well).
   This can either be NumericEval, StringEval or RefEval.
   for RefEval, one more step is required to extract the inner ValueEval
4. Done.


****************** BLAH BLAH *******************

File/Class organization:
0. Formulatokens are mapped to Eval impls
1. Base interface for all Evals is.... "Eval" !!!
2. This is extended as follows:
   
   ValueEval extends Eval: For value elements (ie. not operations)
   OperationEval extends Eval: For operation elements
   
   NumericValueEval extends ValueEval: For value elements that can be directly
evaluated as numbers
   StringValueEval extends ValueEval: For value elements that can be directly
evaluated as strings
   ErrorEval extends ValueEval: Error values
   
   AddEval, SubtractEval etc. implement OperationEval: Individual operations
   FunctionEval implements OperationEval: For special operations that are functions
   
   FuncVarEval extends FunctionEval: Operations that are functions.
     Note: this is because I dont know what FuncPtg does. In case I need it, I
will extend FuncPtg from FunctionEval.
     Hence I have FunctionEval
   
   *** functions ***
   functions are in package: xxxxx.hssf.record.formula.functions
   Base interface is Function
   DefaultFunctionImpl extends Function: For functions that are not yet implemented.
     default behavious is to return ErrorEval (resutls in the entire value being
an error of type FUNCTION_NOT_IMPLEMENTED.
   Individual function classes extend from DefaultFunctionImpl.

--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/