Search results
Suggest a FeaturePDF

This section is specifically for Bold Reports® version less than 3.x. If you are using a higher version of Bold Reports®, recommend you to embed the VB code directly in the report itself, as VBCodeProvider is now available in the .NET Core platform.

How to use custom code with Report Writer

Custom code in a report allows to include new custom constants, variables, functions, or subroutines. As the VBCodeProvider is not available in .NET Core platform, report with custom codes requires additional settings to enable this feature. This section describes the steps required to use custom codes with Report Writer.

Create a custom code class file

  1. Create a new C# class file in your application.
  2. The namespace should be BoldReports.Processing.Helper and class declaration should be public static class Code.
  3. Write the C# methods equivalent to your report VB codes.
  4. Here is the example code to convert the value to USD.
namespace BoldReports.Processing.Helper
{
    public static class Code
    {
        public static string PrintHelloWorld()
        {
            return "Hello World";
        }
    }
}

Create a assembly reference and add it to Report Writer

If you have created the custom code class, then you need to add the assemblies in the list with what you have used in your application to Report Writer as shown in following code example.

using (var reportWriter = new ReportWriter())
{
    reportWriter.Assemblies.Add(this.GetType().GetTypeInfo().Assembly);
    reportWriter.LoadReport(inputStream);
}

If you want to use the custom code feature, then you should not use the ReportWriter(Stream ReportStream) constructor to load the report and assemblies added with Assemblies property before using LoadReport method.