我无法在按钮上单击导出Word文档 [英] I'm unable to Export Word Document on Button Click

查看:86
本文介绍了我无法在按钮上单击导出Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void btnExportToWord_Click(object sender, EventArgs e)
 {


     string strBody = "<html>" +
    "<body>" +
        "<div>Your name is: <b>om   </b></div>" +
        "<table width=\"100%\" style=\"background-color:#cfcfcf;\"><tr><td>1st Cell body data</td><td>2nd cell body data</td></tr></table>" +
        "Ms Word document generated successfully." +
    "</body>" +
    "</html>";
     string fileName = "MsWordSample.doc";
     Response.AppendHeader("Content-Type", "application/msword");
     Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName);
     Response.Write(strBody);
     Response.End();



}


}

推荐答案

查看此示例



http://www.c-sharpcorner.com/UploadFile/muralidharan.d/how-to-create-word-document-using-C-Sharp/ [ ^ ]


Response.Clear();

Response.Charset =;

Response.ContentEncoding = System.Text.UnicodeEncoding。 UTF8;

Response.Charset =UTF-8;

Response.ContentType =application / msword;

Response.Buffer = true;

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

Response.End();
Response.Clear();
Response.Charset = " ";
Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8;
Response.Charset = "UTF-8";
Response.ContentType = "application/msword";
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment;filename=Individual.doc");
Response.End();


这篇关于我无法在按钮上单击导出Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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