DataTable dt = ViewState["DtDatat"] as DataTable;  //Repeater绑定的数据源                  this.Repeater1.DataSource = dt;            this.Repeater1.DataBind();             DisplayDetailCol(false);             //使用流方式导出Excel            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;            HttpContext.Current.Response.ContentType = "application/ms-excel";            HttpContext.Current.Response.Charset = "gb2312";            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + Context.Server.UrlPathEncode("excel名称.xls")); //解决中文乱码问题            StringWriter sw = new StringWriter();            HtmlTextWriter htw = new HtmlTextWriter(sw);            Repeater1.RenderControl(htw);            HttpContext.Current.Response.Write(sw.ToString());            HttpContext.Current.Response.End();
fc441a77b7dfc584417b483bc2970726.png
           DataTable dt = ViewState["DtDatat"] as DataTable;  //Repeater绑定的数据源                  this.Repeater1.DataSource = dt;            this.Repeater1.DataBind();             DisplayDetailCol(false);             //使用流方式导出Excel            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;            HttpContext.Current.Response.ContentType = "application/ms-excel";            HttpContext.Current.Response.Charset = "gb2312";            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + Context.Server.UrlPathEncode("excel名称.xls")); //解决中文乱码问题            StringWriter sw = new StringWriter();            HtmlTextWriter htw = new HtmlTextWriter(sw);            Repeater1.RenderControl(htw);            HttpContext.Current.Response.Write(sw.ToString());            HttpContext.Current.Response.End();
Logo

加入社区!打开量化的大门,首批课程上线啦!

更多推荐