c# - 如何在MS WORD c#中填写表格
问题描述
我需要从列表中填写 MS WORD 表格。我的行数不固定,我找不到 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();
推荐阅读
- python - 使响应成为 `turtle.right()` 中的角度
- reactjs - ReactJS:是否可以动态更改我的“数据目标”属性?而不是单独设置它们?
- javascript - 如何完整获取一周中的某一天?
- r - 列值的字母顺序不正确
- javascript - 有没有办法只循环更新一个纯Javascript的内容?
- c# - XmlSerializer 将 C# 对象转换为 xml 字符串问题
- matlab - 如何使用函数 eraseBetween (Matlab R2019a) 删除多个文件中的字符串
- c++ - 素数实现
- c# - 调用异步方法时是否必须调用等待?
- mysql - NodeJS sequelize 时间戳被禁用但仍然出现 Unknown column 'createdAt' 错误