Mohammad Aman

Mohammad Aman

  • Tech Writer
  • 327
  • 72.4k

Border not showing in excel after exporting in ASP.Net

Feb 24 2016 12:49 AM
My code is here . I am exporting excel sheet by using this code but cell borders are not showing in my excel sheet:
 
Private Sub ExportGridToExcel()
Response.Clear()
Response.Buffer = True
Response.ClearContent()
Response.ClearHeaders()
Response.Charset = ""
Dim FileName As String = "Vithal" + DateTime.Now + ".xls"
Dim strwritter As New StringWriter()
Dim htmltextwrtter As New HtmlTextWriter(strwritter)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", Convert.ToString("attachment;filename=") & FileName)
GridViewBillReport.GridLines = GridLines.Both
GridViewBillReport.HeaderStyle.Font.Bold = True
GridViewBillReport.RenderControl(htmltextwrtter)
Response.Write(strwritter.ToString())
Response.[End]()
End Sub
 
My Excel sheet and my GridView Screenshot are here:
 
 

Answers (1)