I am using Aspose.Words for .NET
I am Inserting a Content Control using StandartDocumentTag class and inserting table html using documentBuilder -
<table border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
</tr>
<tr>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
</tr>
</table>
Expected Output :
My Output:
The scoping is not coming properly,
In first picture you can see the original scoping of word functionality, that starts scoping from first cell of first row and goes on to last cell of last row.
But, in below image, The scoping goes outside of the table.
How to solve this issue My code is below.
//move to end
docBuilder.MoveToDocumentEnd();
//insert content control
StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Block);
//append the content control
doc.LastSection.Body.AppendChild(sdt);
//move inside the content control
docBuilder.MoveTo(sdt.FirstChild);
//inserting html to the content control
docBuilder.InsertHtml(myTableHtml.ToString().Trim());
//moving out of the content control
Node newPara = doc.LastSection.Body.AppendChild(new Paragraph(doc));
docBuilder.MoveTo(newPara);