日期:2014-05-17  浏览次数:20525 次

导出到word时,如何添加页眉页脚
C# code
        string FileName = “sssssss.doc”;
        HttpContext.Current.Response.Charset = "GB2312";
        HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
        HttpContext.Current.Response.ContentType = "application/ms-winword";
        HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
        //HttpContext.Current.Response.
        //Lb_Const[0][10].Page.EnableViewState = false;
        StringWriter sw = new StringWriter();
        HtmlTextWriter tw = new HtmlTextWriter(sw);
        //Label lb = null;
        //lb = (Label)this.Page.FindControl("Label1");
        //if (lb != null) { lb.RenderControl(tw); }
        this.Label1.RenderControl(tw);
        string css_txt = "<style>" + Css_read() + "</style>";
        HttpContext.Current.Response.Write(sw.ToString());

        HttpContext.Current.Response.End();


这样可以输出label的内容到word
现在是想加上一个页眉页脚,该怎么实现呢?

------解决方案--------------------
导出Word