using System.Linq; using AsbCloudApp.Data.AutogeneratedDailyReport; using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.AutoGeneratedDailyReports.AutogeneratedDailyReportBlocks; public class TimeBalanceExcelBlockWriter : IExcelBlockWriter { private const int rowHeaderBlock = 27; private const int columnName = 1; private const int columnDurationHours = 2; public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report) { var i = 1; foreach(var timeBalance in report.TimeBalance) { var row = sheet.Row(i++ + rowHeaderBlock); row.Cell(columnName).Value = timeBalance.Name; row.Cell(columnDurationHours).Value = timeBalance.DurationHours; AddBorderToCell(row.Cell(columnName)); AddBorderToCell(row.Cell(columnDurationHours)); } } private static void AddBorderToCell(IXLCell cell) { cell.Style.Border.TopBorder = XLBorderStyleValues.Thin; cell.Style.Border.BottomBorder = XLBorderStyleValues.Thin; cell.Style.Border.LeftBorder = XLBorderStyleValues.Thin; cell.Style.Border.RightBorder = XLBorderStyleValues.Thin; } }