Spire.Doc 教程:用C#识别Word中的合并字段名称
来源:互联网 发布:一直正在连接tor网络 编辑:程序博客网 时间:2024/05/20 23:31
我们经常遇到一个场景,就是需要将数据合并到由其他人创建的合并字段,我们不能确定合并字段的名称。 所以为了完成邮件合并的目的,首先我们需要读取所有合并字段的名称。
Spire.Doc.Reporting命名空间中的MailMerge类公开了以下方法,该方法返回一个word文档中的合并字段名称或组(区域)名称的集合。
- public string [] GetMergeFieldNames():返回所有合并字段名称的集合。
- public string [] GetMergeFieldNames(string groupName):返回特定组中合并字段名称的集合。
- public string [] GetMergeGroupNames():返回组名的集合。
了更好的演示,我们使用以下示例文档:
以下示例详细说明了如何读取上述单词文档中的组名称和合并字段。
//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 < GroupNames.Length; i++){Console.WriteLine(GroupNames[i]);}Console.WriteLine("----------------Merge field names within a specific group-----------");for (int j = 0; j < MergeFieldNamesWithinRegion.Length; j++){Console.WriteLine(MergeFieldNamesWithinRegion[j]);}Console.WriteLine("----------------All of the merge field names------------------------");for (int k = 0; k < MergeFieldNames.Length; k++){Console.WriteLine(MergeFieldNames[k]);}
截图:
慧都控件网
阅读全文
0 0
- Spire.Doc 教程:用C#识别Word中的合并字段名称
- Word控件Spire.Doc 教程:用C#,VB.NET在Word中创建对书签的交叉引用
- Spire.Doc 教程:将word文档中的隐藏文本保存到PDF
- Word组件 Spire.Doc 教程:如何在C#,VB.NET中将XML转换为PDF
- Spire.Doc 教程:在C#,VB.NET创建、编辑和保存Word
- Spire.Doc 教程:从C#和VB.NET的word文档中删除形状
- Word组件Spire.Doc 教程:如何在C#中设置段落前后的间距
- Spire.Doc 教程:如何将Word转换为PDF
- Spire.Doc 教程:如何将Word 转换为文本
- Spire.Doc 教程:在word文档中创建书签
- Word控件Spire.Doc 教程:如何在C#中设置word 脚注的位置和数字格式
- Spire.Doc 教程:如何在C#,VB.NET中为Word文档插入形状和形状组
- Word教程Spire.Doc 教程:在Word文档中转换文件格式
- Spire.Doc组件读取与写入Word
- Spire.Email 教程:如何删除C#,VB.NET中的电子邮件
- 【在线演示】Word 组件Spire.Doc 在线演示汇总
- 【FAQ】Word组件Spire.Doc 技术FAQ汇总 | 附下载
- Word控件Spire.Doc 6.0.77版发布| 附下载
- DWZ出现Error loading XML document: dwz.frag.xml问题的解决方式
- Java NIO 经典实例代码
- Balanced Lineup
- 长按二维码识别
- 连接静态zlib,Cannot open compiler generated file: 'x86\ZlibDllReleaseWithoutAsm\Tmp\deflate.cod': No suc
- Spire.Doc 教程:用C#识别Word中的合并字段名称
- LA --- 2965 Jurassic Remains 数相同的大写字母 【思维 + 状态压缩枚举 + 中途相遇法(折半搜索)】
- RCNN,Fast RCNN,Faster RCNN 总结
- HTML5-bootstrap-js plugin
- delphi Format格式化函数
- Artificial Intelligence
- excel数据转list
- oracal的列操作
- BufferedInputStream