我想将我的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();
}
答案 0 :(得分:0)
把
Response.AddHeader("Content-Disposition", "attachment; filename=WORK_ORDER.docx");
而不是
Response.AddHeader("Content-Disposition", "attachment; filename=WORK_ORDER.doc");