'Attached: Common MIME Type' GIF File "Image / GIF" 'bmp file "Image / bmp"' JPG file "image / jpeg" 'zip file "Application / X-Zip-compressed"' DOC File "Application / Msword "'Text file" text / place "' html file" text / html "'general file" Application / Oct-stream "private void toExcel1 () {dataset = Database.RunProc (" SELECT * from news ", Dataset; this .DataGrid1.DataSource = dataSet.Tables [0]; this.DataGrid1.DataBind (); HttpContext.Current.Response.AppendHeader ( "excelBack", "attachment; filename = databack.xls"); HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = "application / ms-excel"; this.Page.EnableViewState = false; System.IO .StringWriter tw = new System.IO.StringWriter (); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw); this.DataGrid1.RenderControl (hw); HttpContext.Current.Response.Write (Tw.Tostring ()); httpContext.current.Response.end ();
}