合并单元格
如果要合并单元格,可以使用RtfCell的SetMerged方法,语法为:
SetMerged(Rows, Cols )
参数 | 说明 |
Rows | 要合并的行数 |
Cols | 要合并的列数 |
如果合并成功,返回True,否则返回False。
示例
Dim
wdc
As
New
WordCreator()
Dim
tb
As
New
Word.Objects.RtfTable(5, 5)
wdc.Add(tb)
For
r
As
Integer
= 0
To
tb.Rows.Count - 1
For
c
As
Integer
= 0
To
tb.ColumnCount - 1
Dim
cell
As
word.Objects.RtfCell = tb.Rows(r).Cells(c)
cell.SetRectBorder(Word.RtfBorderStyle.Single, color.Black, 1)
Next
Next
tb.Rows(0).Cells(0).SetMerged(3, 2)
'第1行第1个单元格向下合并3行,向右合并2列
tb.Rows(1).Cells(3).SetMerged(4, 1)
'第2行第4个单元格向下合并4行
Dim
fl
As
String
=
"c:\temp\test.docx"
wdc.Save(fl)
Process.Start(fl)
生成的文档为: