ComputerHardwareStore_YouAr.../ComputerHardwareStore/ComputerHardwareStoreBusinessLogic/OfficePackage/AbstractSaveToExcel.cs

113 lines
2.7 KiB
C#
Raw Permalink Normal View History

2024-05-27 19:58:48 +04:00
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperEnums;
using ComputerHardwareStoreBusinessLogic.OfficePackage.HelperModels;
namespace ComputerHardwareStoreBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcel
{
public void CreateReportProduct(ExcelInfo 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 pb in info.ProductBuilds)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pb.ProductName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var Build in pb.Builds)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Build.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Build.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
rowIndex++;
}
SaveExcel(info);
}
public void CreateReportBuild(ExcelInfo 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 bp in info.BuildProducts)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = bp.BuildName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
2024-05-27 20:36:02 +04:00
foreach (var Product in bp.Products)
2024-05-27 19:58:48 +04:00
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
2024-05-27 20:36:02 +04:00
Text = Product.Item1,
2024-05-27 19:58:48 +04:00
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
2024-05-27 20:36:02 +04:00
Text = Product.Item2.ToString(),
2024-05-27 19:58:48 +04:00
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfo info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfo info);
}
}