是否有可能更新与Syncfusion的DocIO lib中生成的Word文档的TOC(TableOfContents)? [英] Is it possible to update the TOC (TableOfContents) of a Word document generated with Syncfusion's DocIO lib?

查看:572
本文介绍了是否有可能更新与Syncfusion的DocIO lib中生成的Word文档的TOC(TableOfContents)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序生成使用的 Syncfusion的DocIO 库。基本上,我们加载一个模板,并插入到特定的书签它特定的文本,生成的Word文档的即时用户下载。

Our application generates a Word document using Syncfusion's DocIO libs. Basically, we load a template and insert into it specific texts in specific bookmarks, generating a Word document that the user downloads on-the-fly.

我们所面临的问题是:

  • 模板是4页长,并具有TOC。
  • 当我们添加的内容,在页面的文件大小增加(自然)
  • 当下载该文件中,TOC仍然反映模板中使用的页码。换句话说,用户必须手动更新TOC(二次点击 - >更新域)。为了刷新页面数

据Syncfusion的文档(这是稀缺...)这是不可能的使用他们的库。因此,我们实施了一个AutoOpen宏更新TOC时,该文档被打开作为一种变通方法在模板中。但是,这会导致开启,这使得我们的使用不舒服(因为宏的),当文件安全警告。

According Syncfusion's documentation (which is scarce...) this is not possible using their lib. So, we implemented an AutoOpen macro in the template that updates the TOC when the doc is opened as a workaround. However, this causes a security warning when opening the file (because of the macro), which makes our uses uncomfortable.

请问你们有一个想法,以改善这个实现? 谢谢你,

Does any of you have an idea to improve this implementation? Thanks,

推荐答案

试试这个

Document wordDocument;
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); 
wordDocument = word.Documents.Open(saveFileDialog.FileName);
wordDocument.TablesOfContents[1].Update();
wordDocument.Save();
word.Quit();

这篇关于是否有可能更新与Syncfusion的DocIO lib中生成的Word文档的TOC(TableOfContents)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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