Forum Discussion

bvuHH's avatar
bvuHH
Copper Contributor
Jul 06, 2025

SSRS Use Excel WorksheetFunction.Round method in custom code

Hi,

I'm trying to implement a custom code function to be used in an expression of my SSRS report but I'm unable to get it running.

 

Here's what I have so far:

 

Report Properties - References:

Assembly Microsoft.Office.Interop.Excel, Version=15.0.0.0

 

Report Properties - Code

Public Function fRunden(Wert as Double, Dec as Double) as Double
          Dim excelApp As New Microsoft.Office.Interop.Excel.Application
          dim roundval as double 
          roundval = excelApp.WorksheetFunction.Round (Wert, Dec) 
          Return roundval 
end function 

 

 

In the Tablix Textbox I've added the following expression:

=Code.fRunden((sum(Fields!Hours.Value,"GroupDataset")/sum(Fields!Hours.Value,"TotalDataset"))*100,2)

Howerver, rendering the report results in #Error in the textbox

From the Microsoft language documentation the WorksheetFunction is implemented as an interface.

So I'm not sure if I correctly use the objects in my custom code.

Any help is greatly appreciated.

Thanks

No RepliesBe the first to reply

Resources