.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
A newer version of this page is available. Switch to the current version.

FunctionWrapper Class

A base class that allows you to override a built-in spreadsheet function.

Namespace: DevExpress.Spreadsheet.Functions

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll


public abstract class FunctionWrapper :


This example creates a function that calculates the sine of an angle measured in degrees and uses that function to replace the built-in SIN worksheet function.

The collection of worksheet functions is available by using the IWorkbook.Functions property. The WorkbookFunctions.OverrideFunction method is used to override a worksheet built-in function. The method requires the function to replace and a custom function with which the built-in function will be replaced.

To create a custom function, implement the FunctionWrapper descendant and override the FunctionWrapper.Evaluate method.

using DevExpress.Spreadsheet.Functions;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
        private void ReplaceSinFunction()
            WorkbookFunctions functions = spreadsheetControl1.Document.Functions;
            // Obtain the built-in function to override.
            IFunction sinFunction = functions.Math.Sin;
            // Create a new function descending from the FunctionWrapper
            // to replace the built-in function.
            OverridenFunction function = new OverridenFunction(sinFunction);
            // Substitute the built-in function with the custom function.
            functions.OverrideFunction(function.Name, function);

        // A custom function that calculates the sine function for the angle measured in degerees.
        public class OverridenFunction : FunctionWrapper

            public OverridenFunction(IFunction function)
                : base(function)

            public override ParameterValue Evaluate(IList<ParameterValue> parameters, EvaluationContext context)
                ParameterValue value = parameters[0];
                if (value.IsError)
                    return value;

                double angle = parameters[0].NumericValue * Math.PI / 180;
                double sin = Math.Sin(angle);
                return Math.Round(sin, 5);


See Also