Fraser_Admin
asked on
Export GridView to Excel
See code below. I have the following code to write my contents of my gridview to excel. In one column I am sometimes getting a funny character and I'm not sure why or how to get rid of it. I could intercept it in the rowdatabound event? How would I find and replace this character. Any ideas on what would cause this?
MYTESTDATA Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
MYTESTDATA Â Â Â Â Â Â Â Â Â Â Â Â Â
'Write out what is in the Gridview
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
GridView1.Caption = "Grade Groups"
Response.AddHeader("Content-Disposition", "attachment; filename=" + GridView1.Caption + ".xls")
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
GridView1.Caption = ""
GridView1.FooterRow.Visible = False
GridView1.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.[End]()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.