Replace table cell hyperlink with text

I’ve created an Aspose table by inserting an html table. The resultant Aspose table has hyperlinks which i want to replace/format with normal text.
How do i go about navigating to a table cell and replacing the text and change the font?

Hi Mark,

Thanks for your inquiry. Please follow up the code snippet to break the hyperlinks.

Document doc = new Document(@"Test202\in.doc");
BreakHyperlinks(doc);
doc.Save(@"Test202\out.doc");

///

/// Method breaks hyperlink in the document.
/// Hyperlinks in the word document is HYPERLINK fields.
/// Fields looks like the following [FieldStart]field code[FieldSeparator]field value[FieldEnd]
///
/// Input document
private void BreakHyperlinks(Document doc)
{
    // Get collection of FieldStart nodes in the document
    NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);

    // Create temporary arraylist where we will store FieldStart nodes of Hyperlinks
    // After processing all these nodes will be removed
    ArrayList hyperlinkStarts = new ArrayList();

    // Loop through all FieldStart Nodes and search for Hyperlink field
    foreach(FieldStart start in starts)
    {
        if (start.FieldType == FieldType.FieldHyperlink)
        {
            hyperlinkStarts.Add(start);

            Node currentNode = start.NextSibling;
            Node fieldSeparator = null;
            // Remove all nodes between FieldStart and FieldSeparator nodes
            // Field code will be removed
            while (currentNode.NodeType != NodeType.FieldSeparator)
            {
                currentNode = currentNode.NextSibling;
                currentNode.PreviousSibling.Remove();
            }
            // Look for Field end node
            fieldSeparator = currentNode;
            while (currentNode.NodeType != NodeType.FieldEnd)
            {
                if (currentNode.NodeType.Equals(NodeType.Run))
                {
                    (currentNode as Run).Font.Color = Color.Black;
                    (currentNode as Run).Font.Underline = Underline.None;
                }
                currentNode = currentNode.NextSibling;
            }
            // Remove FieldSeparator and FieldEnd nodes
            fieldSeparator.Remove();
            currentNode.Remove();
        }
    }

    // Now we can remove FieldStart nodes of Hyperlink fields
    foreach(FieldStart start in hyperlinkStarts)
    {
        start.Remove();
    }
}

Hope this will help.

Thanks. One last question, how do i go about editing the text in the table cell?

Hi Mark,

Thanks for your inquiry. Please follow up the code to edit cell text.

Document doc = new Document("c:/temp/Print35.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToCell(0, 0, 0, 0);
Regex regex = new Regex(@"[^\r\n]*", RegexOptions.IgnoreCase);
builder.CurrentNode.Range.Replace(regex, builder.CurrentNode.GetText() + "Modify");
doc.Save("c:/temp/PrintOut.docx");

Hope this will help.