c# - Word Xceed 中的动态单元格
问题描述
我有一个列表框中的项目列表,我试图将其动态插入到 word 文档中的表格中,word 中的表格只有一行,但如果列表框中有多个项目,我需要它来添加更多。
我目前正在像这样将项目添加到表中("Item Description"
是我在 word 中设置的自定义属性):
template.AddCustomProperty(new Xceed.Document.NET.CustomProperty("Item Description", item.ProdName));
template.AddCustomProperty(new Xceed.Document.NET.CustomProperty("Quantity", item.Quantity));
template.AddCustomProperty(new Xceed.Document.NET.CustomProperty("Unit Price", item.Price));
template.AddCustomProperty(new Xceed.Document.NET.CustomProperty("Total Per Item", Total ));
我已经完成了我的研究,但到目前为止我找不到任何东西
希望有人可以指导我朝着正确的方向前进
提前感谢您的帮助。
解决方案
最后我自己想通了。
我将项目插入表中,如下所示:
foreach (listItem item in descriptionclb.Items)
{
ItemTable.Rows[i].Cells[j].Paragraphs[0].Append(item.ProdName);
j++;
ItemTable.Rows[i].Cells[j].Paragraphs[0].Append(item.ProdName);
j++;
ItemTable.Rows[i].Cells[j].Paragraphs[0].Append(item.Quantity.ToString());
j++;
ItemTable.Rows[i].Cells[j].Paragraphs[0].Append(item.Price.ToString());
j++;
ItemTable.Rows[i].Cells[j].Paragraphs[0].Append(Total.ToString());
i++;
j = 0;
}
推荐阅读
- javascript - 单击时,Bootstrap 4 单选按钮向左移动
- python - 在 Pandas 中连接时数据未将分隔符应用于 csv 文件
- sql - 如何使用 GO-MSSQLDB 驱动程序获取最后插入的 ID?
- jpanel - 我如何在此代码段中错误地使用 KeyListener?
- c# - 在网格中显示所有类型的上传文件
- angularjs - AngularJS:尝试通过组合变量和“px”来创建样式值
- python - UnsupportedOperation:不能做非零当前相对搜索:Python
- filter - 带有 uuid 的 API 平台过滤器
- hadoop - HIVE如何根据某些条件更新现有数据,如果不存在则插入新数据
- r - 将 Rstudio 与 Docker 组合一起使用并将环境变量传递给 rstudio 用户