When exporting the Telerik RadGrid to Excel, the "Attempted to divide by zero" exception is thrown. The grid contains calculated columns such as getting the percentage, etc.
In Mathematics, dividing a number by zero is undefined. We can check first if the divisor is zero and return zero as the result.
String.Format("{0:0.00%}", group.Sum(i => i.myDivisor) == 0 ? 0 : group.Sum(i => i.myDividend) / group.Sum(i => i.myDivisor) ),
No comments:
Post a Comment