开发者

How to split a document in OpenXML SDK

I need to split a document in OpenXml sdk 2.0. The document has sections that each have a footer with a text element (name of the section). Is there 开发者_开发百科a straightforward way to copy from one OpenXml document to another?


DocumentBuilder is the tool you are looking for. See for example, http://blogs.msdn.com/b/ericwhite/archive/2010/01/08/how-to-control-sections-when-using-openxml-powertools-documentbuilder.aspx


This would require a lot of work on your part to copy and merge stylesheets among other things. I'd recommend using altChunk to do the merging for you as it will take care of all the hard stuff for you. Here are two links to help explain it more: How to Use altChunk for Document Assembly and How to: Assemble Multiple Word Processing Documents in One


I have done similar to what you describe using just the OpenXmlSDK. Though I have to say it wasn't much fun, and I was left wanting a solution I didn't have to carve myself. In my case I had to keep footers/headers etc. with section content and split the document into several other documents.

At the time I couldn't locate any samples on identifying which section an element belonged to, and had to write a utility myself. (The way word splits sections is by injecting a section break after the content, and the SDK didn't seem to provide any helpers.) I then had to locate the header definition by using the headerReference and grab that content too, before creating a new document and injecting the header, footer, and section content.

I wish you the best of luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜