C# 如何在MS WORD c中填写表格#
我需要填写列表中MS WORD的表格。我的行数不是固定的,我找不到如何通过c#C# 如何在MS WORD c中填写表格#,c#,wpf,ms-word,C#,Wpf,Ms Word,我需要填写列表中MS WORD的表格。我的行数不是固定的,我找不到如何通过c#来实现,它将添加行数 字符串pathDocument=AppDomain.CurrentDomain.BaseDirectory+“example.docx”; DocX document=DocX.Create(pathDocument); Table Table=document.AddTable(res.Count,10); 表.Alignment=Alignment.center; table.Design=T
来实现,它将添加行数
字符串pathDocument=AppDomain.CurrentDomain.BaseDirectory+“example.docx”;
DocX document=DocX.Create(pathDocument);
Table Table=document.AddTable(res.Count,10);
表.Alignment=Alignment.center;
table.Design=TableDesign.TableGrid;
对于(var row=0;row)您需要提供更多信息。从您所说的“填写表格”开始:您正在使用模板吗?到目前为止,您使用什么代码将数据添加到文档中,特别是表格中?a将很有帮助……我已经回答了以下问题
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();