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

Repeater导出Excel怎么把最后一列去掉
RT,在导出来的Excel中,编辑、删除那一列也导出来了,我要在导出时删掉最后一列代码怎么写啊?
C# code
 StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        //rep.RenderControl(hw);
        this.repeater1.RenderControl(hw);
        Response.Clear();
        Response.ContentType = "application/vnd.ms-excel";
        Response.Charset = "";
        repeater1.Page.EnableViewState = false;
        Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + HttpUtility.UrlEncode("用户信息(" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ").xls", System.Text.Encoding.UTF8) + "\"");
        string html = "<html><head><meta http-equiv=Content-Type content=\"text/html;";
        html += "charset=UTF8\"><title> adsf</title></head><body><table><tr></tr>";
       // html += "<td>用户名</td><td>密码</td><td>所属机构</td><td>用户类型</td></tr>";
        Response.Write(html);
        Response.Write(sw.ToString());
        Response.Write("</table></body></html>");
        Response.End();

这是源代码

------解决方案--------------------
repeater1绑定事件里处理吧,或者隐藏一个repeater2进行绑定
------解决方案--------------------
你可以到导出repeater绑定的数据源