[英]trying to merge table cells while generating a word document using openXML
[英]How i can merge Microsoft Word table cells horizontally using OpenXML C#
我在Microsoft Word中有一个表。 我需要在表的一行中合并两个单元格。 我得到了我需要的细胞:
Wordprocessing.TableRow row = table.Elements<Wordprocessing.TableRow>().ElementAt(i);
Wordprocessing.TableCell cell1 = row.Elements<Wordprocessing.TableCell>().ElementAt(j);
Wordprocessing.TableCell cell2 = row.Elements<Wordprocessing.TableCell>().ElementAt(j+1);
如何水平合并这些单元格?
您需要将HorizontalMerge
对象附加到单元格的TableProperties
。
TableCellProperties cellOneProperties = new TableCellProperties();
cellOneProperties.Append(new HorizontalMerge()
{
Val = MergedCellValues.Restart
});
TableCellProperties cellTwoProperties = new TableCellProperties();
cellTwoProperties.Append(new HorizontalMerge()
{
Val = MergedCellValues.Continue
});
cell1.Append(cellOneProperties);
cell2.Append(cellTwoProperties);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.