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.
Unfortunately, activation email could not send to your email. Please try again.

Problem getting the exportReport() method to work.

Thread ID:

Created:

Updated:

Platform:

Replies:

127775 Dec 8,2016 03:56 AM Dec 9,2016 05:49 AM JavaScript 1
loading
Tags: ejReportViewer
Richard Broadley
Asked On December 8, 2016 03:56 AM

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.

Yuvaraj Devarajan [Syncfusion]
Replied On December 9, 2016 05:49 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;