The final operand class chosen for each token depends on the formula type and the token's place in the formula. If POI gets the operand class wrong, Excel may interpret the formula incorrectly. This condition is typically manifested as a formula cell that displays as '#VALUE!', but resolves correctly when the user presses F2, enter.
The logic implemented here was partially inspired by the description in "OpenOffice.org's Documentation of the Microsoft Excel File Format". The model presented there seems to be inconsistent with observed Excel behaviour (These differences have not been fully investigated). The implementation in this class has been heavily modified in order to satisfy concrete examples of how Excel performs the same logic (see TestRVA).
Hopefully, as additional important test cases are identified and added to the test suite, patterns might become more obvious in this code and allow for simplification.
| Modifier and Type | Field and Description |
|---|---|
| private final FormulaType |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | |
| private static boolean | |
| private void | setSimpleValueFuncClass(AbstractFunctionPtg afp, byte desiredOperandClass, boolean callerForceArrayFlag)
|
| private byte | |
| public void | transformFormula(ParseNode rootNode)
Traverses the supplied formula parse tree, calling |
| private void | transformFunctionNode(AbstractFunctionPtg afp, ParseNode[] children, byte desiredOperandClass, boolean callerForceArrayFlag)
|
| private void | transformNode(ParseNode node, byte desiredOperandClass, boolean
true if one of the current node's parents is a
function Ptg which has been changed from default 'V' to 'A' type (due to requirements on
the function return value).
|
| _formulaType | back to summary |
|---|---|
| private final FormulaType _formulaType | |
| OperandClassTransformer | back to summary |
|---|---|
| public OperandClassTransformer(FormulaType formulaType) | |
| isSimpleValueFunction | back to summary |
|---|---|
| private static boolean isSimpleValueFunction(Ptg token) | |
| isSingleArgSum | back to summary |
|---|---|
| private static boolean isSingleArgSum(Ptg token) | |
| setSimpleValueFuncClass | back to summary |
|---|---|
| private void setSimpleValueFuncClass(AbstractFunctionPtg afp, byte desiredOperandClass, boolean callerForceArrayFlag) | |
| transformClass | back to summary |
|---|---|
| private byte transformClass(byte currentOperandClass, byte desiredOperandClass, boolean callerForceArrayFlag) | |
| transformFormula | back to summary |
|---|---|
| public void transformFormula(ParseNode rootNode) Traverses the supplied formula parse tree, calling | |
| transformFunctionNode | back to summary |
|---|---|
| private void transformFunctionNode(AbstractFunctionPtg afp, ParseNode[] children, byte desiredOperandClass, boolean callerForceArrayFlag) | |
| transformNode | back to summary |
|---|---|
private void transformNode(ParseNode node, byte desiredOperandClass, boolean callerForceArrayFlag)
| |