I would like to generate a report in aspose words with the following table. Concept is that each row has a child row table in it. Please see the screenshot below.
C# Object
public class OptionsDto
{
public string Type { get; set; }
public string Status { get; set; }
public string TermStart { get; set; }
public string TermEnd { get; set; }
public string NoticeDate { get; set; }
public string BriefDescription { get; set; }
public string LongDescription { get; set; }
public List<RenewalRatesDto> RenewalRatesDto { get; set; }
}
public class RenewalRatesDto
{
public string ChargeCode { get; set; }
public string From { get; set; }
public string To { get; set; }
public string AmountPeriod { get; set; }
}
Sure you can achieve this. But you should slightly change the template. Please see the attached template, the following code and produced output:
// Create a dummy data source.
List<OptionsDto> optionsDto = new List<OptionsDto>();
for (int i = 0; i < 10; i++)
{
OptionsDto options = new OptionsDto();
options.Type = $"Type_{i}";
options.Status = $"Status_{i}";
options.TermStart = $"TermStart_{i}";
options.TermEnd = $"TermEnd_{i}";
options.NoticeDate = $"NoticeDate_{i}";
options.BriefDescription = $"BriefDescription_{i}";
options.LongDescription = $"LongDescription_{i}";
options.RenewalRatesDto = new List<RenewalRatesDto>();
for (int j = 0; j < 5; j++)
{
RenewalRatesDto rates = new RenewalRatesDto();
rates.ChargeCode = $"ChargeCode_{i}_{j}";
rates.From = $"From_{i}_{j}";
rates.To = $"To_{i}_{j}";
rates.AmountPeriod = $"AmountPeriod_{i}_{j}";
options.RenewalRatesDto.Add(rates);
}
optionsDto.Add(options);
}
Document doc = new Document(@"C:\Temp\in.docx");
ReportingEngine engine = new ReportingEngine();
engine.Options = ReportBuildOptions.RemoveEmptyParagraphs;
engine.BuildReport(doc, optionsDto, "OptionsDto");
doc.Save(@"C:\Temp\out.docx");
in.docx (13.9 KB)
out.docx (13.5 KB)