ICustomFunction interface in Java version of Aspose Cells

Hi,

I was not able to find ICustomFunction interface (available in the .NET version) in the Java version of Aspose Cells. We have some custom functions that has to be run on a range of cells and are very specific to the business rules of our application.

The ICustomFunction interface would be our interface of choice for implementing it.

Thanks,
Shashi

Dear Shashi,

We will look into this feature.Thanks for your patience.

Warren,

Thanks for the update. Can you please comment on the timelines for implementing this feature?

Thanks,

Shashi

Dear Shashi,

We are testing on this feature.It will take us 1-2 days to complete it .Thanks for your patience.

Hi Shashi,

Please try this fix.The following is custom function interface. If you want to use custom function, you must implement the interface and call Workbook.calculateFormula(boolean ignoreError,ICustomFunction customFunction) method .

/**
* Allows users to add their custom formula calculation functions to extend the calculation engine.
*
*/
public interface ICustomFunction
{

/**
* Calculates the result of custom function.
* If a custom function name is not supported, please return a null reference.
* Currently there are 3 fixed context objects and some varialbe context objects:
*

1. Current Workbook object.


*

2. Current Worksheet object.


*

3. Current Cell object.


*

Others are custom function parameters text.


*
* @param functionName Custom function name, such as "MyFunc1".
* @param paramsList A list of parameters value for custom functions.
* The parameter object type is in the following types :
* Boolean,String,Integer,Double,Calendar,double[][],Double[][].
* @param contextObjects A list of context objects.
* @return Result of custom function.
* Only support return object types:
* Boolean,String,Integer,Double,Calendar,double[][],Double[][].
*
*/
Object calculateCustomFunction(String functionName,
ArrayList paramsList, ArrayList contextObjects);
}

Warren,

Thanks for providing this feature. Can you please provide some sample Java code that implements the above interface?

Thanks,
Shashi

Hi Shashi,

I attached the sample excel file and the class file which implement the interface.

In the Cell "D3", the formula is test(A1:A2), the "test" function will return A1 * A2.The following codes shows how to calculate formulas with custom functions:

Workbook workbook = new Workbook();
workbook.open("F:\\FileTemp\\Book1.xls");
Cells cells = workbook.getWorksheets().getSheet(0).getCells();
Cell cell = cells.getCell("D3");
System.out.println(cell.getStringValue());

workbook.calculateFormula(false,new CustomFunction());
System.out.println(cell.getStringValue());