添加段落
WordCreator的AddParagraph方法用于添加文本。
其语法有四种:
AddParagraph(text As String)
AddParagraph(text As String, font As Font)
AddParagraph(text As String, font As Font, clr As Color)
AddParagraph(text As String, font As Font, clr As Color, align As
RtfHorizontalAlignment)
text | 段落的文本内容 |
font | 段落的字体 |
clr | 段落文字的颜色 |
align |
段落文字水平方向的排列方式,RtfHorizontalAlignment型枚举,可选值有: Undefined:未定义对齐方式 Left:左对齐 Right:右对齐 Center:居中对齐 Justify:两端对齐 |
示例
在命令窗口执行:
Dim
wdc
As
New
WordCreator()
Dim
fl
As
String
=
"c:\temp\test.docx"
Dim
fnt
As
New
Font("微软雅黑",
12)
wdc.AddParagraph("Foxtable是什么?")
wdc.AddParagraph("Foxtable是电子表格",
fnt)
wdc.AddParagraph("Foxtable也是数据库",
fnt, color.RosyBrown)
wdc.AddParagraph("Foxtable是一个优秀的应用软件",
fnt, Color.Red, Word.RtfHorizontalAlignment.Center)
wdc.AddParagraph("Foxtable也是一个高效率的开发工具",
fnt, Color.Green, Word.RtfHorizontalAlignment.Right)
wdc.Save(fl)
'保存文件
Process.Start(fl)
'打开文件
生成的Word文件内容为: