hi i am trying to export gridview data in xlsx file using below code, but when i open file its showing error,
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=Report.xlsx")
Response.Charset = ""
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
For Each r As GridViewRow In GridView1.Rows
If r.RowType = DataControlRowType.DataRow Then
For columnIndex As Integer = 0 To r.Cells.Count - 1
r.Cells(columnIndex).Attributes.Add("class", "text")
Next
End If
Next
GridView1.RenderControl(htmlWrite)
Dim style As String = "<style> .text { mso-number-format:\@; } "
Response.Write(style)
Response.Write(stringWrite.ToString())
Response.[End]()
Mageshwaran RPosted Nov 27, 2019, 4:25 AM
SenoritaPosted Nov 27, 2019, 3:46 AM
SenoritaPosted Nov 27, 2019, 3:29 AM
Leon DPosted Nov 18, 2019, 12:00 AM
Salman BegPosted Nov 15, 2019, 8:20 AM
SenoritaPosted Nov 14, 2019, 11:46 PM
Salman BegPosted Nov 14, 2019, 11:39 PM