参数的OpenXML问题 [英] Openxml problem with parameters

查看:102
本文介绍了参数的OpenXML问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们编写了一个程序,该程序使用在docx文件中创建的模板(用户定义)来创建协议文档.协议文件通常约为50-60页.
我们使用| p | customername | p |格式的参数在模板文件中,并使用openxml库将参数替换为实际数据.
问题是,某些参数已被替换,而某些参数未被替换.当我们以xml(document.xml)格式打开模板文件时,我们发现MSWord已存储"| p |"在单独的< w:r xmlns:w =#unknown">中标签和客户名称"放在单独的< w:r>标签(实际上,对于某些参数,即使"|"也存储在单独的标签中).当我们将参数作为一个单词搜索时,找不到该参数.
有没有什么方法可以控制MSword存储单词的方式,或者有其他解决方案可以解决此问题?

在此先感谢

Hi,

We have written a program that uses templates(user defined) created in docx files to create agreement documents. The agreement file is typically about 50-60 pages.
We use parameters in the format of |p|customername|p| in the template file and use the openxml library to replace the parameters with the actual data.
The problem is, some parameters are replaced and some are not. When we opened the template file as an xml(document.xml), we found that MSWord has stored the "|p|" in a separate <w:r xmlns:w="#unknown"> tag and "customername" in a separate <w:r> tag (Actually for some parameters even the "|" is stored in a separate tag). When we search for the parameter as one single word, it is not found.
Is there any way of controlling the way MSword stores the words or is there any other solution for this problem?

Thanks in advance

推荐答案

Hello Suresh!

我刚刚在此链接上找到了他们正在解决您的问题的地方:

[
修改:
您可以让您的客户输入文档变量/字段.他们只需要执行插入"->快速零件"->字段"->文档变量",输入变量名,然后在CP上有一个示例,说明如何使用数据填充这些字段:
示例:
在没有Microsoft Word的情况下填写.docx文档中的合并字段 [
Hello Suresh!

I just found this link where they are adressing just your problem:

How to replace content in template docx document and Open XML SDK 2.0 (Aug 09)?[^]

First answer to the question mentions "Document Reflector Tool" which might be helpfull in your quest.

Modification:
You can let your customers enter document variables/fields. They just need to do Insert->Quick Parts->Fields->Doc Variable, enter name of variable and here on CP there is an example of how to fill these fields with data:
Example: Fill Mergefields in .docx Documents without Microsoft Word[^]
End modification


Best Regards,
Manfred


这篇关于参数的OpenXML问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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