问题描述
public void testingExecute()
{
try
{
using (WordprocessingDocument wordDoc1 = WordprocessingDocument.Open(fromDocument1,false)) // opening 1st word file
using (WordprocessingDocument wordDoc2 = WordprocessingDocument.Open(toDocument2,true)) // opening 2nd word file
{
BookmarkStart bookmarkStart = new BookmarkStart();
var res = from bm in wordDoc1.MainDocumentPart.RootElement.Descendants<BookmarkStart>()
where bm.Name == "TestBookmark"
select bm;
var bookmarkstart = res.SingleOrDefault();
var res1 = from bm in wordDoc1.MainDocumentPart.RootElement.Descendants<BookmarkEnd>()
where bm.Id == bookmarkstart.Id
select bm;
var bookmarkend = res1.SingleOrDefault();
body.InsertBeforeSelf<BookmarkStart>(bookmarkstart);
body.InsertAfterSelf<BookmarkEnd>(bookmarkend);
wordDoc2.MainDocumentPart.Document.Save();
}
}
catch (Exception Ex)
{
throw;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)