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

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

问题描述

我们的应用程序使用 Syncfusion 的 DocIO 生成一个 Word 文档强>库.基本上,我们加载一个模板并将特定书签中的特定文本插入其中,生成用户即时下载的 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(二次点击 -> 更新字段)才能刷新页码.

根据 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天全站免登陆