In this article I will explain with an example, how to export and download Crystal Report in Word, Excel, PDF and CSV file formats on Button Click in ASP.Net using C# and VB.Net.
Here I am making use of Microsoft’s Northwind Database. You can download it from here.
HTML Markup
The HTML Markup consists of a CrystalReportViewer control, a RadioButtonList with the Export file formats and a Button to export Crystal Reports to Word, Excel, PDF and CSV file formats.
<html xmlns="">
<head runat="server">
    <script src='<%=ResolveUrl("~/crystalreportviewers13/js/crviewer/crv.js")%>' type="text/javascript"></script>
    <form id="form1" runat="server">
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
        Height="400" Width="600" BestFitPage="False" ToolPanelView="None" />
    <br />
    <asp:RadioButtonList ID="rbFormat" runat="server" RepeatDirection="Horizontal">
        <asp:ListItem Text="Word" Value="Word" Selected="True" />
        <asp:ListItem Text="Excel" Value="Excel" />
        <asp:ListItem Text="PDF" Value="PDF" />
        <asp:ListItem Text="CSV" Value="CSV" />
    <br />
    <asp:Button ID="btnExport" Text="Export" runat="server" OnClick="Export" />
You will need to import the following namespaces.
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Designing and populating the Crystal Report from Database
Inside the Page Load event, the Crystal Report is populated from database.
Note: For more details about designing and populating Crystal Report, please refer the following article.
        Crystal Report ASP.Net Example using DataSet or DataTable in C# VB.Net and Visual Studio 2010
ReportDocument crystalReport;
protected void Page_Load(object sender, EventArgs e)
    crystalReport = new ReportDocument();
    Customers dsCustomers = this.GetData("SELECT TOP 5 * FROM customers");
    CrystalReportViewer1.ReportSource = crystalReport;
private Customers GetData(string query)
    string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    SqlCommand cmd = new SqlCommand(query);
    using (SqlConnection con = new SqlConnection(conString))
        using (SqlDataAdapter sda = new SqlDataAdapter())
            cmd.Connection = con;
            sda.SelectCommand = cmd;
            using (Customers dsCustomers = new Customers())
                sda.Fill(dsCustomers, "DataTable1");
                return dsCustomers;
Private crystalReport As ReportDocument
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    crystalReport = New ReportDocument()
    Dim dsCustomers As Customers = Me.GetData("SELECT TOP 5 * FROM customers")
    CrystalReportViewer1.ReportSource = crystalReport
End Sub
Private Function GetData(query As String) As Customers
    Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
    Dim cmd As New SqlCommand(query)
    Using con As New SqlConnection(conString)
        Using sda As New SqlDataAdapter()
            cmd.Connection = con
            sda.SelectCommand = cmd
            Using dsCustomers As New Customers()
                sda.Fill(dsCustomers, "DataTable1")
                Return dsCustomers
            End Using
        End Using
    End Using
End Function
Exporting Crystal Report and download Word, Excel, PDF and CSV file formats in ASP.Net
When the Export Button is clicked, based on the selection from the RadioButtonList the ExportFormatType for the Crystal Report is set.
Then based on the ExportFormatType the Crystal Report is exported to the desired format using the ExportToHttpResponse method.
The Crystal Report exported document i.e. Word, Excel, PDF or CSV will be downloaded as Attachment in Browser.
protected void Export(object sender, EventArgs e)
    ExportFormatType formatType = ExportFormatType.NoFormat;
    switch (rbFormat.SelectedItem.Value)
        case "Word":
            formatType = ExportFormatType.WordForWindows;
        case "PDF":
            formatType = ExportFormatType.PortableDocFormat;
        case "Excel":
            formatType = ExportFormatType.Excel;
        case "CSV":
            formatType = ExportFormatType.CharacterSeparatedValues;
    crystalReport.ExportToHttpResponse(formatType, Response, true, "Crystal");
Protected Sub Export(sender As Object, e As EventArgs)
    Dim formatType As ExportFormatType = ExportFormatType.NoFormat
    Select Case rbFormat.SelectedItem.Value
        Case "Word"
            formatType = ExportFormatType.WordForWindows
            Exit Select
        Case "PDF"
            formatType = ExportFormatType.PortableDocFormat
            Exit Select
        Case "Excel"
            formatType = ExportFormatType.Excel
            Exit Select
        Case "CSV"
            formatType = ExportFormatType.CharacterSeparatedValues
            Exit Select
    End Select
    crystalReport.ExportToHttpResponse(formatType, Response, True, "Crystal")
End Sub
The Crystal Report
Export Crystal Report on Button Click to Word Excel PDF and CSV in ASP.Net
Crystal Report exported to Word Document
Export Crystal Report on Button Click to Word Excel PDF and CSV in ASP.Net
Crystal Report exported to Excel Spreadsheet
Export Crystal Report on Button Click to Word Excel PDF and CSV in ASP.Net
Crystal Report exported to PDF file
Export Crystal Report on Button Click to Word Excel PDF and CSV in ASP.Net
Crystal Report exported to CSV file
Export Crystal Report on Button Click to Word Excel PDF and CSV in ASP.Net