Introduced in build 9.1
Description
The RegisterCustomFunction method registers an IFunction object with the workbook to be used when calculating a specific custom Excel formula.C#
public void RegisterCustomFunction( string customFunctionName, IFunction customFunction) |
vb.net
Public Sub RegisterCustomFunction(customFunctionName As String , customFunction As IFunction) |
Parameters
customFunctionName
The name of the Excel Function you want to bind your custom IFunction logic to.customFunction
The custom logic you want to use for a specific Excel formula. You implement this logic by using the IFunction interfaceExamples
C#
//Create an ExcelApplication object ExcelApplication xla = new ExcelApplication(); //Open a workbook containing formulas Workbook wb = xla.Open("FormulasWorkbook.xlsx); // Create an instance of the custom function implementation IFunction myCustomFunction = new MyCustomFunction(); //Register the custom function wb.RegisterCustomFunction( "MyCustomFunction" , myCustomFunction); |
VB
'Create an ExcelApplication object Dim xla As New ExcelApplication 'Open a workbook containing formulas Dim wb As Workbook = xla.Open( "formulasWorkbook.xlsx" ) 'Create an instance of the custom function implementation Dim myCustomFunction As IFunction = new MyCustomFunction() 'Register the custom function wb.RegisterCustomFunction( "MyCustomFunction" , myCustomFunction) |
Exceptions
SAException
If the custom function has already been registered with the workbook.