Search results

Display ssrs rdl report in Bold Reports HTML5 JavaScript Report Viewer

This section explains you the steps required to create your first JavaScript reporting application to display already created SSRS RDL report in Bold Reports HTML5 JavaScript Report Viewer without using a Report Server.

HTML file creation

Create a basic HTML file as shown below and place it in a separate folder.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Report Viewer first HTML page</title>
    </head>
    <body>
    </body>
</html>

Refer scripts and CSS

Directly refer all the required scripts and style sheets from CDN links that are mandatorily required to use the Report Viewer as in the following order.

  • bold.reports.all.min.css
  • jquery-1.10.2.min.js
  • ej2-base.min.js, ej2-data.min.js, ej2-pdf-export.min.js, ej2-svg-base.min.js, ej2-lineargauge.min.js and ej2-circulargauge.min.js - Render the gauge item. Add these scripts only if your report contains the gauge report item.
  • ej2.map.min.js - Renders the map item. Add this script only if your report contains the map report item.
  • bold.reports.common.min.js
  • bold.reports.widgets.min.js
  • ej.chart.min.js - Renders the chart item. Add this script, only if your report contains the chart report item.
  • bold.report-viewer.min.js

Refer to the Bold Reports CDN to learn more details about Bold Reports CDN scripts and style sheets links.

You can replace the following code in <head> tag of the Report Viewer HTML page.

Whether you want to get the scripts and style sheets as local, then install the BoldReports.Javascript NuGet package in your application.

<link href="https://cdn.boldreports.com/2.3.26/content/material/bold.reports.all.min.css" rel="stylesheet" />
<script src="https://cdn.boldreports.com/external/jquery-1.10.2.min.js" type="text/javascript"></script>

<!--Render the gauge item. Add this script only if your report contains the gauge report item. -->
<script src="https://cdn.boldreports.com/2.3.26/scripts/common/ej2-base.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/common/ej2-data.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/common/ej2-pdf-export.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/common/ej2-svg-base.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/data-visualization/ej2-lineargauge.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/data-visualization/ej2-circulargauge.min.js"></script>

<!--Render the map item. Add this script only if your report contains the map report item.-->
<script src="https://cdn.boldreports.com/2.3.26/scripts/data-visualization/ej2.map.min.js"></script>

<!-- Report Viewer component script-->
<script src="https://cdn.boldreports.com/2.3.26/scripts/common/bold.reports.common.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/common/bold.reports.widgets.min.js"></script>

<!--Render the chart item. Add this script only if your report contains the chart report item.-->
<script src="https://cdn.boldreports.com/2.3.26/scripts/data-visualization/ej.chart.min.js"></script>
<script src="https://cdn.boldreports.com/2.3.26/scripts/bold.report-viewer.min.js"></script>

To learn more about rendering a report with data visualization report items, refer to the how to render data visualization report items section.

Adding Report Viewer Widget

Add the <div> element within the <body> section, which acts as a container for boldReportViewer widget to render and then initialize the boldReportViewer widget within the script section as shown below,

<div style="height: 600px; width: 950px;">
    <!-- Creating a div tag which will act as a container for boldReportViewer widget.-->
    <div style="height: 600px; width: 950px; min-height: 400px;" id="viewer"></div>
    <!-- Setting property and initializing boldReportViewer widget.-->
    <script type="text/javascript">
        $(function () {
            $("#viewer").boldReportViewer();
        });
    </script>
</div>

Create Web API service

The Report Viewer requires a Web API service to process the report files. You can skip this step and use the online Web API services to preview the already available reports or you should create any one of the following Web API services:

If you are looking to load the report directly from SQL Server Reporting Services (SSRS), then you can skip the following steps and move to SSRS Report.

Adding already created report

If you have created a new service, you can add the reports from the Bold Reports installation location. For more information, refer to samples and demos section.

  1. Create a folder Resources in your Web API application to store RDL reports and add the already created reports to it.

  2. Add already created reports to the newly created folder.

    In this tutorial, the sales-order-detail.rdl report is used, and it can be downloaded in this link.

To create new report refer to the create RDL report section.

Set report path and Web API service

To render the reports available in your application, set the reportPath and reportServiceUrl properties of the Report Viewer.

<div style="height: 600px; width: 950px;">
    <!-- Creating a div tag which will act as a container for boldReportViewer widget.-->
    <div style="height: 600px; width: 950px; min-height: 400px;" id="viewer"></div>
    <!-- Setting property and initializing boldReportViewer widget.-->
    <script type="text/javascript">
        $(function () {
            $("#viewer").boldReportViewer({
                reportServiceUrl: "https://demos.boldreports.com/services/api/ReportViewer",
                reportPath: '~/Resources/docs/sales-order-detail.rdl'
            });
        });
    </script>
</div>

In the above code, the sales-order-detail.rdl report and reportServiceUrl used from online URL. You can view the already created Web API service from the Reporting Service git hub location. For more information, see samples and demos section.

Preview the report

Open your HTML page in the web browser and the Report Viewer will display the report as shown below.

index.html
index.js
ReportViewerController.cs
    <body style="overflow: hidden; position: static; margin: 0; padding: 0; height: 100%; width: 100%;">
    <div id="viewer" style="position: absolute; height: 100%; width: 100%;"></div>
    <script src="index.js"></script>
    </body>
$(function () {
    $("#viewer").boldReportViewer({
        reportServiceUrl: "https://demos.boldreports.com/services/api/ReportViewer",
        reportPath: '~/Resources/docs/sales-order-detail.rdl'
    });
});
   public class ReportViewerController : ApiController, IReportController
    {
        // Post action for processing the RDL/RDLC report
        public object PostReportAction(Dictionary<string, object> jsonResult)
        {
            return ReportHelper.ProcessReport(jsonResult, this);
        }

        // Get action for getting resources from the report
        [System.Web.Http.ActionName("GetResource")]
        [AcceptVerbs("GET")]
        public object GetResource(string key, string resourcetype, bool isPrint)
        {
            return ReportHelper.GetResource(key, resourcetype, isPrint);
        }

        // Method that will be called when initialize the report options before start processing the report
        public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            // You can update report options here
        }

        // Method that will be called when reported is loaded
        public void OnReportLoaded(ReportViewerOptions reportOption)
        {
            // You can update report options here
        }
    }

See Also

Render report with data visualization report items

Render Report Server reports

Create RDLC report

Render RDLC reports

Preview report in print mode

Set data source credential for shared data sources

Change data source connection string

List of SSRS server versions are supported in Bold Reports