Search code examples
c#asp.netreportviewerreportviewer2008

Modifying Export to Excel in ReportViewer


I have a formatted table in ReportViewer. When I want to export to Excel though - I do not want to export the formatted table - instead I want to output the original/raw/unmassaged data table in an excel file.

What's the best way to intercept the Export to Excel function and output data in a different format?


Solution

  • Put the ShowExportButton to False in the ReportViewer and add a new button in your page that do the work.

    Or you can get into the ReportExport event, set the Cancel to True, and the fire your custom method.

    Private Sub ReportViewer1_ReportExport(ByVal sender As Object, _
               ByVal e As Microsoft.Reporting.WinForms.ReportExportEventArgs) _
               Handles ReportViewer1.ReportExport
        e.Cancel = True
    End Sub