Public Sub ExportGridToExcel(ByRef grdGridView As GridView, ByVal fileName As String) Response.Clear() Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xls", fileName)) Response.Charset = "" Response.ContentType = "application/vnd.xls" Dim strWr As New StringWriter() Dim HtmlWr As New HtmlTextWriter(strWr) grdGridView.RenderControl(HtmlWr) Response.Write(strWr.ToString) Response.End() End Sub
Microsoft.Office.Interop.Excel
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)