#region 倒出Excel表格
/// <summary>
/// 倒出Excel表格
/// </summary>
/// <param name="ctl"></param>
public void ToExcel(System.Web.UI.Control ctl)
{
HttpContext.Current.Response.Charset = "GB2312";
HttpContext.Current.Response.AppendHeader("Content- Disposition", "attachment;filename=" +System.DateTime.Now.ToString("yyyyMMddhhmmss") + "_" +HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("表格")) + ".xls");
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = "application/ms-execl";
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();
}
#endregion