UdfMethodAttribute Class

Marks a function as a user-defined function (UDF) method.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.Office.Excel.Server.Udf.UdfMethodAttribute

Namespace:  Microsoft.Office.Excel.Server.Udf
Assembly:  Microsoft.Office.Excel.Server.Udf (in Microsoft.Office.Excel.Server.Udf.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class UdfMethodAttribute _
    Inherits Attribute
'Usage
Dim instance As UdfMethodAttribute
[AttributeUsageAttribute(AttributeTargets.Method)]
public sealed class UdfMethodAttribute : Attribute

Remarks

To use custom functions in a class as Excel Services UDFs, you should mark your UDF methods with this attribute. Any methods that are not marked with this attribute in the UDF assembly are ignored by Excel Calculation Services. They are not considered Excel Services UDF methods.

Examples

using System;
using Microsoft.Office.Excel.Server.Udf;

namespace MyExcelServicesUdf
{
    [UdfClass]public class MyUdfs
    {
        [UdfMethod]public int MyFunction()
        {
            i = (i + 88) * 2;
            return i;
        }
    }  
}
Imports System
Imports Microsoft.Office.Excel.Server.Udf

Namespace MyExcelServicesUdf
    <UdfClass>
    Public Class MyUdfs
        <UdfMethod>
        Public Function MyFunction() As Integer
            i = (i + 88) * 2
            Return i
        End Function
    End Class
End Namespace

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

UdfMethodAttribute Members

Microsoft.Office.Excel.Server.Udf Namespace