We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LINQ Reporting Engine/Rounding of number values

Hi, I am trying to output a value with correct rounding rules. I would like to use the static member function Round(double value, int digits) of class System.Math.

The current expression in the template file would be e.g.:

<<[ds[0].Nums[3]]:"##,#0.00">>

My try with

<<[System.Math.Round(ds[0].Nums[3],1)]:"##,#0.00">>

resulted in a InvalidOperationException stating "Can not get the value of member ‘System’ on type ‘System.Collections.Generic.List’"

So, how can I do this?

Thanks for any infos on this in advance!

Regards
Christof

Hi Christof,

Thanks for your inquiry. Please note LINQ Reporting Engine must be aware of custom external types that you reference in your template before the engine processes the template. You need to add System.Math in known types of ReportingEngin using ReportingEngine.KnownTypes property as following. Please check following documentation link for more details.


// Create an instance of sender class to set it's properties.

Sender sender = new Sender { Name = "LINQ Reporting Engine", Message = "Hello World" ,Amount=12.465};

// Create a Reporting Engine.

ReportingEngine engine = new ReportingEngine();

engine.KnownTypes.Add(typeof(System.Math));

// Execute the build report.

engine.BuildReport(doc, sender, "sender");


Best regards,

Thanks a lot, Tilal!

That was exactly what I was looking for. Works great!
I wasn’t aware of the fact that this KnownTypes feature is not only for my own types but for all external types.

Best Regards
Christof