我的數據是自己手工生產,然后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 關注
- 659 瀏覽
添加回答
舉報
0/150
提交
取消