简体   繁体   中英

How to Add New Row in an Existing Table Using Novacode DocX

I have an existing table inside my Word Document which only consist headers. I want to add data on that table programmatically. I want to add rows in it but I can't find reference how to:

I tried the following:

Table myTable = document.Tables[0];
Row myRow = new Row();
myTable.Rows.Add(myRow);
myTable.Rows[0].Cells[0].Paragraphs.First().Append("Sample Data");
myTable.Rows[0].Cells[1].Paragraphs.First().Append("Sample Data");

This returns an error after building: The type 'Novacode.Row' has no constructors defined

Row myRow = myTable.InsertRow();
myRow.Cells[0].Paragraphs.First().Append("Sample Data");
myRow.Cells[1].Paragraphs.First().Append("Sample Data");
myTable.Rows.Add(myRow);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM