I would like to know if it is possible to extend an existing table by adding new rows?
If so, what is the way to do this?
!!! CANCEL !!!
I’did not have updated my Aspose.Word version.
In the new version, I found all I wanted.
Great, just in the case anybody else has the same question it is easy to do:
//Select the table somehow, for example using XPath
Table table = doc.SelectNode("//Table"); //Select the 1st table in the document.
//Remove the first row for example (shows how to use indexed access to Row).
//Remove the last row (shows how to use FirstRow and LastRow properties)
//Add a row using the typed Rows collection
Row row = new Row(doc);
//Insert a row at the beginning using the typed Rows collection.
table.Rows.Insert(0, new Row(doc));
//Insert a row after the first row using XmlElement-like methods
table.InsertAfter(new Row(doc), table.FirstRow).
Now the row is in the table you need to make sure the row contains one or more Cell nodes and add some Paragraph nodes with Runs of text using the same set of add and insert methods.
Cell cell = (Cell)row.AppendChild(new Cell(doc));
Paragraph para = (Paragraph)cell.AppendChild(new Paragraph(doc));
Run run = (Run)para.AppendChild(new Run(doc, “Hello, text in a Cell.”));