This is a migrated thread and some comments may be shown as answers.

Custom function

1 Answer 146 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Predrag
Top achievements
Rank 1
Predrag asked on 12 Aug 2013, 01:43 PM
HI, is it possible to add custom function in spreadsheet control?

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 13 Aug 2013, 03:15 PM
Hello Predrag,

First I'd like to thank you for your interest in RadSpreadsheet!

It is possible to create custom functions with RadSpreadsheet. Additionally you have great flexibility when handling different cases for the type and count of function arguments, as well as different options for parsing or raising errors on specific argument types. 

In order to create a custom function you need to inherit from the FunctionBase class or any of its inheritors (NumbersInFunction,  StringsInFunction, BooleansInFunction, etc.) depending on what best suits your needs. By inheriting such a class you need to override the Name and FunctionInfo properties and EvaluateOverride method which returns the result from function calculations.

Each function may have required arguments and optional arguments (the latter may allow repetitions).

You may additionally specify concrete argument conversion rules if the default one coming from the inherited class doesn't suit your needs entirely.

Finally, after you have implemented the new function class, you need to register it using FunctionManager's RegisterFunction method.

I am sending you a demo project where you can see the implementation of a GeoMean function class, calculating the Geometric mean of a sequence of numbers. You may see function registration in MainWindow constructor which looks like:

FunctionManager.RegisterFunction(new GeoMean());

I hope this information is helpful! If you have any other question on a concrete function implementation please do not hesitate to contact us again!

Regards,
Deyan
the Telerik team
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Spreadsheet
Asked by
Predrag
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or