Embedding an OpenXML document within another OpenXml document

我是研究僧i 提交于 2019-12-11 02:15:39

问题


I have a need to gather a number of .docx files in a folder and "chain" them into a single document that will be displayed to the user.

Now I've read Brian Jones' article but while it sounded promising I have encountered a problem.

When I perform the actions manually using Word 2007 I end up with a copy of the docx file in the /embeddings folder and when I open the document I am presented with the embedded content.

However, when I do the same thing through code I end up with a file called package.bin in the /embeddings folder and when I open the document I'm greeted with the alternate image telling me to Double-Click on it to activate the embedded document. This is not what I wanted.

Can someone clarify how I embed the document(s) so that they appear as .docx files rather than .bin? I'm hoping that this will overcome the Double-Click to Activate issue as well.

Thanks in Advance


回答1:


I posted this question on the OpenXMLDeveloper forums and was directed to another article by Brian Jones.

While the blog pointed me in the right direction it was not a magic bullet. I had issues with formatting that were resolved by adding a MatchSource element to the AltChunk;

MatchSource matchSrc = new MatchSource();
matchSrc.Val = DocumentFormat.OpenXml.Wordprocessing.BooleanValues.True;
altChunk.AppendChild(matchSrc);

I also needed to remove the footer from the documents being merged as they were being replicated in the new document (resulting in numerous footers within the main footer!). Now I just have the footer in the template for the master document.

Hope this helps someone else as there doesn't seem to be too much information out there are the moment.



来源:https://stackoverflow.com/questions/1271056/embedding-an-openxml-document-within-another-openxml-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!