邮件合并字段在 Word .docx 中并不总是以相同的方式保存
我已经使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果字段的值只是具有一致格式的简单文本,则可以将其存储为 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 thersid
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).