我需要在MS WORD中用List填表。我的行数不固定,我找不到如何用c#来做。
it will add numers of rows
string pathDocument = AppDomain.CurrentDomain.BaseDirectory + "example.docx";
DocX document = DocX.Create(pathDocument);
Table table = document.AddTable(res.Count, 10);
table.Alignment = Alignment.center;
table.Design = TableDesign.TableGrid;
for(var row=0;row<res.Count;row++)
{
table.Rows[row].Cells[0].Paragraphs[0].Append((row+1).ToString());
}
document.InsertParagraph().InsertTableAfterSelf(table);
document.Save();