C#利用 AsposeWords在文档指定位置插入doc文档.docx
《C#利用 AsposeWords在文档指定位置插入doc文档.docx》由会员分享,可在线阅读,更多相关《C#利用 AsposeWords在文档指定位置插入doc文档.docx(7页珍藏版)》请在三一办公上搜索。
1、C#利用 AsposeWords在文档指定位置插入doc文档using System;using System.Collections.Generic;using System.Linq;using System.Text;using Aspose.Words;namespace WindowsFormsApplication1class Class1public static Document insertDocumentAfterBookMark(Document mainDoc,Document tobeInserted, string bookmark) / check maindoc
2、if (mainDoc = null)return null;/ check to be inserted docif (tobeInserted = null) return mainDoc; DocumentBuilder mainDocBuilder = new DocumentBuilder(mainDoc);/ check bookmark and then processif (bookmark != null & bookmark.Trim.Length > 0)Bookmark bm = mainDoc.Range.Bookmarksbookmark;if (bm != n
3、ull) mainDocBuilder.MoveToBookmark(bookmark);mainDocBuilder.Writeln;Node insertAfterNode = mainDocBuilder.CurrentParagraph.PreviousSibling;insertDocumentAfterNode(insertAfterNode, mainDoc, tobeInserted); else / if bookmark is not provided, add the document at the endappendDoc(mainDoc, tobeInserted);
4、return mainDoc;public static void insertDocumentAfterNode(Node insertAfterNode, Document mainDoc, Document srcDoc)/ Make sure that the node is either a pargraph or table.if (insertAfterNode.NodeType != NodeType.Paragraph)& (insertAfterNode.NodeType != NodeType.Table)throw new Exception(The destinati
5、on node should be either a paragraph or table.);/We will be inserting into the parent of the destination paragraph.CompositeNode dstStory = insertAfterNode.ParentNode;/Remove empty paragraphs from the end of documentwhile (null != srcDoc.LastSection.Body.LastParagraph & !srcDoc.LastSection.Body.Last
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C#利用 AsposeWords在文档指定位置插入doc文档 C# 利用 AsposeWords 文档 指定 位置 插入 doc
链接地址:https://www.31ppt.com/p-3060453.html