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 Jun 16, 2015 12:43 pm

Hi,
Is it possible to do a mail merge with multiple rows in a table?

Thanks
Derek.

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Wed Jun 17, 2015 7:37 am

Dear Derek,

Thanks for your inquiry. Yes, it is possible to do a mail merge with multiple rows in a table. Please refer to the following code:
Code: Select all
Document doc = new Document();
doc.LoadFromFile("sample.docx");       
DataTable dt = new DataTable();       
dt.TableName = "table";
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("age", typeof(string));
dt.Rows.Add("yesi", "12");
dt.Rows.Add("jack", "15");
DataSet ds = new DataSet();
ds.Tables.Add(dt);
List<DictionaryEntry> list = new List<DictionaryEntry>();
DictionaryEntry dictionaryEntry = new DictionaryEntry("table", string.Empty);
list.Add(dictionaryEntry);
doc.MailMerge.ExecuteWidthNestedRegion(ds, list);
doc.SaveToFile("merge.docx", FileFormat.Docx);

If i miss something, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Wed Jun 17, 2015 3:46 pm

Thanks the whole doc won't be a list so it'll be something like this where the Cases part is one 'field'. Also have you got a VB example? This is also driven from SQL. Thanks.

Derek Coulahan
3 Pineview Road
Ireland

Case A
Case B
Case C

yours sincerely.

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Thu Jun 18, 2015 6:22 am

Hello,

Thanks for your response. Please provide your template document to us here, or you can send it to us( support@e-iceblue) via email. I will investigate and update to you ASAP.

Best Regards,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Thu Jun 18, 2015 8:45 am

Hi I have attached my template hope you can help, under 'list of cases is where I want to put a list. Thanks.

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Fri Jun 19, 2015 7:44 am

Dear Derek,

Can you please attach your target Word document showing the desired behavior. You can use Microsoft Word to create your target Word document. I will investigate further.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Jun 19, 2015 3:34 pm

It says the doc extension is not allowed so I have attached it in a RAR file

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Tue Jun 23, 2015 7:09 am

Hello,

We are sorry for this delay. I have done some modification on your template and attached the vb codes for your kind reference. You need to modify the code according to your requirement and your data.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Jun 24, 2015 3:14 pm

Thank you!

derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Thu Jun 25, 2015 1:10 am

Dear Derek,

Welcome to write to us again for further problems.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.Doc