Stimulsoft Reports.NET discussion
ivar
Posts: 21 Joined: Tue Aug 04, 2015 11:41 am
Post
by ivar » Thu May 07, 2020 12:36 pm
Hello,
I have registered a custom aggregate function using:
Code: Select all
StiOptions.Services.AggregateFunctions.Add(new SumMoneyFunctionService());
This aggregate function doesn't work when the report calculation mode is 'Interpretation'
Is there a way to make it work?
Regards, Ivar
Lech Kulikowski
Posts: 6263 Joined: Tue Mar 20, 2018 5:34 am
Post
by Lech Kulikowski » Mon May 11, 2020 7:05 am
Hello,
Please try to use the following code for adding custom functions:
Code: Select all
public class MyFunction
{
private const string Category = "MyFuncCategory";
public static string MyFunc(string value)
{
return value.ToUpper();
}
public static void RegisterFunctions()
{
var ParamNames = new string[1];
var ParamTypes = new Type[1];
var ParamDescriptions = new string[1];
ParamNames[0] = "value";
ParamDescriptions[0] = "Descriptions";
ParamTypes[0] = typeof(string);
Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
}
}
Thank you.
ivar
Posts: 21 Joined: Tue Aug 04, 2015 11:41 am
Post
by ivar » Mon May 11, 2020 7:42 am
Thanks,
I used that to add custom functions for expressions and it works.
But how do I add a function to sum multiple lines like in the screenshot?
Regards, Ivar
Attachments
Untitled.png (18.96 KiB) Viewed 2255 times
HighAley
Posts: 8431 Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office
Post
by HighAley » Tue May 12, 2020 9:27 pm
Hello,
Sorry, there is no way to do this.
Different report events are used for the calculations.
You could use the events to make your calculations.
Thank you.
ivar
Posts: 21 Joined: Tue Aug 04, 2015 11:41 am
Post
by ivar » Thu May 14, 2020 10:09 am
ok, not really what I wanted to hear but thanks anyway.
HighAley
Posts: 8431 Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office
Post
by HighAley » Thu May 14, 2020 12:23 pm
Hello.
Anyway you have to add code to report events and there is no way to get it using the custom function.
As a way you could try to do it in our source code. It's available for purchase.
Thank you.
ivar
Posts: 21 Joined: Tue Aug 04, 2015 11:41 am
Post
by ivar » Thu May 14, 2020 6:03 pm
I'll see what I can achieve with the report events. The problem is that many reports would need this custom code and our customers wouldn't know how to edit them without breaking the report. But I can solve it by calculating the totals in the businessobjects beforehand so I have a workaround.
Source code is not really an option I'm afraid. As soon as we start adding our own code we have to maintain it. I already have thousands of lines of code to maintain. I rather use the library as-is as long as most of what we want to achieve is possible.
Thanks for the information.