DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/AutoGeneratedDailyReports/AutogeneratedDailyReportBlocks/TimeBalanceExcelBlockWriter.cs

38 lines
1.1 KiB
C#
Raw Normal View History

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)
{
if(!report.TimeBalance.Any())
return;
for (int i = 0; i < report.TimeBalance.Length; i++)
{
var row = sheet.Row(1 + i + rowHeaderBlock);
row.Cell(columnName).Value = report.TimeBalance[i].Name;
row.Cell(columnDurationHours).Value = report.TimeBalance[i].DurationHours;
AddBorderToCell(row.Cell(columnName));
AddBorderToCell(row.Cell(columnDurationHours));
}
}
private 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;
}
}