如何使用 Novacode DocX 在现有 Table 中添加新行
How to Add New Row in an Existing Table Using Novacode DocX
我的 Word 文档中已有一个 table,它只包含 headers。我想以编程方式在 table 上添加数据。我想在其中添加行,但找不到参考方法:
我尝试了以下方法:
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");
这个returns构建后的一个错误: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);
我的 Word 文档中已有一个 table,它只包含 headers。我想以编程方式在 table 上添加数据。我想在其中添加行,但找不到参考方法:
我尝试了以下方法:
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");
这个returns构建后的一个错误: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);