Code Module is used to add a custom code or custom assemblies to a report. Code module allows to add references to custom code embedded in a report or generated with custom assemblies.
Code
category, click Code… to open Code Module dialog.
The following code example demonstrates the custom function that returns the color string based on the given value range.
Public Function GetColor(ByVal TotalSales As Decimal) As String
Dim ColorName As String
If TotalSales > 0 And TotalSales < 1000 Then
ColorName = "Yellow"
ElseIf TotalSales > 1000 And TotalSales < 1500 Then
ColorName = "Blue"
ElseIf TotalSales > 2000 Then
ColorName = "Red"
Else
ColorName = "Green"
End If
Return ColorName
End Function
Preview
.
To embed a custom assemblies in a report, create a simple visual studio class library project and define the required custom functions.
(.dll)
will be generated in the bin folder of the respective application.Note: To embed the custom assembly into the report, the generated assembly must be installed in GAC or it must be available in reporting services
bin
location. We prefer to manually copy and paste the generated custom assembly into the following path C:\Syncfusion\Report Server\ReportServer.Web\ReportService\bin.
Use the following expression to call the embedded custom code function in the report.
Refer Expression section to learn more about handling expressions.
Preview
.
Download the above report design from link