Adding Excel Export to a Report or Grid

  1. Add NPOI.dll and NPOIHelper.dll to the bin folder of the website.
  2. In the After Execute Select event of the report or grid add the following code:

  If Request.QueryString("Export") = "Excel" Then
   Dim SS As New NPOIHelper.Spreadsheet()
   SS.AddSheet(DirectCast(e.OperationResult,System.Data.DataView))
   SS.WebDownload(Response, "DownloadFilename")
  End If

Add an Export to Excel link to the page with an Expression parameter of Export=Excel.