Spire.Doc 教程:用C 识别Word中的合并字段名称

时间:2023-07-04 01:37:36 

我们经常遇到一个场景,就是需要将数据合并到由其他人创建的合并字段,我们不能确定合并字段的名称。 所以为了完成邮件合并的目的,首先我们需要读取所有合并字段的名称。

Spire.Doc.Reporting命名空间中的MailMerge类公开了以下方法,该方法返回一个word文档中的合并字段名称或组(区域)名称的集合。

  • public string  GetMergeFieldNames:返回所有合并字段名称的集合。

  • public string  GetMergeFieldNames(string groupName):返回特定组中合并字段名称的集合。

  • public string  GetMergeGroupNames:返回组名的集合。

了更好的演示,我们使用以下示例文档:

Spire.Doc 教程:用C 识别Word中的合并字段名称

以下示例详细说明了如何读取上述单词文档中的组名称和合并字段。

//Creates Document instanceDocument document = new Document;//Loads the word documentdocument.LoadFromFile("MergeFields.docx");//Gets the collection of group namesstring GroupNames = document.MailMerge.GetMergeGroupNames;//Gets the collection of merge field names in a specific groupstring MergeFieldNamesWithinRegion = document.MailMerge.GetMergeFieldNames("Products");// Gets the collection of all the merge field namesstring MergeFieldNames = document.MailMerge.GetMergeFieldNames;Console.WriteLine("----------------Group Names-----------------------------------------");for (int i = 0; i

截图:

Spire.Doc 教程:用C 识别Word中的合并字段名称

慧都控件网

有用(0)没用(0)

标签:字段,合并字段名称,public,string
0
投稿

猜你喜欢

  • wps演示超级链接怎么做

    2022-06-17 08:16:08
  • Win7系统出现提示wpcap.dll丢失怎么解决?

    2023-01-21 15:44:00
  • WPS word文档实现即点即输

    2022-02-13 02:52:51
  • WPS2019怎么设置首行缩进?WPS2019首行缩进设置教程

    2022-01-17 22:53:56
  • Win10如何禁止开机启动项?Win10禁止开机启动项的操作方法

    2023-02-12 18:14:15
  • WPS excel 表格中输入 0 不显示怎么办

    2022-06-25 04:05:44
  • Win10 Mobile 10536预览版用得越久越卡顿是怎么回事?

    2022-02-14 02:11:24
  • 「MacOS」三维动画制作必备工具分享

    2023-05-29 17:16:44
  • Win10重装系统后pin码登录失败怎么办?(图文步骤)

    2022-08-21 10:33:43
  • Win11任务栏白色怎么变成黑色?Win11任务栏变黑色教程

    2022-11-30 02:40:10
  • 笔记本电脑一开机就自动关机怎么办?

    2022-09-07 07:14:13
  • Flash版本过低怎么办?

    2022-11-03 11:53:20
  • 手机版WPS如何防止PPT被篡改

    2023-03-05 05:27:24
  • WPS 如何在word文档中拆分表格

    2022-10-13 19:40:43
  • dms文件怎么打开

    2022-08-28 00:45:09
  • ​Word文档怎么制作勾画重点的效果

    2023-07-20 23:52:09
  • excel最大行数是多少

    2022-12-29 18:18:53
  • WPS PPT思维导图中快速替换文字的方法

    2023-11-09 15:01:12
  • 如何在Mac上的Safari中禁用选项卡预览?

    2022-10-31 01:04:27
  • Win10 Mobile Build 15254.597正式推送(附更新教程)

    2022-04-24 14:19:55
  • asp之家 电脑教程 m.aspxhome.com