Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Mar 19, 2019 10:44 am

Hi,

I'm facing an issue with the MailMerge.ExecuteWidthNestedRegion method when I have records without child records. I'm using the dot net standard edition. I've created a small application to demonstrate the problem.

Code: Select all
class Program {

      public class Order {
         public Int32 OrderId { get; set; }
         public String OrderName { get; set; }
      }

      public class OrderProduct {
         public Int32 ProductId { get; set; }
         public Int32 OrderId { get; set; }
         public String ProductName { get; set; }
         public String ProductAndOrderId {
            get { return String.Format("{0}|{1}", this.ProductId, this.OrderId); }
         }
      }

      public class OrderProductOption {
         public Int32 ProductId { get; set; }
         public Int32 OrderId { get; set; }
         public String OptionName { get; set; }
         public String ProductAndOrderId {
            get { return String.Format("{0}|{1}", this.ProductId, this.OrderId); }
         }
      }

      static void Main(string[] args) {
         List<Order> orders = new List<Order>() {
            new Order() {OrderId = 1, OrderName = "First order"},
            new Order() {OrderId = 2, OrderName = "Second order"},
            new Order() {OrderId = 3, OrderName = "Third order"},
            new Order() {OrderId = 4, OrderName = "Fourth order (empty)"}
         };

         List<OrderProduct> orderproducts = new List<OrderProduct>() {
            new OrderProduct() {OrderId = 1, ProductId = 1, ProductName = "55 INCH TV"},
            new OrderProduct() {OrderId = 1, ProductId = 2, ProductName = "DVD Player"},
            new OrderProduct() {OrderId = 2, ProductId = 3, ProductName = "iPhone"},
            new OrderProduct() {OrderId = 3, ProductId = 1, ProductName = "55 INCH TV"}
         };

         List<OrderProductOption> orderproductoptions = new List<OrderProductOption>() {
            new OrderProductOption() {OrderId = 1, ProductId = 1, OptionName = "Remote control"},
            new OrderProductOption() {OrderId = 1, ProductId = 1, OptionName = "Wall mount"},
            new OrderProductOption() {OrderId = 2, ProductId = 3, OptionName = "Cable"},
            new OrderProductOption() {OrderId = 3, ProductId = 1, OptionName = "Wall mount"},
         };

         List<DictionaryEntry> relationsList = new List<DictionaryEntry>();
         MailMergeDataSet mailMergeDataSet = new MailMergeDataSet();
         mailMergeDataSet.Add(new MailMergeDataTable("Orders", orders));
         mailMergeDataSet.Add(new MailMergeDataTable("OrderProducts", orderproducts));
         mailMergeDataSet.Add(new MailMergeDataTable("OrderProductOptions", orderproductoptions));

         relationsList.Add(new DictionaryEntry("Orders", string.Empty));
         relationsList.Add(new DictionaryEntry("OrderProducts", "OrderId = %Orders.OrderId%"));
         relationsList.Add(new DictionaryEntry("OrderProductOptions", "ProductAndOrderId = %OrderProducts.ProductAndOrderId%"));

         Document document = new Document(@"D:\SpirePoc\Poc.docx", FileFormat.Auto);
         //document.IsUpdateFields = true;
         document.MailMerge.ClearFields = true;
         document.MailMerge.HideEmptyGroup = true;
         //document.MailMerge.HideEmptyParagraphs = true;
         document.MailMerge.ExecuteWidthNestedRegion(mailMergeDataSet, relationsList);

         document.SaveToFile(@"D:\SpirePoc\Poc-Result.docx");
      }
   }


I'm having two problems here:
- The ordered DVD player in the first order doesn't have options, but it shows "Cable"
- The fourth order doesn't have any ordered products nor product options, but it shows the products placeholder and all options.

I've attached the template doc and the result.

Thanks in advance,
Bart

DhooreBart
 
Posts: 1
Joined: Wed Mar 13, 2019 8:02 am

Wed Mar 20, 2019 7:27 am

Hello,

Thanks for your post.
I have reproduced the issue and reported it to our Dev team for further investigating and fixing. If there is any update, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Thu Apr 04, 2019 10:57 am

Hello,

Hope you are doing well.
Glad to inform you that there is a temporary version Spire.Doc7.4.4 which fixed the reported issue, please download and test it.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Thu Apr 11, 2019 9:21 am

Hello,

Glad to inform you that the official version is available now. Please download the Spire.Doc Pack(hot fix) Version:7.4.6 from the following link.
Website link: https://www.e-iceblue.com/Download/download-word-for-net-now.html
Nuget link:https://www.nuget.org/packages/Spire.Doc/

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue Apr 23, 2019 6:43 am

Hello,

Greetings from E-iceblue.
Did the hotfix version work for you? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc