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
close icon

Want to export My Grid into pdf and excel format with summary and column tamplate details & need to change the page orientation into landscape during pdf export by default

Hi sir

I want to export my grid into pdf and excel format with column tamplate and summary . I used the exporting method but it is not working fine.... the normal column is working good but the last 4 column in which I used the column tamplate with summary details is not coming in pdf properly....... all data is showing 0 there ....

I also want to change the oriention of exporting pdf page into landscape.... but unable to do that. The header I'm providing there on document I want to make it on middle but don't know how to do that.

please check the below code and help me for this, it's very urgent. I'm using Ej1 grid of syncfusion version asp.net core 1.1

Here I'm sharing my code here and as an attachment you can find my controller code. grid working fine but exporting functionality not working


<ej-grid id="TicketDataGrid" allow-sorting="true" export-to-excel-action="@Url.Action("ExportToExcel_Ticket","TransportNReports")" toolbar-click="toolBarClick" export-to-pdf-action="@Url.Action("ExportToPdf_Ticket","TransportNReports")" export-to-word-action="@Url.Action("ExportToWord_Ticket","TransportNReports")" datasource="ViewBag.ticket" locale="fr-FR" allow-paging="true" allow-filtering="true" show-summary="true" show-column-chooser="true" filter-settings="new Syncfusion.JavaScript.Models.FilterSettings() {FilterType=Syncfusion.JavaScript.FilterType.Excel}">

        <e-summary-row title="Total Amount">
                <e-summary-column summary-type="Sum" display-column="TotalAmountK" template="#TotalTemplate" datamember="TotalAmountK" />

        <e-summary-row title="Total Discount">
                <e-summary-column summary-type="Sum" display-column="DiscountAmount" template="#DiscountTemplate" datamember="DiscountAmount" />

        <e-summary-row title="Total Cancelled Amount">
                <e-summary-column summary-type="Sum" display-column="CancelledAmountk" template="#CancelledTemplate" datamember="CancelledAmountk" />

        <e-summary-row title="Total Outstanding Amount">
                <e-summary-column summary-type="Sum" display-column="OutStandingAmountk" template="#OutstandingTemplate" datamember="OutStandingAmountk" />

    <e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>() {"excelExport","wordExport","pdfExport","printGrid" })>

    <e-page-settings print-mode="CurrentPage" page-size="25"></e-page-settings>

        <e-column field="BookingId" header-text="Booking Id" text-align="Center" visible="false" show-in-column-chooser="true"></e-column>
        <e-column field="BookingRefNo" header-text="Booking Ref. No." text-align="Center" width="150"></e-column>
        <e-column field="DateofSell" header-text="Date" width="80" format="{0:MM/dd/yyyy}" visible="true" show-in-column-chooser="true"></e-column>
        <e-column field="Channel" header-text="Channel" text-align=Center width="100" show-in-column-chooser="true" visible="false"></e-column>
        <e-column field="Cashier" header-text="Cashier" text-align=Center width="100" show-in-column-chooser="true" visible="false"></e-column>
        <e-column field="NoOfPassengers" header-text="No. Of Passenger" text-align=Center width="75" show-in-column-chooser="true" visible="false"></e-column>
        <e-column field="SellStation" header-text="Sell Station" text-align=Center width="80" visible="true" show-in-column-chooser="true"></e-column>
        <e-column field="DestStation" header-text="Destination" text-align=Center width="80" visible="true" show-in-column-chooser="true"></e-column>
        <e-column field="TicketType" header-text="Ticket Type" text-align=Center width="80" visible="true" show-in-column-chooser="true"></e-column>
        <e-column field="TotalAmountK" header-text="Amount" text-align=Center width="85" template="#columntotal" show-in-column-chooser="true" visible="true"></e-column>
        <e-column field="DiscountAmount" header-text="Discount Amount" text-align=Center width="80" template="#columndiscount" visible="true" show-in-column-chooser="true"></e-column>
        <e-column field="CancelledAmountk" header-text="Cancelled Amount" text-align=Center width="80" template="#columncancelled" visible="true" show-in-column-chooser="true"></e-column>
        <e-column field="OutStandingAmountk" header-text="OutStanding Amount" text-align=Center width="80" template="#columnoutstanding" visible="true" show-in-column-chooser="true"></e-column>


<script id="TotalTemplate" type="text/x-jsrender">
    XOF {{:summaryValue}}

<script id="DiscountTemplate" type="text/x-jsrender">
    XOF {{:summaryValue}}

<script id="CancelledTemplate" type="text/x-jsrender">
    XOF {{:summaryValue}}

<script id="OutstandingTemplate" type="text/x-jsrender">
    XOF {{:summaryValue}}

<script id="columntotal" type="text/x-jsrender">
    XOF {{:TotalAmountK}}

<script id="columndiscount" type="text/x-jsrender">
    XOF {{:DiscountAmount}}

<script id="columncancelled" type="text/x-jsrender">
    XOF {{:CancelledAmountk}}

<script id="columnoutstanding" type="text/x-jsrender">
    XOF {{:OutStandingAmountk}}

Controller part
  public ActionResult ExportToPdf_Ticket(string GridModel)
            PdfExport exp = new PdfExport();
            List<SalesReportTicketDetails> sales_ticket_detail = HttpContext.Session.GetObjectFromJson<List<SalesReportTicketDetails>>("SalesTicket");
            var DataSource = sales_ticket_detail;
            GridProperties gridProp = ConvertGridObjectkd(GridModel);
            GridPdfExport pdfExp = new GridPdfExport();
            pdfExp.FileName = "Export.pdf";
            pdfExp.Theme = "flat-saffron";
            pdfExp.IsTemplateColumnIncluded = true;
            pdfExp.IncludeDetailRow = true;
            pdfExp.IsSummaryRow = true;
            pdfExp.HeaderText = "Sales Report Ticket Details";
            pdfExp.IsAutoFit = true;
            gridProp.PdfDetailTemplateInfo = PdfDetailTemplateInfo;
            gridProp.PdfColumnTemplateInfo = PdfTemplateInfo;
            pdfExp.PdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
            PdfDocument document = new PdfDocument();
            document.PageSettings.Orientation = PdfPageOrientation.Landscape; //Sets landscape page orientation.
            return exp.Export(gridProp, DataSource, pdfExp);

remaining code I'm attaching with text file. please check that and help me for this . I'm using ej1 grid of syncfusion version asp.net core 1.1

Attachment: code_f2b7fd13.rar

6 Replies

PK Padmavathy Kamalanathan Syncfusion Team December 14, 2019 05:10 AM UTC

Hi Vikash,

Thanks for contacting Syncfusion Forums.

QUERY1: Export column template with summary

From your code we can find that you are using column template in summary. We regret to say this, we don't have support for summary with column template export.

QUERY2: Change orientation of pdf page into landscape

We have already discussed this in our KnowledgeBase documentation. Please check the below help documentation,

We suspect that you have not properly assigned parameters to the export method. Please compare your code with the above code.

QUERY3: Want to make header on middle 

We are unable to understand your query properly. You have mentioned that you need to set the header in the middle of the page. Please share us an example how the header and grid should be placed on the page.

If you have further queries, please get back to us.

Padmavathy Kamalanathan

VK Vikash Kumar December 14, 2019 05:32 AM UTC

for landscape can you please share with me the example for asp.net core because of the link you shared with me it is for asp.net MVC not asp.net core...........  I tried this with asp.net core but it is not working here.......  please create one example for me for this page orientation in landscape.

Another things regarding for my previous query............   

I already posted for this but by mistake that was posted on another forum....  I'm sharing you the link....

please check this link for more details & kindly help me regarding this.

Thanks & Regards
Vikash Kumar

VK Vikash Kumar December 16, 2019 07:39 AM UTC

Still waiting your response . Kindly reply

PK Padmavathy Kamalanathan Syncfusion Team December 16, 2019 12:10 PM UTC

Hi Vikash,

Thanks for your update.

QUERY1: share example for landscape in asp.net core

Please check the below screenshot and sample for achieving landscape mode in pdf export,

For setting landscape mode, you need to give orientation to pdf document and set this document to pdf export ( pdfExp.PdfDocument = document). Please check the above sample shared.

QUERY2: place header at center above grid

We have placed header at the center above grid by using pdf page  template. Using that template you can create header and set alignment to center by setting pdf string format's alignment to center ( check the sample and screenshot( highlighted using yellow ))

QUERY3: suffix doesn't appear in the pdf file

 You have placed XOF in the template of summary . As we have mentioned earlier, we don't have support for exporting summary with template. So you couldn't achieve it.

If you have further queries, please get back to us.

Padmavathy Kamalanathan

VK Vikash Kumar December 17, 2019 10:11 AM UTC

Exactly same thing I needed...!!!!!!  Thanku so much .

I need one more help with you like same example can you give me the sample for html to pdf convert in syncfusion in asp.net core v 1.1, because of in my project I am using .net core version 1.1. so please help me regarding this.


PK Padmavathy Kamalanathan Syncfusion Team December 18, 2019 03:20 PM UTC

Hi Vikash, 
Thanks for your update. 
QUERY: Html to Pdf convert 
Please check the below help documentation, 
If we have miss interpreted your query, please provide us the below details, 
1) Please let us know your query in detail, (whether you need to export the grid or some other control) 
2) If possible, please share us your part of code in which you have handled this conversion. 
If you have further queries, please get back to us. 
Padmavathy Kamalanathan  

Live Chat Icon For mobile
Up arrow icon