Share via


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