首页 > 解决方案 > 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 ));

我已经完成了我的研究,但到目前为止我找不到任何东西
希望有人可以指导我朝着正确的方向前进

提前感谢您的帮助。

标签: c#winformsms-worddocxxceed

解决方案


最后我自己想通了。
我将项目插入表中,如下所示:

            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;
            }

推荐阅读