This section is specifically for Bold Reports® version less than 3.x. If you are using a higher version of Bold Reports®, we recommend that you 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

To use custom code with the Bold Reports® ASP.NET Core Report Writer, write C# methods equivalent to your report VB code in a custom code class and add its assembly to the Report Writer before you load the report. Custom code in a report lets you include new custom constants, variables, functions, or subroutines. As the VBCodeProvider is not available in the .NET Core platform, a report with custom code requires additional settings to enable this feature.

How do I create a custom code class file?

To create a custom code class file for the Report Writer, add a C# class in the BoldReports.Processing.Helper namespace and declare it as public static class Code.

  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";
        }
    }
}

How do I add the assembly reference to the Report Writer?

To add the custom code class to the Report Writer, add the assembly that contains it to the Assemblies property of the Report Writer before you call the LoadReport method, as in the 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.