2024-11-06 03:05:29 +04:00
|
|
|
|
using EventVisitorLogic.OfficePackage.HelperEnums;
|
|
|
|
|
using EventVisitorLogic.OfficePackage.HelperModels;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace EventVisitorLogic.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
|
|
|
|
|
});
|
2024-12-02 02:20:47 +04:00
|
|
|
|
MergeCells(new ExcelMergeParameters
|
|
|
|
|
{
|
|
|
|
|
CellFromName = "A1",
|
|
|
|
|
CellToName = "F1"
|
|
|
|
|
});
|
2024-11-06 03:05:29 +04:00
|
|
|
|
uint rowIndex = 2;
|
|
|
|
|
foreach (var pc in info.Visitors)
|
|
|
|
|
{
|
2024-12-02 02:20:47 +04:00
|
|
|
|
|
2024-11-06 03:05:29 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
|
|
|
|
ColumnName = "A",
|
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = pc.Name,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
2024-12-02 02:20:47 +04:00
|
|
|
|
MergeCells(new ExcelMergeParameters
|
|
|
|
|
{
|
|
|
|
|
CellFromName = $"A{rowIndex}",
|
|
|
|
|
CellToName = $"B{rowIndex}"
|
|
|
|
|
});
|
2024-11-06 03:05:29 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
2024-12-02 02:20:47 +04:00
|
|
|
|
ColumnName = "C",
|
2024-11-06 03:05:29 +04:00
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = pc.Email,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
2024-12-02 02:20:47 +04:00
|
|
|
|
MergeCells(new ExcelMergeParameters
|
|
|
|
|
{
|
|
|
|
|
CellFromName = $"C{rowIndex}",
|
|
|
|
|
CellToName = $"D{rowIndex}"
|
|
|
|
|
});
|
2024-11-06 03:05:29 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
2024-12-02 02:20:47 +04:00
|
|
|
|
ColumnName = "E",
|
2024-11-06 03:05:29 +04:00
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = pc.Phone,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
2024-12-02 02:20:47 +04:00
|
|
|
|
MergeCells(new ExcelMergeParameters
|
|
|
|
|
{
|
|
|
|
|
CellFromName = $"E{rowIndex}",
|
|
|
|
|
CellToName = $"F{rowIndex}"
|
|
|
|
|
});
|
2024-11-06 03:05:29 +04:00
|
|
|
|
InsertCellInWorksheet(new ExcelCellParameters
|
|
|
|
|
{
|
2024-12-02 02:20:47 +04:00
|
|
|
|
ColumnName = "G",
|
2024-11-06 03:05:29 +04:00
|
|
|
|
RowIndex = rowIndex,
|
|
|
|
|
Text = pc.Status,
|
|
|
|
|
StyleInfo = ExcelStyleInfoType.Text
|
|
|
|
|
});
|
2024-12-02 02:20:47 +04:00
|
|
|
|
MergeCells(new ExcelMergeParameters
|
|
|
|
|
{
|
|
|
|
|
CellFromName = $"G{rowIndex}",
|
|
|
|
|
CellToName = $"H{rowIndex}"
|
|
|
|
|
});
|
2024-11-06 03:05:29 +04:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|