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 }); MergeCells(new ExcelMergeParameters { CellFromName = "A1", CellToName = "F1" }); uint rowIndex = 2; foreach (var pc in info.Visitors) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "A", RowIndex = rowIndex, Text = pc.Name, StyleInfo = ExcelStyleInfoType.Text }); MergeCells(new ExcelMergeParameters { CellFromName = $"A{rowIndex}", CellToName = $"B{rowIndex}" }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, Text = pc.Email, StyleInfo = ExcelStyleInfoType.Text }); MergeCells(new ExcelMergeParameters { CellFromName = $"C{rowIndex}", CellToName = $"D{rowIndex}" }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "E", RowIndex = rowIndex, Text = pc.Phone, StyleInfo = ExcelStyleInfoType.Text }); MergeCells(new ExcelMergeParameters { CellFromName = $"E{rowIndex}", CellToName = $"F{rowIndex}" }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "G", RowIndex = rowIndex, Text = pc.Status, StyleInfo = ExcelStyleInfoType.Text }); MergeCells(new ExcelMergeParameters { CellFromName = $"G{rowIndex}", CellToName = $"H{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); } }