码迷,mamicode.com
首页 > 其他好文 > 详细

内容导出成word

时间:2017-10-14 16:57:19      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:utf8   .sh   for   logs   efi   ros   get   .text   bytes   

private void 导出word(string 内容)
{
    string tit = "<html xmlns:v=\"urn:schemas-microsoft-com:vml\"   xmlns:o=\"urn:schemas-microsoft-com:office:office\"   xmlns:w=\"urn:schemas-microsoft-com:office:word\"   xmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\"   xmlns=\"http://www.w3.org/TR/REC-html40\">";

    string path = string.Empty;
    System.Windows.Forms.SaveFileDialog fbd = new System.Windows.Forms.SaveFileDialog();
    fbd.Filter = "所有文件 (*.doc)|*.doc";
    if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        path = fbd.FileName;
        byte[] myByte = System.Text.Encoding.UTF8.GetBytes(tit+内容);
        using (FileStream fsWrite = new FileStream(path, FileMode.Create))
        {
            fsWrite.Write(myByte, 0, myByte.Length);
        };

    }
}

 

内容导出成word

标签:utf8   .sh   for   logs   efi   ros   get   .text   bytes   

原文地址:http://www.cnblogs.com/12jh23/p/7667170.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!