Problems exporting to xls from asp.net
has anyone encountered problems exporting datagrids to xls when using office xp as opposed to office 97?
i'm using the following sub: (it works great with office 97, but blows up with office xp)
Private Overloads Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnExport.Click
'export to excel
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter()
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
Me.ClearControls(dg)
dg.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
End Sub
thanks!
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

degel5 reputationPosted Sep 25, 2003, 12:07 PM EDT
chrishornbergerRank #2,700 · 517 reputationPosted Sep 26, 2003, 7:53 AM EDT