生成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();
    }

原文地址:https://www.cnblogs.com/kaiwanlin/p/4103788.html