///
/// 导出Excel
///
///
///
public static void Data2Excel(System.Web.UI.Control ctl,string filename)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+filename);
HttpContext.Current.Response.Charset ="";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.ContentType ="application/vnd.ms-excel";
ctl.Page.EnableViewState =false;
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();
}
/// 导出Excel
///
///
///
public static void Data2Excel(System.Web.UI.Control ctl,string filename)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+filename);
HttpContext.Current.Response.Charset ="";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.ContentType ="application/vnd.ms-excel";
ctl.Page.EnableViewState =false;
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();
}