public Stream GenerateReport <T>(IReadOnlyCollection <ScenarioCampaignFailure> data, T snapshot, DayOfWeek tenantStartDayOfWeek) where T : IFaultTypesHolder, ICampaignsHolder { var results = GenerateReportData(data, snapshot); var weekDays = DaypartDayFormattingUtilities.GetWeekDaysWithCustomStart(tenantStartDayOfWeek); var sheetName = SheetName; var sheetConfiguration = CreateExcelConfigurationBuilder(weekDays, tenantStartDayOfWeek).BuildConfiguration(); var stream = new MemoryStream(); using (var reportBuilder = new OneTableExcelReportBuilder(new ExcelStyleApplier()) .PredefineStyles(GamePlanReportStyles.AllPredefineStyles)) { if (results.Count == 0) { _ = reportBuilder.Sheet(sheetName, sheetBuilder => { sheetBuilder.DataContent(results, sheetConfiguration); }); } else { for (int i = 0, page = 1; i < results.Count; i += PageSize, page++) { // copy for lambda int j = i; _ = reportBuilder.Sheet(sheetName, sheetBuilder => { sheetBuilder.DataContent(results.Skip(j).Take(PageSize).ToArray(), sheetConfiguration); }); sheetName = $"{SheetName} ({page})"; } } reportBuilder.SaveAs(stream); } _ = stream.Seek(0, SeekOrigin.Begin); return(stream); }
/// <summary>Generates the report.</summary> /// <param name="source">The source.</param> /// <returns></returns> public Stream GenerateReport(IReadOnlyCollection <Recommendation> source) { var extendedData = GenerateReportData(source); var sheetName = SheetName; var sheetConfiguration = CreateExcelConfigurationBuilder().BuildConfiguration(); var stream = new MemoryStream(); using (var reportBuilder = new OneTableExcelReportBuilder(new ExcelStyleApplier()) .PredefineStyles(GamePlanReportStyles.RecommendationReportPredefineStyles)) { if (extendedData.Count == 0) { _ = reportBuilder.Sheet(sheetName, sheetBuilder => { sheetBuilder.DataContent(extendedData, sheetConfiguration); }); } else { for (int i = 0, page = 1; i < extendedData.Count; i += PageSize, page++) { // copy for lambda int j = i; _ = reportBuilder.Sheet(sheetName, sheetBuilder => { sheetBuilder .Freeze(1, 2) .DataContent(extendedData.Skip(j).Take(PageSize).ToArray(), sheetConfiguration); }); sheetName = $"{SheetName} ({page})"; } } reportBuilder.SaveAs(stream); } _ = stream.Seek(0, SeekOrigin.Begin); return(stream); }