2008年6月5日 星期四

DataGrid轉Excel

Dim sw As New System.IO.StringWriter Dim hw As New System.Web.UI.HtmlTextWriter(sw)
DataGrid1.RenderControl(hw) Response.Clear() Response.AppendHeader("Content-Disposition", "attachment; filename=excel.xls") Response.ContentType = "application/vnd.ms-excel" Response.Write(sw.ToString()) Response.End()

沒有留言: