我們經常遇到一個場景,就是需要将數據合并到由其他人創建的合并字段,我們不能确定合并字段的名稱。 所以為了完成郵件合并的目的,首先我們需要讀取所有合并字段的名稱。
Spire.Doc.Reporting命名空間中的MailMerge類公開了以下方法,該方法返回一個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)
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!