How to split a document in the OpenXML SDK

I need to split a document in OpenXml sdk 2.0. The document has sections, each of which has a footer with a text element (section name). Is there an easy way to copy from one OpenXml document to another?

+4
source share
3 answers

It will require a lot of work on your part to copy and merge style sheets among other things. I would recommend using altChunk to do the merge for you, as it takes care of all the hard stuff for you. Here are two links to help explain this more: How to use altChunk to assemble a document and How to collect multiple documents to process documents in one

+3
source

I did the same as you using OpenXmlSDK. Although I must say that it was not very fun, and I had only to want a solution that I did not need to cut out. In my case, I had to support footers and headers, etc. With the contents of the section and break the document into several other documents.

At that time, I could not find any patterns in determining the partition to which the element belonged, and I had to write a utility myself. (Separating collocation sections consists of introducing a section break after the content, and the SDK did not seem to provide any helpers.) Then I had to find the definition of the header using headerReference and capture this content before creating a new document and entering the contents of the header, bottom footer and section.

Wish you luck!

0
source

Source: https://habr.com/ru/post/1335130/


All Articles