日期:2014-05-17  浏览次数:20447 次

各位大师,小弟是新手,帮帮忙。感谢万分。
asp.net中把Repeater中的数据导入到Excel里,通过string excelname = "excel文件名";
            HttpContext.Current.Response.Charset = "GB2312";
            HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
            HttpContext.Current.Response.ContentType = "application/ms-excel";
            HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment;filename=" + excelname + ".xls");
            Repeater1.Page.EnableViewState = false;
            StringWriter sw = new StringWriter();
            HtmlTextWriter tw = new HtmlTextWriter(sw);
            Repeater1.RenderControl(tw);
            HttpContext.Current.Response.Write(sw.ToString());
            HttpContext.Current.Response.End();
只能把<%#eval()%>里面的内容下载到excel表格中,label的内容就不行。

------解决方案--------------------
try this:
http://www.cnblogs.com/insus/archive/2013/01/16/2862121.html


------解决方案--------------------
Refer C# version, but refer method only:
http://www.cnblogs.com/insus/archive/2013/05/14/3077826.html
------解决方案--------------------
为什么你就这么死脑筋 你用流搞不定的excel导出 你不会用元数据导出么 元数据 应该是没问题的把