public override byte[] Convert(ReportViewModel report) { if (report == null) { throw new ArgumentNullException(nameof(report)); } var prReport = report as WorkItemsReportViewModel; if (prReport == null) { throw new NotSupportedException($"Report of type {report.GetType()} is not supported by {nameof(WorkItemsReportToExcelConverter)}"); } var memory = new MemoryStream(); { var workbook = new XSSFWorkbook(); CreateResolvedWorkItemsReport(workbook, "Resolved Work Items", prReport.ResolvedWorkItems, prReport); CreateWorkItemsInPullRequestReport(workbook, "Work Items In Pull Request", prReport.WorkItemsInReview, prReport); CreateActiveWorkItemsReport(workbook, "Active Work Items", prReport.ActiveWorkItems, prReport); workbook.Write(memory); return(memory.ToArray()); } }
private List <string> GetAllPropertyNameOfReportViewModel() { var reportViewModel = new ReportViewModel(); var type = reportViewModel.GetType(); return(ReflectionUtilities.GetAllPropertyNamesOfType(type)); }
public override byte[] Convert(ReportViewModel report) { if (report == null) { throw new ArgumentNullException(nameof(report)); } var prReport = report as PullRequestReportViewModel; if (prReport == null) { throw new NotSupportedException($"Report of type {report.GetType()} is not supported by {nameof(PullRequestsReportToExcelConverter)}"); } var memory = new MemoryStream(); { var workbook = new XSSFWorkbook(); var excelSheet = workbook.CreateSheet($"{prReport.ProfileName}_{prReport.StartDate.ToString("yyyy_MM_dd")}_{prReport.EndDate.ToString("yyyy_MM_dd")}"); SetHeader(excelSheet); var rowIdx = 1; foreach (var reportEntry in prReport.IndividualReports) { var cellIdx = 0; var row = excelSheet.CreateRow(rowIdx); row.CreateCell(cellIdx++, CellType.String).SetCellValue(reportEntry.TeamMember); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.Created); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.Completed); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.Active); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.Abandoned); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.TotalIterations); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.AverageIterations.ToString("F2")); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.CodeQuality.ToString("F2")); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.TotalComments); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.AverageComments.ToString("F2")); row.CreateCell(cellIdx++, CellType.Numeric).SetCellValue(reportEntry.AveragePRLifespan.TotalDays.ToString("F2")); rowIdx++; } var summaryRow1 = excelSheet.CreateRow(rowIdx++); var summaryRow2 = excelSheet.CreateRow(rowIdx++); var summaryRow3 = excelSheet.CreateRow(rowIdx++); var summaryRow4 = excelSheet.CreateRow(rowIdx++); InitCells(summaryRow1, cellsCount: 7); InitCells(summaryRow2, cellsCount: 7); InitCells(summaryRow3, cellsCount: 7); InitCells(summaryRow4, cellsCount: 7); CreateSummaryRow(excelSheet, summaryRow1, "Total created:", "Avg iterations:", prReport.TotalCreated, prReport.AverageIterations); CreateSummaryRow(excelSheet, summaryRow2, "Total completed:", "Avg comments:", prReport.TotalCompleted, prReport.AverageComments); CreateSummaryRow(excelSheet, summaryRow3, "Total active:", "Code quality:", prReport.TotalActive, prReport.CodeQuality); CreateSummaryRow(excelSheet, summaryRow4, "Total abandoned:", "Avg lifespan:", prReport.TotalAbandoned, prReport.AveragePRLifespan.TotalDays); workbook.Write(memory); return(memory.ToArray()); } }