Export Crystal Report to PDF Without opening Report file in ASP.Net MVC

Last Reply one year ago By dharmendr

Posted one year ago

i want to download crystal report output directly in pdf file without opening a rpt file.means when i click on checkbox that time only export to pdf crystalreport file and it will not open in page.only export to pdf operation perform.

Posted one year ago

Hi varun.p,

Refer below article for exporting crystal report to PDF.

ASP.Net MVC: Export Crystal Report to Word Excel PDF and CSV

As you don't want to open the report file, you don't need to set the CrystalReportViewer ReportSource property.

You need to initalize the Crystalreport and set the DataSource using SetDataSource properties with Entity Framework.

Then set ExportFormatType to PortableDocFormat and exported it using the ExportToHttpResponse method.

The Crystal Report exported will be exported to PDF and downloaded as Attachment in Browser.


For this example I have used of Northwind database that you can download using the link given below.

Download Northwind Database


<asp:Button ID="btnExport" runat="server" Text="Export" OnClick="Export" />


protected void Export(object sender, EventArgs e)
    CustomerReport crystalReport = new CustomerReport();
    NorthwindEntities entities = new NorthwindEntities();
    crystalReport.SetDataSource(from customer in entities.Customers.Take(5)
                                select customer);
    crystalReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Crystal");