CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopBusinessLogic/OfficePackage/AbstractSaveToExcelEmployee.cs

70 lines
2.1 KiB
C#
Raw Permalink Normal View History

using ElectronicsShopBusinessLogic.OfficePackage.HelperEnums;
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
namespace ElectronicsShopBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcelEmployee
{
public void CreateReport(ExcelInfoEmployee info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var pc in info.Products)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ProductName.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
2024-06-01 02:22:36 +04:00
InsertCellInWorksheet(new ExcelCellParameters
{
2024-06-01 02:22:36 +04:00
ColumnName = "B",
RowIndex = rowIndex,
Text = pc.ProductName.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
2024-06-01 02:22:36 +04:00
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = pc.Price.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfoEmployee info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfoEmployee info);
}
}