如何在 OpenXML SDK 中拆分文档

发布于 2024-10-11 19:08:01 字数 103 浏览 6 评论 0原文

我需要在 OpenXml sdk 2.0 中拆分文档。该文档包含多个部分,每个部分都有一个带有文本元素(部分名称)的页脚。有没有一种直接的方法可以从一个 OpenXml 文档复制到另一个文档?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

怂人 2024-10-18 19:08:01

DocumentBuilder 是您正在寻找的工具。例如,请参见

谁许谁一生繁华 2024-10-18 19:08:01

这将需要您做大量的工作来复制和合并样式表等。我建议使用 altChunk 来执行为您合并,因为它将为您处理所有困难的事情。这里有两个链接可以帮助解释更多:如何使用 altChunk 进行文档组装如何:将多个文字处理文档组合到一个中

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

烂人 2024-10-18 19:08:01

我仅使用 OpenXmlSDK 完成了与您所描述的类似的操作。尽管我不得不说这并不怎么有趣,而且我想要一个不需要自己雕刻的解决方案。就我而言,我必须保留页脚/页眉等与部分内容,并将文档拆分为几个其他文档。

当时,我找不到任何用于识别元素属于哪个部分的示例,因此必须自己编写一个实用程序。 (单词分割部分的方式是在内容之后注入分节符,并且 SDK 似乎没有提供任何帮助器。)然后,我必须使用 headerReference 找到标头定义并抓取在创建新文档并注入页眉、页脚和部分内容之前,也应包含该内容。

祝您好运!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文