Aspose.Words如何在Word中插入带样式的文本

作者:控件中国网   出处:控件中国网   2016-04-26 09:35:08   阅读:22

在Word软件中内嵌了多种默认的样式,如标题、标题一、副标题、强调等很多文本段落样式,同样地Aspose.Words控件也内嵌了这种样式,开发人员可以使用代码轻松地为Word文档插入带样式的文本或段落,或者对Word中已有的段落进行格式样式的设置,下面的代码主要用于对新的Word文档插入一段“标题一”样式的文本,具体可以参考下面的代码:
 
Document doc = new Document();
// Insert two sections with some text
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Section 1 Unprotected hadadkajhdjkad");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.BodyText;
// Call the method below to update the TOC.
doc.UpdateFields();
builder.Document.Save("style.doc");
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat