猿问

Repeater显示数据,并且导出到excel

我的数据是自己手工生产,然后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();
 
    }


一只斗牛犬
浏览 638回答 2
2回答

慕容3067478

这个能导出,但是没有按列显示,而且还有Html的元素

手掌心

你repeater控件的ID是Panel1???
随时随地看视频慕课网APP
我要回答