欢迎来到天天文库
浏览记录
ID:56785408
大小:18.50 KB
页数:11页
时间:2020-07-11
《Aspose Words使用 DocumentBuilder插入各种元素到Word里.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、AsposeWords使用DocumentBuilder插入各种元素到Word里对于新创建的或者是已有的Word文档,开发人员可以利用AsposeWords提供的DocumentBuilder为Word插入文本、段落、表格、分段、图片、书签、字段、超链接等,具体可以查看下面的事例代码:1.使用DocumentBuilder为Word插入文本DocumentBuilderbuilder=newDocumentBuilder();//Specifyfontformattingbeforeaddingtext.Aspose.Words.Fontfo
2、nt=builder.Font;font.Size=16;font.Bold=true;font.Color=Color.Blue;font.Name="Arial";font.Underline=Underline.Dash;builder.Write("Sampletext.");2.为Word插入一个段落Documentdoc=newDocument();DocumentBuilderbuilder=newDocumentBuilder(doc);//SpecifyfontformattingAspose.Words.Fontfont=
3、builder.Font;font.Size=16;font.Bold=true;font.Color=System.Drawing.Color.Blue;font.Name="Arial";font.Underline=Underline.Dash;//SpecifyparagraphformattingParagraphFormatparagraphFormat=builder.ParagraphFormat;paragraphFormat.FirstLineIndent=8;paragraphFormat.Alignment=Parag
4、raphAlignment.Justify;paragraphFormat.KeepTogether=true;builder.Writeln("Awholeparagraph.");3.使用AsposeWord为Word插入一个表格Documentdoc=newDocument();DocumentBuilderbuilder=newDocumentBuilder(doc);Tabletable=builder.StartTable();//Insertacellbuilder.InsertCell();//Usefixedcolumnwi
5、dths.table.AutoFit(AutoFitBehavior.FixedColumnWidths);builder.CellFormat.VerticalAlignment=CellVerticalAlignment.Center;builder.Write("Thisisrow1cell1");//Insertacellbuilder.InsertCell();builder.Write("Thisisrow1cell2");builder.EndRow();//Insertacellbuilder.InsertCell();//A
6、pplynewrowformattingbuilder.RowFormat.Height=100;builder.RowFormat.HeightRule=HeightRule.Exactly;builder.CellFormat.Orientation=TextOrientation.Upward;builder.Writeln("Thisisrow2cell1");//Insertacellbuilder.InsertCell();builder.CellFormat.Orientation=TextOrientation.Downwar
7、d;builder.Writeln("Thisisrow2cell2");builder.EndRow();builder.EndTable();4.使用AsposeWord为Word插入分页符Documentdoc=newDocument();DocumentBuilderbuilder=newDocumentBuilder(doc);builder.Writeln("Thisispage1.");builder.InsertBreak(BreakType.PageBreak);builder.Writeln("Thisispage2.")
8、;builder.InsertBreak(BreakType.PageBreak);builder.Writeln("Thisispage3.");5.使用Aspo
此文档下载收益归作者所有