我的数据是自己手工生产,然后repeater绑定,最后导出excel,但出现问题,谁可以给个例子什么的没有。关键代码如下:protected void LinkButton1_Click(object sender, EventArgs e) { string time = DateTime.Now.ToString("yyyyMMddhhmmss"); HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + time + ".xls"); HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = "application/ms-excel"; Panel1.Page.EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); Panel1.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); }
- 2 回答
- 0 关注
- 637 浏览
添加回答
举报
0/150
提交
取消