void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
{
if (this.mBuilder == null)
this.mBuilder = new DocumentBuilder(e.Document);
// This way we catch the beginning of a new row.
if (e.FieldName.Equals("CompanyName"))
{
// Select the color depending on whether the row number is even or odd.
Color rowColor;
if (IsOdd(this.mRowIdx))
rowColor = Color.FromArgb(213, 227, 235);
else
rowColor = Color.FromArgb(242, 242, 242);
// There is no way to set cell properties for the whole row at the moment,
// so we have to iterate over all cells in the row.
for (int colIdx = 0; colIdx < 4; colIdx++)
{
this.mBuilder.MoveToCell(0, this.mRowIdx, colIdx, 0);
this.mBuilder.CellFormat.Shading.BackgroundPatternColor = rowColor;
}
this.mRowIdx++;
}
}