2024-04-04 00:39:31 +04:00
|
|
|
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
|
|
|
|
using FlowerShopBusinessLogic.OfficePackage.HelperEnums;
|
2024-03-23 00:48:54 +04:00
|
|
|
|
using FlowerShopBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
|
|
|
|
|
namespace FlowerShopBusinessLogic.OfficePackage
|
|
|
|
|
{
|
|
|
|
|
public abstract class AbstractSaveToExcel
|
|
|
|
|
{
|
|
|
|
|
public void CreateReport(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;
|
2024-04-04 00:39:31 +04:00
|
|
|
|
foreach (var fc in info.FlowerComponents)
|
2024-03-23 00:48:54 +04:00
|
|
|
|
{
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
2024-04-04 00:39:31 +04:00
|
|
|
|
Text = fc.FlowerName,
|
2024-03-23 00:48:54 +04:00
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
rowIndex++;
|
2024-04-04 00:39:31 +04:00
|
|
|
|
foreach (var (Flower, Count) in fc.Components)
|
2024-03-23 00:48:54 +04:00
|
|
|
|
{
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "B",
|
|
|
|
|
RowIndex = rowIndex,
|
2024-04-04 00:39:31 +04:00
|
|
|
|
Text = Flower,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
2024-03-23 00:48:54 +04:00
|
|
|
|
});
|
2024-04-04 00:39:31 +04:00
|
|
|
|
|
2024-03-23 00:48:54 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
2024-04-04 00:39:31 +04:00
|
|
|
|
Text = Count.ToString(),
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
2024-03-23 00:48:54 +04:00
|
|
|
|
});
|
2024-04-04 00:39:31 +04:00
|
|
|
|
|
2024-03-23 00:48:54 +04:00
|
|
|
|
rowIndex++;
|
|
|
|
|
}
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = "Итого",
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "C",
|
|
|
|
|
RowIndex = rowIndex,
|
2024-04-04 00:39:31 +04:00
|
|
|
|
Text = fc.TotalCount.ToString(),
|
2024-03-23 00:48:54 +04:00
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|