Extra redundant row after export to excel
Hi
I'm experiencing a slight problem here. I'm exporting my GridView data into excel, but the first row is usually filled with 2 redundant characters. Please help me have a look at it, is there anything wrong with this piece of code? Thank you!
Dim sw As New StringWriter
Dim htw As New HtmlTextWriter(sw)
Me.GridView1.RenderControl(htw)
Dim strHtml As String = sw.ToString.Trim
Dim ExcelFileName As String = "New Employee Email Details.xls"
Dim FilePhysicalPathName = Request.PhysicalApplicationPath
Dim objectExcelFileName As String = Path.Combine(FilePhysicalPathName, ExcelFileName)
If File.Exists(objectExcelFileName) Then
File.Delete(objectExcelFileName)
End If
Dim fs As New FileStream(objectExcelFileName, FileMode.Create)
Dim bw As New BinaryWriter(fs, Encoding.Default)
bw.Write(strHtml)
bw.Close()
fs.Close()
|