Hi
Thank you for additional information. Here is sample code:
public void Test056()
{
//Open document
//The document is output document of Xls2Doc convertor
Document doc = new Document(@"Test056\in.doc");
Regex regex = new Regex("WBSDESC");
doc.Range.Replace(regex, new ReplaceEvaluator(Replace056), false);
doc.Save(@"Test056\out.doc");
}
private ReplaceAction Replace056(object sender, ReplaceEvaluatorArgs e)
{
//Get match Run
Run run = (Run)e.MatchNode;
//Matched node is child of Table Row
Row row = (Row)run.GetAncestor(NodeType.Row);
//We should split table and insert document between sub tables
//Create new table
Table newTable = new Table(e.MatchNode.Document);
//Copy rows after matched row to the new table
while (row.NextSibling != null)
{
newTable.AppendChild(row.NextSibling);
}
//We should insert the newly created table after original table
//But first we should insert empty paragraph
Paragraph par = new Paragraph(e.MatchNode.Document);
row.ParentTable.ParentNode.InsertAfter(par, row.ParentTable);
//And insert table
par.ParentNode.InsertAfter(newTable, par);
//Now we can insert insert document
//Open corresponding document
//I assume that you will use information from
//run.Text to get document from DB. Here I just open document
Document doc = new Document(@"Test056\test.doc");
InsertDocument(par, doc);
//Also we should remove matched row
row.Remove();
return ReplaceAction.Skip;
}
I hope this could help you.
Best regards.
Alexey Noskov
Developer/Technical Support
Aspose Auckland Team