InsertHtml inside Cell Node

Hi,

the below code is working fine when the node type is paragraph. But when node type is cell, it is throwing exception at builder.MoveTo(sdr)–> the node must be a paragraph.

Please let us know how do we insert html content when the node is of type cell.

We are using 14.9.0.0 of Aspose.Words

var sdr = sdt.GetChild(NodeType.Any, 0, true);
builder.MoveTo(sdr);
builder.InsertParagraph();
builder.InsertHtml("some html content with table tags",true);

Hi there,

Thanks for your inquiry. Yes, you need to move the cursor to a specific Paragraph or Run node before inserting the html using InsertHtml method. In your case, I suggest you please use following code snippet.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Cell Cell = (Cell)doc.GetChild(NodeType.Cell, 0, true);
builder.MoveTo(Cell.FirstChild);
builder.InsertHtml("some html content with table tags", true);
doc.Save(MyDir + "Out.docx");