Search results
Suggest a FeaturePDF

Export SSRS Report Server Report

Report Writer has support to Export RDL reports into popular file formats such as PDF, Microsoft Word, Microsoft Excel, and CSV from SSRS Report Server.

To export the SSRS Reports, set the ReportProcessingMode, ReportServerURL, and ReportPath properties in Web API as shown in the following steps.

  1. To create your first ASP.NET Web Forms Report Writer application, refer to the Getting-started section.

  2. Set the reportProcessignMode API for Bold Report Writer as shown in the following code snippet.

    protected void ExportButton_Click(object sender, EventArgs e)
    {
        BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();
        writer.ReportProcessingMode = ProcessingMode.Remote;
    }
  3. Set the reportServerUrl API for Bold Report Writer with Web Service URL in the WebAPI as shown in the following code snippet.

    protected void ExportButton_Click(object sender, EventArgs e)
    {
        BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();
        writer.ReportProcessingMode = ProcessingMode.Remote;
        writer.ReportServerUrl = "http://<servername>/Reports_SSRS";
    }

    The Web Service URL should be set as reportServerUrl when using ASP.NET Web Forms service. The Web Service URL can be found from the Reporting Services Configuration manager under the Web Service URL section, as shown in the following image. SSRS report server web service URL as report server URL

  4. Set the report path for loading the reports from the SSRS Report Server. The report path should be in the format of /folder name/report name.

    protected void ExportButton_Click(object sender, EventArgs e)
    {
        BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();
        writer.ReportProcessingMode = ProcessingMode.Remote;
        writer.ReportServerUrl = "http://<servername>/Reports_SSRS";
        writer.ReportPath= Server.MapPath("/SSRSSamples2/Territory Sales");
    }

    The report path can be found from the SSRS Report Server by navigating to the path of the report to be loaded, as shown in the following image. SSRS report server report path

Network credentials for SSRS

The network credentials are required to load specified SSRS report from the specified SSRS Report Server using the Report Writer. Specify the ReportServerCredential property in writer instance.

writer.ReportServerCredential = new System.Net.NetworkCredential("username", "password");

If you are facing problem to access the SSRS Report server reports, you can refer How to provide the permission for user to access the SSRS Report Server reports.

Set data source credential to shared data sources

The SSRS Report Server does not provide options to get credential information of the report data source deployed on the SSRS Server. If the report has any data source that uses credentials to connect with the database, then you should specify the DataSourceCredentials for each report data source to establish database connection.

List<BoldReports.Web.DataSourceCredentials> dataSourceCredentialsList = new List<BoldReports.Web.DataSourceCredentials>();
dataSourceCredentialsList.Add(new BoldReports.Web.DataSourceCredentials("datasource name", "username", "password"));
writer.SetDataSourceCredentials(dataSourceCredentialsList);

Data source credentials should be added to the shared data sources that do not have credentials in the connection strings.

Refer to the following final code snippet example to export the SSRS report server reports.

protected void ExportButton_Click(object sender, EventArgs e)
{
    string fileName = null;
    WriterFormat format;
    HttpContext httpContext = System.Web.HttpContext.Current;
    BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();
    writer.ReportProcessingMode = ProcessingMode.Remote;
    writer.ReportServerUrl = "http://<servername>/Reports_SSRS";
    writer.ReportPath= Server.MapPath("/SSRSSamples2/Territory Sales");
    writer.ReportServerCredential = new System.Net.NetworkCredential("username", "password");
    List<BoldReports.Web.DataSourceCredentials> dataSourceCredentialsList = new List<BoldReports.Web.DataSourceCredentials>();
    dataSourceCredentialsList.Add(new BoldReports.Web.DataSourceCredentials("datasource name", "username", "password"));
    writer.SetDataSourceCredentials(dataSourceCredentialsList);

    if (this.ExportFormat.SelectedValue == "PDF")
    {
        fileName = "sales-order-detail.pdf";
        format = WriterFormat.PDF;
    }
    else if (this.ExportFormat.SelectedValue == "Word")
    {
        fileName = "sales-order-detail.docx";
        format = WriterFormat.Word;
    }
    else if (this.ExportFormat.SelectedValue == "Html")
    {
        fileName = "sales-order-detail.Html";
        format = WriterFormat.HTML;
    }
    else if (this.ExportFormat.SelectedValue == "PPT")
    {
        fileName = "sales-order-detail.ppt";
        format = WriterFormat.PPT;
    }
    else
    {
        fileName = "sales-order-detail.xlsx";
        format = WriterFormat.Excel;
    }
    writer.Save(fileName, format, httpContext.Response);
}