本文介绍使用spire.doc for .net 在word中添加横线的方法。
c#
using spire.doc;
using spire.doc.documents;
namespace addhorizontalline
{
class program
{
static void main(string[] args)
{
//加载word测试文档
document doc = new document();
doc.loadfromfile("test.docx");
//获取节和段落
section section = doc.sections[0];
paragraph paragraph = section.paragraphs[4];
//添加横线
paragraph.appendhorizonalline();
//保存文档
doc.savetofile("output.docx");
system.diagnostics.process.start("output.docx");
}
}
}
vb.net
imports spire.doc
imports spire.doc.documents
namespace addhorizontalline
class program
private shared sub main(args as string())
'加载word测试文档
dim doc as new document()
doc.loadfromfile("test.docx")
'获取节和段落
dim section as section = doc.sections(0)
dim paragraph as paragraph = section.paragraphs(4)
'添加横线
paragraph.appendhorizonalline()
'保存文档
doc.savetofile("output.docx")
system.diagnostics.process.start("output.docx")
end sub
end class
end namespace
横线添加效果: