搞了很久不弄出来。
求支持,谢谢了。
我的代码如下:
- Code: Select all
NTable.Rows(4).Cells(2).SplitCell(1,7)
NTable.Rows(4).Cells(3).SplitCell(1,7)
NTable.Rows(4).Cells(4).SplitCell(1,7)
NTable.ApplyVerticalMerge(4, 1, 5)
NTable.Rows(4).Cells(5).SplitCell(1,7)
执行后的结果如图三。
NTable.Rows(4).Cells(2).SplitCell(1,7)
NTable.Rows(4).Cells(3).SplitCell(1,7)
NTable.Rows(4).Cells(4).SplitCell(1,7)
NTable.ApplyVerticalMerge(4, 1, 5)
NTable.Rows(4).Cells(5).SplitCell(1,7)Document document = new Document();
document.LoadFromFile(inputFile);
Section section = document.Sections[0];
Table table = section.Tables[0] as Table;
table.Rows[0].Cells[2].SplitCell(1, 7);
foreach (TableRow tableRow in table.Rows)
{
for (int i = 3; i < table.Rows[0].Cells.Count;i++)
{
if (i != 6 && i != 9 && i != 10)
{
TableCell cell = tableRow.Cells[i];
cell.CellFormat.VerticalMerge = CellMerge.None;
}
}
}
table.ApplyVerticalMerge(4, 1, 5);
table.ApplyVerticalMerge(8, 1, 6);
document.SaveToFile("result.docx", FileFormat.Docx2010);Annika.Zhou wrote:您好,
感谢您的咨询。
请参考下面的代码来实现您的需求。
- Code: Select all
Document document = new Document();
document.LoadFromFile(inputFile);
Section section = document.Sections[0];
Table table = section.Tables[0] as Table;
table.Rows[0].Cells[2].SplitCell(1, 7);
foreach (TableRow tableRow in table.Rows)
{
for (int i = 3; i < table.Rows[0].Cells.Count;i++)
{
if (i != 6 && i != 9 && i != 10)
{
TableCell cell = tableRow.Cells[i];
cell.CellFormat.VerticalMerge = CellMerge.None;
}
}
}
table.ApplyVerticalMerge(4, 1, 5);
table.ApplyVerticalMerge(8, 1, 6);
document.SaveToFile("result.docx", FileFormat.Docx2010);
Sincerely,
Annika
E-iceblue support team
table.Rows(4).Cells(2).SplitCell(1, 7)
For j = 0 To 6
For i = 3 To table.Rows(4).Cells.Count - 1
If (i <> 6 And i <> 9 And i <> 10) Then
Dim cell As TableCell = table.Rows(j + 4).Cells(i)
cell.CellFormat.VerticalMerge = CellMerge.None
End If
Next
Next
table.ApplyVerticalMerge(4, 4 + 1, 4 + 5)
table.ApplyVerticalMerge(8, 4 + 1, 4 + 6)