The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have a
list of persons, and I want to have this list merged into my word document in a
way that each person should be placed on a separate line. Assuming my list
consists of the persons "Alice" and "Bob", my resulting
file could look like
"
A list of persons:
Alice
Bob
"
How would my word file have to look like to allow that? If my file looks like
"
A list of persons:
{MERGEFIELD BeginGroup:Persons}{MERGEFIELD FirstName}
{MERGEFIELD EndGroup:Persons}
"
the result will look like
"
A list of persons:
Alice
Bob
"
Notice the unwanted empty line at the end.
On the other hand, if my file looked like
"A list of persons: {MERGEFIELD BeginGroup:Persons}{MERGEFIELD FirstName},
{MERGEFIELD EndGroup:Persons}"
the result would be
"A list of persons: Alice, Bob, "
I don't want the "separator" to be applied after the last item as
well, just as ",".Join() would apply it to the last item.
(Sidenote: After I edited this post to add some information, all newlines
vanished (even though they were visible in the editor before saving), which
makes the post unreadable and much less comprehensible. Adding them all again
doesn't work, so I'm sorry that if something might be incomprehensible.)
This is how my last posting should look like, but I can't format it that way again.
SYSethumanikkam Yogendran Syncfusion Team June 15, 2017 10:12 AM UTC
Hi Sebastian,
Thank you for contacting Syncfusion support.
Regarding empty line after Mail merge: To remove empty paragraphs, you can use the “RemoveEmptyParagraphs” and “RemoveEmptyGroup” properties from MailMerge which will remove the paragraphs and groups which contains empty merge field values in Word document while performing Mail merge.
Regarding remove separator for last item while performing the Mail merge: To remove separator in the group (i.e after merge field), you can use Event support which will allows you to work with merge fields and its owners while performing Mail merge.
We have prepared the sample to illustrate the same, please find the sample from below link and let us know if this helps you. Sample link Note: Please find the input template in “App_Data” folder and code snippets in “Default.aspx.cs” file in the application.
Please refer our UG link to know more about Event support in Mail merge.
If we misunderstood any of your requirement, then kindly provide us sample or modified sample of above along with data’s used at your end and screenshot/output Word document of the expected result which will helpful to provide you the appropriate solution at the earliest.
Please let us know if you have any other questions.