日期:2014-05-20  浏览次数:20953 次

repeater 导出Excel
repeater 导出Excel ,导出的Excel文件没有边框线怎么办

------解决方案--------------------
在repeater中显示时要能看到边框,比如用<table>,要加上border=“1”。要不就要在Excel中设置边框了

------解决方案--------------------
C# code

protected void Excel_Click(object sender, EventArgs e)
{
            Response.Clear();
            //获取或设置一个值,该值指示是否缓冲输出,并在完成处理整个响应之后将其发送
            Response.Buffer = true;
            //获取或设置输出流的HTTP字符集
            Response.Charset = "GB2312";
            //将HTTP头添加到输出流
            Response.AppendHeader("Content-Disposition", "attachment;filename=PriceManage" + DateTime.Now.Date.ToString("yyyyMMdd") + ".xls");
            //获取或设置输出流的HTTP字符集
            Response.ContentEncoding = System.Text.Encoding.UTF7;
            //获取或设置输出流的HTTP MIME类型
            Response.ContentType = "application/ms-excel";
            System.IO.StringWriter onstringwriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter onhtmltextwriter = new System.Web.UI.HtmlTextWriter(onstringwriter);
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);           
            this.Repeater1.RenderControl(htw);
            string html = sw.ToString().Trim();
            Response.Output.Write(html);
            Response.Flush();
            Response.End();      
   }
public override void VerifyRenderingInServerForm(Control control)
 {
            //base.VerifyRenderingInServerForm(control);
}

------解决方案--------------------
探讨

引用:
C# code


protected void Excel_Click(object sender, EventArgs e)
{
Response.Clear();
//获取或设置一个值,该值指示是否缓冲输出,并在完成处理整个响应之后将其发送
Response.Buffer = true;
……

我就是这么写的,导出的Exc……