Starting in 2019, the Reporting control is no longer included in Essential Studio®. If you're experiencing issues with the Syncfusion� Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion� and appreciate your understanding.

Using ReportWriter to export a PDF off of a ReportServer

Hello,
I am currently working on a report mass export. My goal is to export 1 report many times varying it's parameters everytime.
The best case solution would be somehow talking to our report server specifying the report and parameters and export it as pdf.
In my first approach I tried to reach the report server API:
  1. Authentication: /api/token [POST] and specifying user, pass and grantType in url-enconded format. This worked and I got the bearer token in my response.
  2. I tried to use: api/v2.0/reports/export [POST] including my bearer token inside the Authorization (Header-field) but was always rejected with 401 Unauthorized
My second approach is using ReportWriter.
But I got kind of confused by the ReportPath. How can I find out what I have to specify here? Tried: relative/absolute local paths on client and server, and as shown in my example the report-link. Nothing worked so far.

ReportWriter reportWriter = new ReportWriter
{
    ReportProcessingMode = ProcessingMode.Remote,
    ReportServerCredential = new NetworkCredential()
    {
        UserName = "user",
        Password = "p4ss"
    },
    ReportServerUrl = "https://report.somewhere.de/",
    ReportPath = "https://report.somewhere.de/en-us/reports/category1/report1" // - ?
};
 
reportWriter.ReportError += this.ReportWriter_ReportError;
 
reportWriter.Save($@"D:\Sample_{DateTime.Now.ToString().Replace(':','_').Replace('.','_').Replace(' ','_')}.pdf"WriterFormat.PDF);

1 Reply

YD Yuvaraj Devarajan Syncfusion Team June 16, 2018 08:30 AM UTC

Hi Robin,

 

The best case solution would be somehow talking to our report server specifying the report and parameters and export it as pdf.

In my first approach I tried to reach the report server API:

Authentication: /api/token [POST] and specifying user, pass and grantType in url-enconded format. This worked and I got the bearer token in my response.

I tried to use: api/v2.0/reports/export [POST] including my bearer token inside the Authorization (Header-field) but was always rejected with 401 Unauthorized

 

The unauthorized error occurred due the missing of “bearer” in authorization header,Please add ‘bearer’ in Authorization header as like below,

 

 

My second approach is using ReportWriter.

But I got kind of confused by the ReportPath. How can I find out what I have to specify here? Tried: relative/absolute local paths on client and server, and as shown in my example the report-link. Nothing worked so far.

 

We have checked the mentioned problem by loading the report from ReportServer and it's working properly at our end. We suspect the mentioned problem might be occurred when you have missed to ReportServer extension file at your end. Please refer to the below UG documentation link for more details,

https://help.syncfusion.com/report-platform/report-platform-sdk/reportwriter/aspnet-mvc

 

public ActionResult Index(string writerFormat)

        {

            try

            {

                string fileName = null;

                WriterFormat format;

                HttpContext httpContext = System.Web.HttpContext.Current;

                ReportWriter reportWriter = new ReportWriter();

                reportWriter.ReportPath = "/Sample Reports/Company Sales";

                reportWriter.ReportServerUrl = "http://reportserver.syncfusion.com:80/";

                reportWriter.ReportingServer = new ReportingServerExt();

                reportWriter.ReportServerCredential = new System.Net.NetworkCredential("guest", "demo");

                reportWriter.ReportProcessingMode = ProcessingMode.Remote;

 

                if (writerFormat == "PDF")

                {

                    fileName = "Company Sales.pdf";

                    format = WriterFormat.PDF;

                }

                else if (writerFormat == "Word")

                {

                    fileName = "Company Sales.doc";

                    format = WriterFormat.Word;

                }

                else if (writerFormat == "Html")

                {

                    fileName = "Company Sales.Html";

                    format = WriterFormat.HTML;

                }

                else if (writerFormat == "Csv")

                {

                    fileName = "Company Sales.csv";

                    format = WriterFormat.CSV;

                }

                else

                {

                    fileName = "Company Sales.xls";

                    format = WriterFormat.Excel;

                }

                reportWriter.Save(fileName, format, httpContext.Response);

            }

            catch

            {

            }

            return View();

        }

 

We have prepared a Report Writer sample and it can have downloaded from,

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/ReportWriterMvc1894795404.zip

 

You can obtain the ASP.Net Report Writer samples from the below build installed location,  

%userprofile%\AppData\Local\Syncfusion\ReportsSDK\Samples\ASP.NET MVC\ReportServerWriter

 

 

 

Regards,

Yuvaraj D.


Loader.
Up arrow icon