2023-07-24 11:14:07 +05:00
|
|
|
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)
|
|
|
|
{
|
2023-07-28 11:14:45 +05:00
|
|
|
var i = 1;
|
|
|
|
foreach(var timeBalance in report.TimeBalance)
|
2023-07-24 11:14:07 +05:00
|
|
|
{
|
2023-07-28 11:14:45 +05:00
|
|
|
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));
|
2023-07-24 11:14:07 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-28 11:14:45 +05:00
|
|
|
private static void AddBorderToCell(IXLCell cell)
|
2023-07-24 11:14:07 +05:00
|
|
|
{
|
|
|
|
cell.Style.Border.TopBorder = XLBorderStyleValues.Thin;
|
|
|
|
cell.Style.Border.BottomBorder = XLBorderStyleValues.Thin;
|
|
|
|
cell.Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
|
|
cell.Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
|
|
}
|
|
|
|
}
|