tft每日頭條

 > 生活

 > word excel實訓中的具體案例

word excel實訓中的具體案例

生活 更新时间:2024-08-31 00:23:35

我們經常遇到一個場景,就是需要将數據合并到由其他人創建的合并字段,我們不能确定合并字段的名稱。 所以為了完成郵件合并的目的,首先我們需要讀取所有合并字段的名稱。

Spire.Doc.Reporting命名空間中的MailMerge類公開了以下方法,該方法返回一個word文檔中的合并字段名稱或組(區域)名稱的集合。

  • public string GetMergeFieldNames:返回所有合并字段名稱的集合。
  • public string GetMergeFieldNames(string groupName):返回特定組中合并字段名稱的集合。
  • public string GetMergeGroupNames:返回組名的集合。

了更好的演示,我們使用以下示例文檔:

word excel實訓中的具體案例(Spire.Doc教程用C)1

以下示例詳細說明了如何讀取上述單詞文檔中的組名稱和合并字段。

//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

截圖:

word excel實訓中的具體案例(Spire.Doc教程用C)2

慧都控件網

有用(0)沒用(0)

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved