Hi, I’m new to GemBox and I’m trying to replicate some existing mail merges using GemBox.Document and I’ve run into some problems that I can’t see how to solve.
I’ve looked at the forum etc but not found anything that seems relevant.
These mail merges are all using “flat” data files because that’s what Word can accept.
I really don’t want to re-write the data file creation if I can avoid it, and there’s a large number of existing customized template docuemnts outside of my control, so I’m looking for ways to make GemBox accept the current flat file data format and template and do a mail merge that is as close as possible to what Word would do.
Firstly: Conditional merge fields.
A couple of examples:
- There’s a need to skip “blank” records, i.e. records where a certain marker field is blank. It’s currently done like this:
{ SKIPIF MERGEFIELD ReportName = “” }
- Conditional contents.
For example, if the “Notes” merge field is blank, don’t add the nicely formatted “Notes” heading.
{ IF MERGEFIELD Notes = “” “” "
Please find the case notes below.
{MERGEFIELD Notes} }
This is just a very simple example.
Some of the more complicated ones involves whole sections being added / omitted and in some cases several levels of nested IFs.
Secondly: Catalog mail merges.
A number of the mail merges are using the Word “catalog” setting (multiple data rows on one page).
A simple example would be a report showing (say) the day’s total takings in different departments.
The data file would essentially be lines containing text / value pairs, but there’d be an extra “header” fields and control field to indicate if a line is a “sum”.
Something like this:
Data file contents:
“Dept 1” “Toys” “54.66” “”
“” “Food” “120.00” “”
“” “Keys” “100.00” “”
“” “” “274.66” “SUM”
“Dept 2” “Toys” “20.00” “”
“” “Food” “100.50” “”
“” “Keys” “15.00” “”
“” “” “135.50” “SUM”
(etc).
The template would use IF conditions for layout of header and totals - e.g. { IF MERGEFIELD SUM (…) and produce something like this:
Dept 1 daily takings
Toys 54.66
Food 120.00
Keys 100.00
274.66
===============
Dept 2 daily takings
Toys 20.66
Food 100.50
Keys 15.00
135.50
===============
etc.
I’d appreciate some ideas, please.
Thanks.