Use return value 'object' from TFlexCelUserFunctio

I wrote a simple user function to retrieve a single value from a list of objects:

class AccessorFunction : TFlexCelUserFunction
public override object Evaluate(object[] parameters)
var list = parameters.ElementAt(0) as IList;
var index = Convert.ToInt32(parameters.ElementAt(1));
return list[index];

Everything works fine, except that I have no idea how to use the return value of the function in my report as it is not a primitive datatype but an object.

I imagine something like that:


Is the usage of a user function like that supported by flexcel or is it expected to always return a primitive datatype?


Sadly the objects that you can access with a syntax like <#Accessor(<#Objects>;0)>.PropertyName
 must be objects FlexCel knows about at compile time, since the template is precompiled before running, and we can't know if an arbitrary object like the result from an user defined function has a property named "PropertyName" or not. (we raise an error if the property doesn't exist at this precompiling phase, and that is very useful since you could have mistyped PropertyName).

What maybe could be done, even if not elegant, is to define the UDF with 3 parameters like:


Then in the evaluate function, you can use Reflection to return the primitive value of Objects.PropertyName. With a little more of fiddling, you could also separate the PropertyName with dots in the Evaluate functions, so you could write: