我在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);