导出HTML到MS WORD DOCX在ASP.NET文件 [英] Export HTML to MS WORD docx file in ASP.NET

查看:259
本文介绍了导出HTML到MS WORD DOCX在ASP.NET文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮帮我......我想我的aspx页面上导出HTML表到MS WORD(的.docx )文件。
我已经有code出口的 .DOC 的文件,但我想在DOCX扩展导出。

Please help me......I want to export html Table on my aspx page to MS WORD (.docx) file. I already have code to export .doc file but I want to Export in docx extension.

 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();

}

推荐答案

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

而不是

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

这篇关于导出HTML到MS WORD DOCX在ASP.NET文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆