Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click Response.Clear() Response.AddHeader("content-disposition", "attachment; filename=ABC.xls") Response.Charset = "" Response.ContentType = "application/vnd.xls" Dim FilePathName As String = Request.PhysicalPath Response.WriteFile(FilePathName, IO.FileMode.Open, IO.FileAccess.Read) Dim stringWrite As New System.IO.StringWriter() Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite) GridView1.HeaderRow.Style.Add("background-color", "#99CCFF") GridView1.RenderControl(htmlWrite) Response.Write(stringWrite.ToString()) Response.[End]()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)