Fügen Sie eine Zeile an eine vorhandene Tabelle in ein Word-Dokument (open XML)

Brauche ich um zu öffnen ein vorhandenes Word-Dokument (.docx) mit einer vorhandenen Tabelle (zum Beispiel mit 3 Spalten) und fügen Sie eine neue Zeile an die Tabelle. Gibt es eine Möglichkeit, dies zu tun? Ich bin mit Open XML

Bin ich mit dem erstellen der Tabelle, wie hier (zum ersten mal):

Table tbl = new Table();

//Set the style and width for the table.
TableProperties tableProp = new TableProperties();
TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };

//Make the table width 100% of the page width.
TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct };

//Apply
tableProp.Append(tableStyle, tableWidth);
tbl.AppendChild(tableProp);

//Add 3 columns to the table.
TableGrid tg = new TableGrid(new GridColumn(), new GridColumn(), new GridColumn());
tbl.AppendChild(tg);

//Create 1 row to the table.
TableRow tr1 = new TableRow();

//Add a cell to each column in the row.
TableCell tc1 = new TableCell(new Paragraph(new Run(new Text("1"))));
TableCell tc2 = new TableCell(new Paragraph(new Run(new Text("2"))));
TableCell tc3 = new TableCell(new Paragraph(new Run(new Text("3"))));
tr1.Append(tc1, tc2, tc3);

//Add row to the table.
tbl.AppendChild(tr1);
return tbl;
InformationsquelleAutor Nicole | 2013-03-25
Schreibe einen Kommentar