I have this, courtesy of
Colt Kwong, that seems to work. (It's in VB, but hopefully that won't be a problem.) It assumes that you've got a DataGrid1 control that is configured to be data-bound, etc.
Sub Page_Load()
DataGrid1.DataBind()
Response.ContentType = "application/vnd.ms-excel"
Dim tw As New System.IO.StringWriter()
Dim hw As new System.IO.HtmlTextWriter(tw)
DataGrid1.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Sub
mikepope
Contributor
5803 Points
1155 Posts
Microsoft
Re: I need to download data to excel
Nov 15, 2003 03:34 AM|LINK