文檔處理控件TX Text Control即將發佈的X10版本,將升級重點仍是放到了其比較優點的流式佈局報表設計和生成上。慧都得到了來自其開發商Text Control GmbH公司的一手資料,火燒眉毛的爲你們帶來還在測試階段的TX Text Control X10的獨家揭祕。 app
直接使用枚舉業務對象做爲數據源,來建立合併模板是TX Text Control最經常使用的需求之一。即將發佈的TX Text Control X10使用了一個新方法來實現這一需求,即便用新增的DocumentServer.MailMerge方法和IEnumerable對象。 佈局
public void MergeObjects(System.Collections.IEnumerable mergeData);
郵件合併須要將集合中全部對象的公共屬性做爲表列和子表,才能正常進行處理。IEnumerable的屬性做爲關係可以自動實例化,並被用於合併塊和嵌套合併塊。 測試
例如一下數據源的類結構: this
如下代碼就是上圖UML類設計: spa
public class Invoice { public List<Product> Products { get; set; } public Customer Customer { get; set; } } public class Product { public Product(string Name, Decimal Price) { this.Name = Name; this.Price = Price; } public string Name { get; set; } public Decimal Price { get; set; } }
如今須要一個報表模板,須要合併塊Products,合併字段是塊中的Name和Price。操做方式以下。 設計
使用如下代碼就能實現建立數據源對象,並使用MergeObjects來開始合併。 code
Invoice invoice = new Invoice(); invoice.Products = new List<Product>(); invoice.Products.Add(new Product("Apple", 3.55m)); invoice.Products.Add(new Product("Banana", 2.4m)); invoice.Products.Add(new Product("Pineapple", 2.99m)); var invoices = new List<Invoice>(); invoices.Add(invoice); mailMerge1.MergeObjects(invoices);