https://issues.apache.org/bugzilla/show_bug.cgi?id=48526

Yegor Kozlov <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from Yegor Kozlov <[email protected]> 2010-08-12 10:27:42 EDT ---
Thanks for the patch, applied in r984796

> If you open a Workbook that has the ATP formula already present they you are
> able to assign the formula to new cells without issue.
> 
> Is this expected behavior or is there a defect with the ATP functions? Or do
> you need to alter the workbook after creation to support the ATP functions?

This is currently a limitation of POI. We can evaluate UDFs from the Analysis
Toolpack but we cannot assign formulas containing these functions. It may seem
an easy task, but unfortunately it is not. 

Firstly, FormulaParser needs additional information to process a user defined
formula token. This additional information should describe the number of
arguments and their type, type of the returned value, etc. For built-in
functions this is described by
org.apache.poi.hssf.record.formula.functionFunctionMetadata and
functionMetadata.txt, I guess we will need something similar for the Analysis
Toolpack.  

Secondly, each UDF used in a workbook must have a corresponding EXTERNALNAME
record, this is how Excel resolves user-defined functions. Suppose you open a
Workbook that has formulas with ATP functions. Each used ATP has a
corresponding EXTERNALNAME record and is registered in the workbook-global
LinkTable:

ISEVEN      --> EXTERNALNAME 
RANDBETWEEN --> EXTERNALNAME 

where all EXTERNALNAME records are aggregated in a LinkTable.

When you assign more formulas with ISEVEN and RANDBETWEEN, the FormulaParser
resolves their names via the list of EXTERNALNAME and the assignment is
successful. When you assign formulas with ISEVEN and RANDBETWEEN to a new
workbook then the LinkTable is empty and you get a "completely unknown"
exception.

Yegor

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to