UdfClassAttribute class

Marks a class as a user-defined function class.

Inheritance hierarchy

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

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

Syntax

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

Remarks

To use custom functions in a class as Excel Services user-defined functions, you should mark your user-defined function class with this attribute. Any classes that are not marked with this attribute in the user-defined function assembly are ignored by Excel Calculation Services. They are not considered Excel Services user-defined function classes.

Examples

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

namespace MyExcelServicesUdf
{
    [UdfClass]
    public class MyUdfs
    {
        Random rand = new Random();

        [UdfMethod(IsVolatile=true)]
        public int GetRandomNumber()
        {
            return (rand.Next(0, 1000));
        }
    }
}

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

UdfClassAttribute members

Microsoft.Office.Excel.Server.Udf namespace