Nested MailMerge with Plain Objects

I have word document like this

«BeginGroup:Elements»

«Seller.Name»

«EndGroup:Elements»


My object is like this

var invoice = new Invoice();

invoice.Seller = new InvoiceSeller();

invoice.Seller.Name = "John";

var mailObject = new MailObject();

mailObject.Elements.Add(invoice);


I merge like this

var dataTable = new MailMergeDataTable("Elements", mailObject.Elements);

var document = new WordDocument(wordFileStream, FormatType.Automatic);

var document.MailMerge.ExecuteNestedGroup(dataTable);


And when i checked word there are no info in word. 

How to select nested object property?

I think it relates to this one https://www.syncfusion.com/forums/109919/nested-mailmerge-with-plain-objects


4 Replies

SB Suriya Balamurugan Syncfusion Team June 13, 2022 12:12 PM UTC

Hi Valentas,

From the given details, we have found that your requirement is to perform nested mail merge with plain objects using DocIO.

We have prepared the sample application to meet your requirement and it can be downloaded from the below attachment.

Please refer our UG documentation link to know more about nested mail merge for group,
https://help.syncfusion.com/file-formats/docio/mail-merge/mail-merge-for-nested-groups#mail-merge-with-implicit-relational-data

If we misunderstood any of your requirement, then kindly provide us sample or modified sample of above along with input template, and screenshot/output Word document of the expected result which will be helpful to provide you the appropriate solution at the earliest.

Regards,
Suriya Balamurugan.


Attachment: Mailmergewithimplicitrelationaldata_6938bae9.zip


VA valentas June 13, 2022 12:33 PM UTC

Not exactly. In you example you merge with object>objects>objects.

I want to merger object>object.otherobject.name.

Just change your example word to

«BeginGroup:Elements»

«BeginGroup:Invoices»«Seller.Name»«EndGroup:Invoices»

«EndGroup:Elements»

and class to

 public class Invoice

    {

        private Seller seller;

        public Seller Seller

        {

            get { return seller; }

            set { seller = value; }

        }

        public Invoice(Seller sellers)

        {

            Seller = sellers;

        }

    }


I am not sure if it is even possible merge with nested objects.



AN Anto Nihil Sahaya Raj Syncfusion Team June 14, 2022 01:09 PM UTC

Hi Valentas,

Thanks for your details. It is not feasible to merge nested objects as like given structure (Seller.Name). We suggest you to modify the template and data source structure to merge the data as we mentioned in the previous update.


Regards,
Anto Nihil S



VA valentas June 14, 2022 01:13 PM UTC

Got it. Thank you for information.


Loader.
Up arrow icon