MailMerge Template XML

I am writing to seek assistance with a project at my company for which we obtained a license from your organization some time ago. Currently, we are encountering an issue where we need to populate a table from top to bottom and then expand it horizontally. In reviewing the documentation, I could only find examples for filling tables from left to right and from top to bottom. We want to using GemBox.Document for this purpose.

Attached to this message, you will find a sample template and an exemplary XML file for your reference. Additionally, it would be greatly appreciated if you could provide a link to a comprehensive code documentation where I can gain insights into the functionalities and capabilities of the individual code blocks.

Thank you in advance for your assistance. I look forward to your prompt response and resolution to our query.
Files here: ( with two files inside)


Currently, GemBox.Document doesn’t provide an out-of-the-box solution for defining a table column as a merge range. It is possible that in the future this feature will be introduced, but for now you’ll need to either customize the mail merge process or process the document after the mail merge to achieve the desired result.

For example, let’s say you have this template document:

Now if you execute the mail merge process, because of this table’s layout and the location of “RangeStart” and “RangeEnd” fields, each “Product” record will result in duplicating those 23 rows.
So, what you could do is after the mail merge you would move the last cells from those extra rows into one of the original 23 rows.

Something like this:

// Get mail merge data source as an anonymous object.
var xmlDoc = XDocument.Load("xyz1234_.xml");
var jsonText = JsonConvert.SerializeXNode(xmlDoc);
dynamic source = JsonConvert.DeserializeObject<ExpandoObject>(jsonText);

var document = DocumentModel.Load("CdAuftragen1.docx");

// Get table with desired column merge range.
var table = document.GetChildElements(true, ElementType.Table).ElementAt(2) as Table;

// Pre-format the table.
table.TableFormat.PreferredWidth = new TableWidth(0, TableWidthUnit.Auto);
table.Columns.Last().PreferredWidth = 40;
foreach (var cell in table.Rows.Select(r => r.Cells.Last()))
    cell.CellFormat.PreferredWidth = new TableWidth(40, TableWidthUnit.Point);

int originalRowsCount = table.Rows.Count;

// Execute mail merge process.

// Post-process the table.
for (int i = originalRowsCount; i < table.Rows.Count; i++)
    var extraRow = table.Rows[i];
    int lastCellIndex = extraRow.Cells.Count - 1;
    var lastCell = extraRow.Cells[lastCellIndex];

    var originalRow = table.Rows[i % originalRowsCount];
while (table.Rows.Count > originalRowsCount)


Here is the resulting document:


Thank you very much. Perhaps it’s the best solution. Gembox.Document - is a powerful components.