[C#] HTML Tags to Plain text?

Associate
Joined
17 Nov 2008
Posts
209
I have a RichTextBox in which you can create HTML tables etc

I'm creating a Word Document with data from the RichTextBox, however the data appear with HTML tags...

Any ideas?
 
This is how I'm creating the Word Document
Code:
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

            //Start Word and create a new document.
            Word._Application oWord;
            Word._Document oDoc;
            oWord = new Word.Application();
            oWord.Visible = true;
            oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
            ref oMissing, ref oMissing);
            object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

            SPList oList = oWeb.Lists["Self Evaluation Form"];

            Word.Paragraph oPara3;
            foreach(SPListItem item in oList.Items)
            {

                oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                oPara3 = oDoc.Content.Paragraphs.Add(ref oRng);

[U][B]string hello = Server.HtmlDecode(item["Section Body"].ToString());[/B][/U]
                oPara3.Range.Text = hello;
                oPara3.Format.SpaceAfter = 15;
                oPara3.Range.InsertParagraphAfter();
                
            }

I get HTML tags in the word document
 
Code:
string hello = Regex.Replace(item["Section Body"].ToString(),@"<(.|\n)*?>",string.Empty);

Maybe? I've not tested it!
 
But a word document should show the HTML tags shouldn't it?
If I typed <Table> into a word document I wouldn't want it to vanish awaiting a closing tag.

The document object does have a tables method you can use to create tables in the word doc but I guess that's not what you want.
 
Back
Top Bottom