We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Returning Value from ICustomFunction

I'm using version of Aspose.Cells in Visual Basic .NET, and I'm having trouble returning a value from my CalculateCustomFunction function.

I'm assuming that I can return a boolean, integer, double, string, etc. as the Java documentation states, but when I include an empty CalculateCustomFunction function that simply returns a value (for example, 5) and use "=CUSTFUNC(1)+1" in my workbook, it has no effect. It should change it to 6, correct? Or am I misunderstanding?

When stepping through the code, I can see that CalculateCustomFunction is being called with functionName = "CUSTFUNC", it's just that I'm not sure what to return.


Thanks for considering Aspose.

How do you write code and implement ICustomFunction, Could you create a sample console test Application, zip it and post it here to show the issue, We will check it soon.

By the way, following sample shows how to use ICustomFunction interface:

Class CustomFunction

Imlements Aspose.Cells.ICustomFunction

Public Function CalculateCustomFunction(ByVal functionName As String, ByVal paramsList As ArrayList, ByVal contextObjects As ArrayList) As Object


End Function

End Class


Dim wb As Workbook = New Workbook()


Dim customFunction As CustomFunction = New CustomFunction()
wb.CalculateFormula(false, customFunction)


Thank you.


I apologize for taking so long to reply.

I have attached an example of what I'm trying to do (very simple, just trying to return a value from my custom function).

It's my understanding that I can return a value from my custom function, and Aspose.Cells will replace the reference to CUSTFUNC() with the value I return. Am I misunderstanding the purpose of custom functions?

CalculateFormula function returns correct result at run time but it won't change the file. To replace cell with correct value, please try following code:

Sub Main()
Const WORKBOOK_NAME As String = "..\..\..\test.xls"

Dim lic As New Aspose.Cells.License()

'Open the workbook
Dim wbk As New Aspose.Cells.Workbook

wbk.CalculateFormula(False, New CustomFunction)


'Save the workbook
End Sub