- voidExportExcel(System.Web.UI.WebControls.DataListdl,stringstrFileName)
- {
- strFileName=System.Web.HttpUtility.UrlEncode(strFileName,System.Text.Encoding.UTF8);
- System.Web.HttpContext.Current.Response.Clear();
- System.Web.HttpContext.Current.Response.Buffer=true;
- System.Web.HttpContext.Current.Response.Charset="gb2312";
- System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition","online;filename="+strFileName+".xls");
- System.Web.HttpContext.Current.Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312");
- System.Web.HttpContext.Current.Response.ContentType="application/ms-excel";
- System.Globalization.CultureInfomyCItrad=newSystem.Globalization.CultureInfo("zh-CN",true);
- System.IO.StringWriteroStringWriter=newSystem.IO.StringWriter(myCItrad);
- System.Web.UI.HtmlTextWriteroHtmlTextWriter=newSystem.Web.UI.HtmlTextWriter(oStringWriter);
- dl.RenderControl(oHtmlTextWriter);
- System.Web.HttpContext.Current.Response.Write(oStringWriter.ToString().Replace("<td","<tdSTYLE='MSO-NUMBER-FORMAT://@'"));
- System.Web.HttpContext.Current.Response.Buffer=false;
- System.Web.HttpContext.Current.Response.End();
- }
datalist导出excel
最新推荐文章于 2017-12-30 10:29:20 发布