行高与列宽

RtfRow表示行,RtfCell表示单元格,需要注意的是,列类型是不存在。

通过RtfRow的Height可设置行高,如果要设置列宽,则只能遍历此列的所有单元格(RtfCell),逐个单元格设置Width属性。

示例

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.DimGray, 1)
   
Next
Next

tb.Rows(2).Height = 60
'设置 第三行的行高
tb.Rows(2).BackFilling = Color.Aquamarine
'设置 第三行的背景颜色
For
Each r As Word.Objects.RtfRow In tb.Rows '设置第三列的宽度和背景颜色,要逐个单元格设置:
    r.Cells(2).Width = 200
'单元格宽度
    r.Cells(2).BackFilling = Color.Aquamarine
'单元格背景颜色
Next

Dim
fl As String = "c:\temp\test.docx"
wdc.Save(fl)
Process.Start(fl)

生成的文档为:


本页地址:http://www.foxtable.com/webhelp/topics/6038.htm