We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
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.

Problem getting the exportReport() method to work.

Has anyone had any experience getting the exportReport() method of ejReportViewer to export a report?

I have a requirement to embed the ejReportViewer in an application and to allow the user to interact with it (set filters, show/hide columns, etc.) and also to export the report to a pdf document. 
I've got all this working except for the export to pdf.

Yes, I know that this can be done via the report viewer toolbar, but I have a requirement to not show the toolbar and to code the functions that we need, in order to make the embedding look more like the branding we want. According to the documentation as I understand it, the export function can be programmed (https://help.syncfusion.com/api/js/ejreportviewer#methods:exportreport).

The code I put together to try the export is:

<div>
    <div id="controls">
        <button onclick="exportRep();">export</button>
    </div>
    <div id="reportviewer" name="reportviewer"></div>
</div>

@section Scripts{
    @Scripts.Render("~/script/syncfusionreports")

    <script type="text/javascript">

        function exportRep() {
            console.log("exportRep(): start");
            var ejRep = $("#reportviewer").data("ejReportViewer");
            ejRep.exportReport();
            console.log("exportRep(): end");
        }

        function onReportExport(args)
        {
            console.log('onReportExport(): start');
            var exportName = $(args.exportAction).find('#' + this._id + '_exportfileName');
            exportName.val('DemoReport_01');
            console.log('onReportExport(): end');
        }


        $(function () {
            $("#reportviewer").ejReportViewer({
                reportServiceUrl: "/api/Report",
                reportPath: '62864599-1317-4767-ADE3-ADF47D5CB50C',
                parameters: [@Html.Raw( Model )],
                toolbarSettings: { showToolbar: false},
                exportSettings: { exportOptions: ej.ReportViewer.ExportOptions.Pdf },
                reportExport: "onReportExport"
            });
        })
    </script>
}

The report is being displayed with the data passed in to it but clicking the export button, which calls the exportRep() function, just results in the start and end messages being displayed in the JavaScript console. No pdf is being generated.

What am I doing wrong?

Any help would be much appreciated.

Thanks.

1 Reply

YD Yuvaraj Devarajan Syncfusion Team December 9, 2016 10:49 AM UTC

Hi Richard, 

Thanks for contacting Syncfusion support. 
 
On further analysis of the shared code example, you have not specified any export format type in exportReport() method at your end. Hence the Report is not exported at your end. So we request you to specify the export format type in exportReport() method as show in below code example to avoid the issue at your end.   

<script type="text/javascript"> 
            $(function () { 
                $("#container").ejReportViewer( 
                    { 
                        reportServiceUrl: "/api/ReportApi", 
                        processingMode: ej.ReportViewer.ProcessingMode.Local, 
                        reportPath: '~/ReportTemplate/Product Catalog.rdlc', 
                        toolbarSettings: { showToolbar: false } 
                    }); 
            }); 
 
            function exportReport() { 
                var reportviewerObj = $("#container").data("ejReportViewer"); 
                reportviewerObj.exportReport('PDF'); //Exports the reports 
            }            
    </script> 

We have prepared a sample and it can be downloaded from, 
  
Regards, 
Yuvaraj D. 


Loader.
Up arrow icon