如何使用 OpenXML SDK 2.5 生成目录? [英] How to generate Table Of Contents using OpenXML SDK 2.5?

查看:97
本文介绍了如何使用 OpenXML SDK 2.5 生成目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读并理解了这个this Stackoverflow 问题但有关于 OpenXML SDK 2.0.在 OpenXML SDK 2.0 中,没有真正的方法来更新目录 (ToC).有一些解决方法,例如将文档标记为脏,这将要求用户在打开文档时更新 ToC、使用办公自动化更新 ToC 或使用 word 宏更新 ToC.

I've read and understand this and this Stackoverflow question but there all about OpenXML SDK 2.0. In OpenXML SDK 2.0 there is no real way to update the Table of Content (ToC). There are a few workarounds like marking the document dirty which will ask the user to update the ToC on opening the document, update the ToC using office automation or update the ToC using a word macro.

不幸的是,这些解决方案都不适合我的问题.

Unfortunately, none of this solutions fits for my problem.

是否有更方便的方法来使用 Open XML SDK 2.5?

Is there an more convenient way to update the ToC using Open XML SDK 2.5?

推荐答案

该问题与 openxml 及其版本无关.在 openxml 中,作为文档标准,您只定义分页的需要(通过公式占位符),但分页仅发生在 RENDERING 阶段(与 openxml 无关).正如您在打开 Word 文档时已经看到的那样,分页在 Word 编辑器的底部实时运行.所以唯一的方法是模拟它,它只能通过办公自动化(或类似工具)发生或使其变脏.请注意,在 PDF 生成中,问题略有不同.页面是在定义级别而不是呈现级别指定的.

The problem is not related to openxml and its versions. In openxml , as document standard, you only define the need of pagination (by a formula place holder) but the pagination only occurs at RENDERING phase (which is not related to openxml). As you have already seen whenever opening a word document, the pagination is running live at bottom of the word editor. So the only way is simulating it and it can only be happened by office automation ( or a similar tool) or making it dirty. Note that in PDF generation the problem is a little different. The pages are specified at definition level not rendering level.

这篇关于如何使用 OpenXML SDK 2.5 生成目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆