简体   繁体   English

如何使用OpenXML SDK 2.5生成目录?

[英]How to generate Table Of Contents using OpenXML SDK 2.5?

I've read and understand this and this Stackoverflow question but there all about OpenXML SDK 2.0. 我已经阅读并理解了这个这个 Stackoverflow的问题,但所有这些都与OpenXML SDK 2.0有关。 In OpenXML SDK 2.0 there is no real way to update the Table of Content (ToC). 在OpenXML SDK 2.0中,没有真正的方法来更新目录(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. 有一些变通办法,例如将文档标记为脏文件,这将要求用户在打开文档时更新ToC,使用办公自动化更新ToC或使用word宏更新ToC。

Unfortunately, none of this solutions fits for my problem. 不幸的是,这些解决方案都不适合我的问题。

Is there an more convenient way to update the ToC using Open XML SDK 2.5 ? 是否有使用Open XML SDK 2.5更新ToC的更方便的方法?

The problem is not related to openxml and its versions. 该问题与openxml及其版本无关。 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). 在openxml中,作为文档标准,您仅定义分页的需要(通过公式占位符),但是分页仅在RENDERING阶段发生(与openxml不相关)。 As you have already seen whenever opening a word document, the pagination is running live at bottom of the word editor. 如您所见,每次打开Word文档时,分页都在Word编辑器的底部实时运行。 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. 请注意,在PDF生成中,问题有所不同。 The pages are specified at definition level not rendering level. 这些页面是在定义级别而非渲染级别指定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM