This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestArrayCustomFunction.vb
54 lines (50 loc) · 2.26 KB
/
TestArrayCustomFunction.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Imports DevExpress.Spreadsheet
Imports DevExpress.Spreadsheet.Functions
Imports System.Collections.Generic
Imports System.Globalization
Namespace CustomFunctionReturningArrayExample
#Region "#TestArrayCustomFunctionImplement"
Public Class TestArrayCustomFunction
Implements ICustomFunction
Private name_Renamed As String = "TESTARRAY"
Private parameters_Renamed() As ParameterInfo = { New ParameterInfo(ParameterType.Array, ParameterAttributes.Required) }
Private return_type As ParameterType = ParameterType.Array
Public ReadOnly Property Name() As String Implements ICustomFunction.Name
Get
Return Me.name_Renamed
End Get
End Property
Public ReadOnly Property Parameters() As ParameterInfo() Implements ICustomFunction.Parameters
Get
Return Me.parameters_Renamed
End Get
End Property
Public ReadOnly Property ReturnType() As ParameterType Implements ICustomFunction.ReturnType
Get
Return Me.return_type
End Get
End Property
Public ReadOnly Property Volatile() As Boolean Implements ICustomFunction.Volatile
Get
Return False
End Get
End Property
Public Function GetName(ByVal culture As CultureInfo) As String Implements ICustomFunction.GetName
Return Name
End Function
Public Function Evaluate(ByVal parameters As IList(Of ParameterValue), ByVal context As EvaluationContext) As ParameterValue Implements ICustomFunction.Evaluate
Dim args(,) As CellValue = parameters(0).ArrayValue
Dim xDim As Integer = args.GetLength(0)
Dim yDim As Integer = args.GetLength(1)
Dim result(xDim - 1, yDim - 1) As CellValue
For n As Integer = 0 To args.GetLength(0) - 1
For m As Integer = 0 To result.GetLength(1) - 1
Dim coeff As Double = If(args(n, m).NumericValue = 0, 1, args(n, m).NumericValue)
result(n, m) = (n + 1) * (m + 1) * coeff
Next m
Next n
Return result
End Function
End Class
#End Region ' #TestArrayCustomFunctionImplement
End Namespace