C# Html编辑器-删除标记

C# Html编辑器-删除标记,c#,asp.net,C#,Asp.net,我的页面中有一个html编辑器。我想用粗体、斜体等样式将文本存储在word文档中。。我用这段代码写word文档 object strTextToWrite = txtdocument.Text.Trim(); oWordApplic = new Word.ApplicationClass(); object missing = System.Reflection.Missing.Value; oDoc = oWordApplic.Document

我的页面中有一个html编辑器。我想用粗体、斜体等样式将文本存储在word文档中。。我用这段代码写word文档

object strTextToWrite = txtdocument.Text.Trim();

        oWordApplic = new Word.ApplicationClass();
        object missing = System.Reflection.Missing.Value;
        oDoc = oWordApplic.Documents.Add(ref missing, ref missing, ref missing, ref missing);
        oDoc.Activate();
        string test = StripTagsCharArray(txtdocument.Text);        
        string test2 = test.Replace(" ", " ");
        oWordApplic.Selection.TypeText(test2);
object path =Server.MapPath("~/Documents/"+txtfrom_name.Text + ".doc");
        oDoc.SaveAs(ref path, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
            ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
        oDoc.Close(ref missing, ref missing, ref missing);
        oWordApplic.Application.Quit(ref missing, ref missing, ref missing);
拆分功能是

public static string StripTagsCharArray(string source)
    {
        char[] array = new char[source.Length];
        int arrayIndex = 0;
        bool inside = false;

        for (int i = 0; i < source.Length; i++)
        {
            char let = source[i];
            if (let == '<')
            {
                inside = true;
                continue;
            }
            if (let == '>')
            {
                inside = false;
                continue;
            }
            if (!inside)
            {
                array[arrayIndex] = let;
                arrayIndex++;
            }
        }
        return new string(array, 0, arrayIndex);
    }

现在我得到的是没有粗体、斜体的纯文本。。我需要word文档中的粗体、斜体和下划线功能,,,请帮助我

是否需要旧格式的word文档?如果DocxWord2007/2010格式适合您,请尝试使用and将html转换为Word。有必要了解如何使用这两个组件。我想说的是,这比使用COM类(如Word.ApplicationClass)的互操作DLL要快得多,也更安全