We want to create a CSV file from data .It is showing HTML tags .Same working fine for xlx file. Below is code.
Dim response As System.Web.HttpResponse = System.Web.HttpContext.Current.Response
response.Clear()
response.ClearHeaders()
response.Write("<meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""/>")
'Chose what type of file needed ie.e CSV /XLS
If _exportType = ExportTypeEnum.CSV Then
response.ContentType = "application/vnd.xls"
Else
response.ContentType = "application/vnd.xls"
End If
response.AddHeader("Content-Disposition", "attachment;filename=" & FileNameToExport)
Dim sw As System.IO.StringWriter = New StringWriter()
Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
Dim dg As DataGrid = New DataGrid()
Dim dv1 As DataView = data
dg.DataSource = dv1
dg.BorderStyle = BorderStyle.None
dg.DataBind()
dg.RenderControl(htw)
response.Write(sw.ToString())
response.End()
Please suggest WHY it is not working for CSV file , although it is fine for xls file.
Many thanks in advance