我们经常遇到一个场景,就是需要将数据合并到由其他人创建的合并字段,我们不能确定合并字段的名称。 所以为了完成邮件合并的目的,首先我们需要读取所有合并字段的名称。
Spire.Doc.Reporting命名空间中的MailMerge类公开了以下方法,该方法返回一个word文档中的合并字段名称或组(区域)名称的集合。
- public string GetMergeFieldNames:返回所有合并字段名称的集合。
- public string GetMergeFieldNames(string groupName):返回特定组中合并字段名称的集合。
- public string GetMergeGroupNames:返回组名的集合。
了更好的演示,我们使用以下示例文档:
word文档打不开的解决办法
word文档打不开的解决办法?生活中,如果你的电脑遇到一个打不开的word文档,首先检查一下你是不是没有安装打开这个文档的软件。然后看看这份文件

以下示例详细说明了如何读取上述单词文档中的组名称和合并字段。
//Creates Document instance Document document = new Document; //Loads the word document document.LoadFromFile("MergeFields.docx"); //Gets the collection of group names string GroupNames = document.MailMerge.GetMergeGroupNames; //Gets the collection of merge field names in a specific group string MergeFieldNamesWithinRegion = document.MailMerge.GetMergeFieldNames("Products"); // Gets the collection of all the merge field names string MergeFieldNames = document.MailMerge.GetMergeFieldNames; Console.WriteLine("----------------Group Names-----------------------------------------"); for (int i = 0; i截图:
慧都控件网
有用(0)没用(0)
4个Word打印技巧,学会了不仅提升效率而且还非常省钱!
每当秋小叶写好论文和工作报告去打印的时候,都会有好多个版本的文档需要处理,这让秋小叶很是奔溃。前几天