GrapeCity.CalcEngine Evaluation of Custom Function

Posted by: kevin.keller on 23 June 2019, 11:00 pm EST

    • Post Options:
    • Link

    Posted 23 June 2019, 11:00 pm EST

    Is there a way in the GrapeCity.CalcEngine for the Evaluate method to have a custom handling of specific value in the arguments, where when the specific condition is not present to pass the arguments to an existing standard calculation and return the result from the standard calculation.

    In the following function definition I would like to return 1 when a user creates a cell formula like ROWS2() with no arguments but if arguments are passed I would like to just have the existing ROWS function handle the evaluation passing it the ARGS that were passed to ROWS2.

    Public Class Rows2FunctionInfo

    Inherits [Function]

    Public Sub New()
        MyBase.New("ROWS2", 0, 1, FunctionAttributes.Array)
    End Sub
    
    Protected Overrides Sub Evaluate(ByVal args As IArguments, ByVal result As IValue)
    
        Try
            If args.Count = 0 Then
                result.SetValue(1)
            Else
                [b]result.SetValue(GrapeCity.CalcEngine.RowFunction.Evaluate(args))
    

    [/b] End If

    Catch ex As Exception

    result.SetValue(“#ERROR EVALUATING ROWS2#”)

    End Try

    End Sub
    

    End Class

    Is there any Documentation on implementing the GrapeCity.CalcEngine that has details on custom Function creation and tips and tricks or any additional resources for that CalcEngine?

    Any Assistance would be appreciated,

    Kevin

  • Posted 25 June 2019, 11:46 pm EST

    Hello Kevin,

    Firstly, apologies for the delayed response.

    Regarding creating custom functions, following is a documentation link: https://help.grapecity.com/spread/SpreadNet12/WF/webframe.html#spwin-formulacustomfunc.html

    See if that helps you.

    Thanks,

    Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels