把dataset 输出到 excel
public void CreatExcel(System.Web.UI.WebControls.GridView ctl,DataSet ds,string filename)
{
ctl.DataSource = ds.Tables[0];
ctl.DataBind();
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+filename);
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}