'附:常见的MIME类型
'GIF文件 "image/gif"
'BMP文件 "image/bmp"
'JPG文件 "image/jpeg"
'zip文件 "application/x-zip-compressed"
'DOC文件 "application/msword"
'文本文件 "text/plain"
'HTML文件 "text/html"
'一般文件 "application/octet-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();
}