日期:2014-05-17 浏览次数:20442 次
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();