邮件合并字段在 Word .docx 中并不总是以相同的方式保存

发布于 2024-08-15 19:07:13 字数 461 浏览 1 评论 0原文

我已经使用 Word 2003 创建了一个 Word 文档,并通过 GUI 插入了一些 MergeField。 我已使用 Microsoft Office Word、Excel 和 PowerPoint 2007 文件格式兼容包将其保存为 .docx。一些合并字段存储为 SimpleField,而其他合并字段存储为 FieldCode(带有 start-FieldChar 和 end-FieldChar)。通过谷歌搜索,我找到了这个博客。正如你所看到的,这个人也面临着同样的问题;但还没有找到解决办法。

我在 Codeplex [Fill Mergefields] 上使用以下代码示例,将 MergeFields 替换为来自不同数据源的实际值。

欢迎任何帮助。

I have created a Word document with Word 2003 and inserted some MergeField via the GUI.
I have saved it as a .docx by using Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats. Some Mergefields are stored as a SimpleField, while others are stored as a FieldCode (with start-FieldChar and end-FieldChar). Some Googling brought me to this blog. As you can see the guy is facing the same problem; but hasn't found a solution yet.

I'm using the following code sample on Codeplex [Fill Mergefields] to replace the MergeFields with the actual values from different datasources.

Any help is welcome.

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

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

发布评论

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

评论(1

清风不识月 2024-08-22 19:07:13

如果字段的值只是具有一致格式的简单文本,则可以将其存储为 fldSimple 节点。但是,如果字段的值具有不同的格式,则必须将其保存为复杂字段(fldChar Start、Optional Separator 和 End),以便字段值内的每次运行都可以具有在运行属性 中定义的不同格式。我认为如果 word 使用 rsid 属性来跟踪更改也会发生这种情况。如果字段嵌套,例如多个 IF 字段,则 fldChar Start/Separate/End 也是必需的,这样它就可以存储任意数量的 < w:p> 作为字段的值。

有时它会这样存储它们,似乎没有什么充分的理由。 (正如该博客指出的那样)。

If a field's value is just simple text with consistent formatting, it can be stored as a fldSimple node. However, if the field's value has varying formatting, it has to be saved as a complex field (fldChar Start, Optional Separate, and End) so that each run within the field's value can have it's different formatting defined in the run properties <w:rPr>. I think that also happens if word uses the rsid attributes to track changes. The fldChar Start/Separate/End are also necessary if the fields are nested, such as multiple IF fields, so that it can store an arbitrary number of <w:r>, <w:p>, <w:tbl> as the field's value.

And sometimes it stores them like that for seemingly no good reason. (As that blog noted).

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