通过 OpenXML 删除 MailMerge 数据源

发布于 2024-08-25 21:42:09 字数 581 浏览 5 评论 0原文

我有一些代码使用 Open XML 打开 .docx 文件,查找所有 MailMerge 字段,并将它们替换为数据(忽略可能已提供的数据源)。

我最初针对在 Office 2007 中创建的文档进行了测试,效果似乎很好。

然后,我们在 2003 年根据 Excel 电子表格数据源创建了一个,并将其保存为 2007 .docx 格式。当我们打开由我的代码生成的文件时,Word 会警告用户它将执行一些 SQL,特别是 SELECT * from 'Sheet1$'。它有是/否选项。选择需要我找到数据源。选择会将我带到该文档,该文档似乎是正确的。

我不确定为什么现在会看到这个弹出窗口。也许是因为 2003 年文档的数据源不同?

我希望有一种方法可以删除对任何数据源的所有引用,并且弹出窗口不会显示。我发现这个,但似乎不起作用。有什么建议吗?

I have some code that uses Open XML to open up a .docx file, find all MailMerge fields, and replace them with data (ignoring the datasource that may have been provided).

I initially tested this against a document created in Office 2007 and it seemed to work great.

We then created one in 2003 based off an Excel spreadsheet data source and saved it to 2007 .docx format. When we open the file produced by my code, Word warns the user that it is going to execute some SQL, specifically SELECT * from 'Sheet1$'. It has options of Yes/No. Selecting Yes requires I find the data source. Selecting No brings me to the document, which appears to be correct.

I'm not sure why I'm now seeing this pop-up. Perhaps it's due to a different data source for the 2003 document?

My hope was that there was a way to delete all references to any datasources and that the pop-up wouldn't show. I found this, but it doesn't seem to work. Any suggestions?

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

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

发布评论

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

评论(1

眸中客 2024-09-01 21:42:09

好的,我知道如何做到这一点。必须从 /word/settings.xml 获取设置部分,找到 w:mailMerge 条目并将其删除。

Ok, I found out how to do this. Had to get the settings part from /word/settings.xml, find the w:mailMerge entry and delete it.

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