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.

Wed Feb 15, 2017 3:08 am

Hi,

In Spire is it possible to have nested grouping? All the data will be created during runtime and WON'T be connecting to an external data-source

I know that I can loop through a mail merge template by using the following code
Code: Select all
var dataTable = new MailMergeDataTable("Person", IEnumerableData);
document.MailMerge.ExecuteGroup(dataTable);

Using this template
Code: Select all
<<GroupStart:Person>>
..
..
..
<<GroupEnd:Person


but is it possible to have a template like this and still have the grouping work for Address?

Code: Select all
<<GroupStart:Person>>
..
    <<GroupStart:Address>>
    ..
    <<GroupEnd:Address>>
..
<<GroupEnd:Person


Second question, is it possible to just pass in a dataset (not enumarable, just a single class/dataset) into the mail merge Execute() function without using string[]?
i.e
Code: Select all
 document.MailMerge.Execute(string[], string[]);//i don't want to use this function

Is there a function to pass in a single data-source that does the mapping for me? I feel an array of strings is a bit dodgy.
Code: Select all
 document.MailMerge.Execute(Data);//something like this would be better

Dylan_Spire
 
Posts: 18
Joined: Wed Jun 15, 2016 1:28 am

Wed Feb 15, 2017 7:04 am

Dear Dylan_Spire,

Thanks for your inquiry.
For your first question, yes, it can do that. Please use ExecuteGroup twice.
Code: Select all
            document.MailMerge.ExecuteGroup( new MailMergeDataTable("Person", new[]
            {
            new Person { Bar = "person1" },
            new Person { Bar = "person2" },
              }));
            document.MailMerge.ExecuteGroup(new MailMergeDataTable("Address", new[]
            {
            new Person { Bar = "Address1" },
            new Person { Bar = "Address2" },
              }));

If there is still issue, please provide us 1)your sample file and 2)the code you were using and 3)the expected result for further investigation.

For the second question, here is an overload method, it can use DataTable.
Code: Select all
Execute(DataTable table);

Hope this can help.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Feb 15, 2017 10:12 pm

Thanks for the reply,

Yeah I'm still having an issue with my first question. I've added my example code and template below, hopefully that can help

Dylan_Spire
 
Posts: 18
Joined: Wed Jun 15, 2016 1:28 am

Wed Feb 15, 2017 11:58 pm

By the way I'm suing Spire.Doc 5.6.17.4040

Dylan_Spire
 
Posts: 18
Joined: Wed Jun 15, 2016 1:28 am

Thu Feb 16, 2017 3:32 am

Dear Dylan_Spire,

Many thanks for the files.
We will investigate the issue with using ExecuteGroup to mail merge your template. Once there is any progress, we will inform you.
In addition, we suggest you use ExecuteWidthNestedRegion to mail merge the template first, and you need to build the relationship of the datas. And I have attachemd the related files for your kind reference, please check.
If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Feb 16, 2017 5:04 am

Hey, you haven't answered my question.

The zip file you gave me loads and XML file/external data source I DO NOT WANT THIS, I have been explicitly told not to use System.Data.DataSet. I would like to create the data source during run time with dynamic objects. i.e List<MyClass> and inside of each MyClass there is an another list object List<MyOtherClass>

Code: Select all
public class MyClass
{
     public List<MyOtherClass> Data2 {get;set;}
}

public MyOtherClass
{
     public string Data2 {get;set;}
}




So if I run doc.MailMerge.Execute.....(List<MyClass>) it will loop through

Is it possible in Spire perform nested mail merge with relational data objects?

Dylan_Spire
 
Posts: 18
Joined: Wed Jun 15, 2016 1:28 am

Thu Feb 16, 2017 7:47 am

Dear Dylan_Spire,

Thanks for your prompt response.
So sorry that I misunderstand your meaning before.
After further investigation, we change the code you provided, perfect the relationship of that data and now it can mail merge correctly, please check the code on attachement. If there is any question, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Feb 16, 2017 9:49 am

thank you for that, it solves the problem

Dylan_Spire
 
Posts: 18
Joined: Wed Jun 15, 2016 1:28 am

Fri Feb 17, 2017 1:31 am

Dear Dylan_Spire,

Thanks for your feedback.
Please feel free to contact us if there is any question, we are here for help.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Doc