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

    }
}

 

posted on 2017-10-14 14:00  金琥  阅读(125)  评论(0编辑  收藏  举报