Dear Aspose Team
I have defined a Template (see Template.PNG) which creates a table for each project in the list. This table contains basic information about a project. This works as expected. But now I would like to create a sub-table containing the milestone of this project. Each row should contain four cells containing the milestone name. If there are more than four milestones, the next four should be in a new row (see ExpectedResult.PNG).
I have defined the following models
public class myProjectList
{
public string Title { get; set; }
public string PL { get; set; }
public string TotalBudget { get; set; }
public List Milestones { get; set; }
}
public class myMilestone
{
public string MilestoneName { get; set; }
}
And I am using the following code:
public Document getAgenda(string agendaTemplateFileName)
{
Document doc = new Document(agendaTemplateFileName);
List projects = new List();
for (int i = 0; i < 2; i++)
{
List milestones = new List();
for (int i = 0; i < 8; i++)
{
milestones.Add(new myMilestone()
{
MilestoneName = "M" + i + "00"
});
}
projects.Add(new myProjectList()
{
Title = "CustomerProject " + i,
Milestones = milestones
});
}
doc.MailMerge.ExecuteWithRegions(new MailMergeDataSource(projects, "ProjectList"));
return doc;
}
I think I need to do something like the following, but I don’t know exactly where to place it and how to achieve that
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("MilestoneName");
builder.StartTable();
int i = 0;
foreach (myMilestone ms in milestones)
{
builder.InsertCell();
builder.Write(ms.MilestoneName);
if (i % 4 == 0)
{
builder.EndRow;
}
i++;
}
builder.EndTable();
It would be great If someone could help me to get this work. If you need any additional information, let me know
Thanks in advance