1

我想将我的 aspx 页面上的 html 表导出到 MS WORD ( .docx ) 文件。我已经有导出.doc文件的代码,但我想以 docx 扩展名导出。

protected void btnExport_Click(object sender, EventArgs e)
{
    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "application/vnd.openxmlformatsofficedocument.wordprocessingml.documet";
    Response.AddHeader("Content-Disposition", "attachment; filename=WORK_ORDER.doc");
    Response.ContentEncoding = System.Text.Encoding.UTF8;
    Response.Charset = "";
    EnableViewState = false;
    System.IO.StringWriter writer = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter html = new System.Web.UI.HtmlTextWriter(writer);
    xx.RenderControl(html);
    Response.Write(writer);
    Response.End();
}      
4

1 回答 1

0

Response.AddHeader("Content-Disposition", "attachment; filename=WORK_ORDER.docx");

代替

Response.AddHeader("Content-Disposition", "attachment; filename=WORK_ORDER.doc");
于 2015-08-29T07:18:26.807 回答