gpt4 book ai didi

c# - 字2007 : Duplicate a table with content control from one page to another

转载 作者:太空宇宙 更新时间:2023-11-03 16:53:33 25 4
gpt4 key购买 nike

有没有办法将具有预定义样式、字体、内容控制等的表格从一个页面克隆到另一个页面,以便我可以在不同的故事中填写不同的数据。因此,例如,我将有一个表格,在一张表格中显示一个人的姓名、年龄和地址。则下一页的表格样式相同,但信息不同。

这可能吗?我找到了一种克隆行/列但不是整个表的方法。

我正在使用 C# 和 OpenXML SDK 2.0。对此主题的任何帮助将不胜感激。

感谢期待。

问候

最佳答案

这个article可能有帮助

foreach (var order in customerOrderHistory)
{
TableRow rowCopy = (TableRow)theRow.CloneNode(true);
rowCopy.Descendants<TableCell>().ElementAt(0).Append(new Paragraph
(new Run (new Text(order.Contact.ToString()))));
rowCopy.Descendants<TableCell>().ElementAt(1).Append(new Paragraph
(new Run (new Text(order.NameOfProduct.ToString()))));
rowCopy.Descendants<TableCell>().ElementAt(2).Append(new Paragraph
(new Run (new Text(order.Amount.ToString()))));
theTable.AppendChild(rowCopy);
}

关于c# - 字2007 : Duplicate a table with content control from one page to another,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3055308/

25 4 0