2

在 Word 中,段落 > 换行符和分页符下有一个属性“与下一个保持一致”。我想知道是否有办法将此属性设置为使用 Novacode DocX 创建的表

4

1 回答 1

0

是的,使用 KeepWithNext(true) 在表格的每一行中设置至少一个单元格的段落。如果您正在动态构建表格,那么这很容易做到。

Novacode.Table t = doc.InsertTable(2, 3); // 2 rows; 3 columns

t.Rows[0].Cells[0].Paragraphs[0].Append("A1").KeepWithNext(true);
t.Rows[0].Cells[1].Paragraphs[0].Append("B1");
t.Rows[0].Cells[2].Paragraphs[0].Append("C1");
t.Rows[0].Cells[0].Paragraphs[0].KeepWithNext(true);

t.Rows[1].Cells[0].Paragraphs[0].Append("A2").KeepWithNext(true);
t.Rows[1].Cells[1].Paragraphs[0].Append("B2");
t.Rows[1].Cells[2].Paragraphs[0].Append("C2");
于 2017-12-20T23:28:22.177 回答