protected void AddDataToExcel(ReportGenerator reportGenerator, string worksheetName, ICollection <OtherSampleEntity> entities) { foreach (OtherSampleEntity otherSampleEntity in entities) { foreach (var anotherSampleEntity in otherSampleEntity.AnotherSampleEntities) { DataRow row = reportGenerator.NewRow(worksheetName); row["Entity Id"] = otherSampleEntity.Id; row["Name"] = otherSampleEntity.Name; row["City"] = anotherSampleEntity.City; row["State"] = anotherSampleEntity.State; row["Country"] = anotherSampleEntity.Country; row["Active"] = anotherSampleEntity.Active ? "Active" : "Inactive"; reportGenerator.AddRow(worksheetName, row); } } }