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

Export to pdf, excel and print

Hi, 

I'm using SyncFusion  grid control for ASP.NET. Please provide me a sample project to export the grid to pdf and excel along with the print functionality. I'd also like to add header and footer to that exported pdf. So kindly provide me a sample project for the same. 


Regards
Dhirender


1 Reply

AS Alan Sangeeth S Syncfusion Team March 10, 2015 12:37 PM UTC

Hi Dhirender,

Thanks for using Syncfusion Products.

We have prepared a Grid Exporting sample based on your requirement and the same can be downloaded from below link.

Sample: http://www.syncfusion.com/downloads/support/directtrac/118444/Sample2030582165.zip

In the above sample for pdf exporting, we have added header and footer to the pdf document using “PdfPageTemplateElement”. Please refer the following code snippets.

protected void FlatGrid_ServerPdfExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)

        {

...

PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);

PdfPageTemplateElement header = new PdfPageTemplateElement(rect);

...

footer.Graphics.DrawString("Custom Text - Footer", font, brush, rect, format); //Add custom text to the header

header.Graphics.DrawString("Custom Text - Header", font, brush, rect, format); //Add custom text to the footer

pdfdocument.Template.Bottom = footer; //Append custom template to the document

pdfdocument.Template.Top = header;

pdfdocument.Save("Export.pdf", Response, HttpReadType.Save);

Please refer the following UG document and online sample link for further reference on exporting.

Documentation: http://help.syncfusion.com/ug/js/documents/exporting3.htm

Online Sample: http://asp.syncfusion.com/demos/web/grid/excelexporting.aspx

Regards,
Alan Sangeeth S



Loader.
Live Chat Icon For mobile
Up arrow icon