Custom Formuals no longer work in 11.40

Posted by: FromGrapeCity on 17 December 2017, 11:35 pm EST

    • Post Options:
    • Link

    Posted 17 December 2017, 11:35 pm EST

    Custom formulas no longer work in spread version 11.40. I debugged thru this and it is passing ‘nothing’ to the custom function as opposed to the actual values. It’s a real simple custom function, its gets the number of days between dates. Before this worked fine. Also, I noticed that sometimes, not all the time, I get a warning about the AddCustomFunction being obsolete - see below. I tried to search help for more help on this but it only gives examples of the old way to add custom functions.

    Public Overloads Sub AddCustomFunction(FunctionInfo as FunctionInfo)’ is obsolete. This method has been deprecated. Use AddCustomFunction(GrapeCity.CalcEngine.Function) to add custom function instead.

  • Posted 18 December 2017, 12:28 am EST

    Here is an image of the obsolete message that get…

  • Posted 18 December 2017, 5:09 am EST

    Hi,

    There is a new calculation engine in v11, which is supposed to calculate old FunctionInfo custom functions as before with no changes required. Can you please post your custom function code? It sounds like we will need to recreate the problem and submit a bug to be fixed. If you prefer, you can attach the code in a support ticket here:

    https://www.grapecity.com/en/support/new-ticket?product=spread

    Regards,

    -Sean

  • Posted 18 December 2017, 6:58 am EST

    Hi,

    I submitted a ticket, but it was to https://supportone.componentone.com/home/casedetail/301178

    Here is the source code though…



    How do I convert the code below to use the new calc engine in version 11? I only have this one custom function and I would be fine with converting it. It would allow be to continue on. I use this function in a lot of places so its really causing me to revert back to version 10. Also, did you add a function to v11 that does date math like this. I am just getting the number of days between 2 dates. If either of the 2 dates is invalid it returns zero. You will see that in the source code below.

    Public Shared Sub AddDayDiffFunction(ByVal aoSpread As FpSpread)

    Dim sv As SheetView

    sv = aoSpread.ActiveSheet

    sv.AddCustomFunction((New DateDiffFunctionInfo))

        Dim cfs As FarPoint.Win.Spread.Model.ICustomFunctionSupport
        cfs = CType(aoSpread.ActiveSheet.Models.Data, ICustomFunctionSupport)
        cfs.AddCustomFunction(New DateDiffFunctionInfo())
    

    End Sub

    Public Class DateDiffFunctionInfo

    Inherits FarPoint.CalcEngine.FunctionInfo

    Public Overrides ReadOnly Property Name() As String
        Get
            Return "DAYSDIFF"
        End Get
    End Property
    
    Public Overrides ReadOnly Property MinArgs() As Integer
        Get
            Return 2
        End Get
    End Property
    
    Public Overrides ReadOnly Property MaxArgs() As Integer
        Get
            Return 2
        End Get
    End Property
    
    Public Overrides Function Evaluate(ByVal args() As Object) As Object
        ' Get number of days between dates, return 0 on bad dates
    
        Dim date1 As Date = FarPoint.CalcEngine.CalcConvert.ToDateTime(args(0))
        Dim date2 As Date = FarPoint.CalcEngine.CalcConvert.ToDateTime(args(1))
    
        If IsValidDate(date1) And IsValidDate(date2) Then
            Return date1.Subtract(date2).Days
        Else
            Return 0
        End If
    End Function
    

    End Class

  • Posted 18 December 2017, 11:05 am EST

    I discovered that I can use the built in DATEDIF() function instead of my custom formula, so I can use that instead of the custom formula. You still want to fix that issue, but I am good with my workaround for this issue.

  • Posted 20 December 2017, 3:40 am EST

    Hello,

    I have created a sample application using your code and it looks to be working fine. Please test the attached.

    Thanks,

    Deepak Sharma

    SpreadCustomFormulaIssue.zip

Need extra support?

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

Learn More

Forum Channels