Hi Team,
I have a scenario where I have Row level (MarkupLevel.Row) content controls (StructuredDocumentTag) and I want to set some text to the StructuredDocumentTag and also some text before and after StructuredDocumentTag as well at the row level but I am not able to insert Paragraph and Run nodes to the StructuredDocumentTag due to MarkupLevel is Row for the StructuredDocumentTag.
I have attached a sample doc to the request. Please let me know how we can achieive this through
backend c# code.
SampleDocument.docx (76.7 KB)
Thank you.
@RajmalConga Row level StructuredDocumentTag have a row with the cells inside. You need to work with them as with the table rows and cells.
Document doc = new Document("SampleDocument.docx");
List<StructuredDocumentTag> tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true)
.OfType<StructuredDocumentTag>().ToList();
StructuredDocumentTag sdt = tags[0];
Row row = (Row)sdt.FirstChild;
foreach (Cell cell in row.Cells)
{
cell.FirstParagraph.Runs.Clear();
cell.FirstParagraph.AppendChild(new Run(doc, "Updated content"));
}
doc.Save("output.docx");