Table of Contents

TFlexCelReport.SetUserFunction Method

Adds a new user defined function to be used with the report. The User function object is managed by the report, so you don't have to free it once you used this method to add it to the report. For information on how to create the user function, see TFlexCelUserFunction

Syntax

Unit: FlexCel.Report

procedure TFlexCelReport.SetUserFunction(const name: string; const functionImplementation: TFlexCelUserFunction);

Parameters

<-> Parameter Type Description
const name string Name that the function will have on the report. Case insensitive.
const functionImplementation TFlexCelUserFunction An implementation of the user function.

Examples

You can define a function "MF" on the following way:

  myFuncImpl := TMyUserFunction.Create;  //The MyUserFunction class implements an user defined function.
  //Note that we don't have to free myFuncImpl, it will be freed by the report once it is over.
  flexCelReport.SetUserFunction('MF', myFuncImpl);  //The name used in Excel will be =MF().

Then, if you write <#MF(param1, param2... paramn)> on a cell, the function will be called and the result shown. Note that the name is case insensitive, so both "MF" and "mf" refer to the same function.

See also