Change Theme Settings
Change Theme Settings
Themes
 
Show All Themes
v
...v

Global Custom Functions

  • Undo

    Undo
    po
  • Clipboard

    Clipboard
    po
  • v
    v
    popopopo
    Font

    Font
    po
  • Alignment

    Alignment
    po
  • po
    dialogboxlauncherNumber

    Number
    po
  • Cells

    Cells
    po
  • Editing

    Editing
    po
  • Styles

    Styles
    po
  • dialogboxlauncherPage Setup

    Page Setuppo
  • dialogboxlauncherPrint

    Print
    po
  • Document Views

    Document Viewspo
  • Show

    Show
    po
  • View

    View
    po
  • Window

    Window
    po
  • Table Name
    Properties

    Properties
    po
  • Tools

    Tools
    po
  • Table Style Options

    Table Style Optionspo
  • Table Style Options

    Table Style Optionspo
  • Layout

    Layout
    po
  • PivotTable Style Options

    PivotTable Style Optionspo
 

The DevExpress ASP.NET Spreadsheet control (ASPxSpreadsheet) provides the capability to create your own custom functions. Custom functions are available for spreadsheet calculations and can be used in cell formulas in the same manner as built-in functions. A custom function executes a server custom code that performs the required calculation and returns the result.

Custom functions supported by the Spreadsheet are global - they can be accessed from all spreadsheet documents opened on the server. To create a custom function, implement the CustomFunction interface and register the function using the RegisterGlobalCustomFunction static method. It is recommended to register custom functions only once at the application level. The following demo code illustrates how this can be done in the Global.asax file's Application_Start method.

void Application_Start(object sender, EventArgs e) {
    ...
    ASPxSpreadsheet.RegisterGlobalCustomFunction(new DiscountFunction());
    ...
}

In this demo, the DiscountFunction custom function is defined. It is used in the C7 cell to calculate a discount based on the order's Quantity (C5) and Unit Price (C4) values. In the calculation, different discount rates are used depending on the total number of items in the order.


See Also: