From 1cadee7eeccfeb7ffccc89c3c06622e4e641fdc8 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 16:26:56 +0400 Subject: [PATCH] fix --- .../BusinessLogic/ReportLogic.cs | 4 +- .../OfficePackage/AbstractSaveToExcel.cs | 80 ++++++++++++++++--- .../OfficePackage/AbstractSaveToWord.cs | 36 +++++++-- 3 files changed, 103 insertions(+), 17 deletions(-) diff --git a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs index 2a90d3a..6078833 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/ReportLogic.cs @@ -76,7 +76,7 @@ namespace BankBusinessLogic.BusinessLogic public void SaveTransfersToWordFile(ReportBindingModel model) { - _saveToWord.CreateDoc(new WordInfo + _saveToWord.CreateTransfersDoc(new WordInfo { FileName = model.FileName, Title = "Список переводов", @@ -89,7 +89,7 @@ namespace BankBusinessLogic.BusinessLogic public void SaveTransfersToExcelFile(ReportBindingModel model) { - _saveToExcel.CreateDoc(new ExcelInfo + _saveToExcel.CreateTransfersDoc(new ExcelInfo { FileName = model.FileName, Title = "Список переводов", diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index d011363..fcb7fca 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -11,10 +11,6 @@ namespace BankBusinessLogic.OfficePackage { public abstract class AbstractSaveToExcel { - /// - /// Создание отчета - /// - /// public void CreateRequestsDoc(ExcelInfo info) { CreateExcel(info); @@ -78,12 +74,76 @@ namespace BankBusinessLogic.OfficePackage rowIndex++; } SaveExcel(info); - } - /// - /// Создание excel-файла - /// - /// - protected abstract void CreateExcel(ExcelInfo info); + } + public void CreateTransfersDoc(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 transfer in info.Transfers) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "", + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + foreach (var component in transfer.Transfers) + { + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = rowIndex, + Text = "", + StyleInfo = + ExcelStyleInfoType.TextWithBroder + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = "", + StyleInfo = + ExcelStyleInfoType.TextWithBroder + }); + rowIndex++; + } + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = rowIndex, + Text = "Итого", + StyleInfo = ExcelStyleInfoType.Text + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = rowIndex, + Text = "", + StyleInfo = ExcelStyleInfoType.Text + }); + rowIndex++; + } + SaveExcel(info); + } + /// + /// Создание excel-файла + /// + /// + protected abstract void CreateExcel(ExcelInfo info); /// /// Добавляем новую ячейку в лист /// diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 74c6f57..8e45211 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -38,11 +38,37 @@ namespace BankBusinessLogic.OfficePackage CreateTable(wordTable); SaveWord(info); } - /// - /// Создание doc-файла - /// - /// - protected abstract void CreateWord(WordInfo info); + public void CreateTransfersDoc(WordInfo info) + { + CreateWord(info); + List> list = new List>(); + foreach (var shop in info.Shops) + { + var ls = new List + { + shop.ShopName, + shop.Address, + shop.OpeningDate.ToShortDateString() + }; + list.Add(ls); + } + var wordTable = new WordTable + { + Headers = new List { + "Название", + "Адрес", + "Дата открытия"}, + Columns = 3, + RowText = list + }; + CreateTable(wordTable); + SaveWord(info); + } + /// + /// Создание doc-файла + /// + /// + protected abstract void CreateWord(WordInfo info); /// /// Создание абзаца с текстом ///