We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to replace particular image in table and append rows in table

I want to append rows in existing table without disturbing format of table and then replace particular image from different table with another image. When I perform this operation then format of document gets disturb. I want to know how to perform this operation using aspose.words. Here “ReportTemplate.doc” is input file and “FillReportTemplate.doc” will be the output file.

Hi there

Thanks for your inquiry. Please use the following code example to append the row at the end of table with same formatting and set image data with another image. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "ReportTemplate.doc");
// Clone last row of table and append it to table
Table table = (Table)doc.GetChild(NodeType.Table, 1, true);
Row rowCLone = (Row)table.LastRow.Clone(true);
foreach (Cell cell in rowCLone.Cells)
// Change the image data
table = (Table)doc.GetChild(NodeType.Table, 2, true);
Shape shape = (Shape)table.FirstRow.FirstCell.GetChild(NodeType.Shape, 0, true);
shape.ImageData.ImageBytes = File.ReadAllBytes(MyDir + "in.png");
doc.Save(MyDir + "Out.docx");