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