生成word

生成Word:

    protected void Button1_Click(object sender, EventArgs e)
    {
        Export("application/ms-word", "员工报表.doc");
    }
    private void Export(string FileType, string FileName)
    {
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
        Response.ContentType = FileType;
        this.EnableViewState = false;
        StringWriter tw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(tw);
        GridView1.RenderControl(hw);
        Response.Write(tw.ToString());
        Response.End();
    }

posted @ 2014-11-17 16:11  开开123  阅读(116)  评论(0编辑  收藏  举报