This commit is contained in:
Zakharov_Rostislav 2024-05-26 16:26:56 +04:00
parent 682fa772ea
commit 1cadee7eec
3 changed files with 103 additions and 17 deletions

View File

@ -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 = "Список переводов",

View File

@ -11,10 +11,6 @@ namespace BankBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcel
{
/// <summary>
/// Создание отчета
/// </summary>
/// <param name="info"></param>
public void CreateRequestsDoc(ExcelInfo info)
{
CreateExcel(info);
@ -78,12 +74,76 @@ namespace BankBusinessLogic.OfficePackage
rowIndex++;
}
SaveExcel(info);
}
/// <summary>
/// Создание excel-файла
/// </summary>
/// <param name="info"></param>
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);
}
/// <summary>
/// Создание excel-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateExcel(ExcelInfo info);
/// <summary>
/// Добавляем новую ячейку в лист
/// </summary>

View File

@ -38,11 +38,37 @@ namespace BankBusinessLogic.OfficePackage
CreateTable(wordTable);
SaveWord(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateWord(WordInfo info);
public void CreateTransfersDoc(WordInfo info)
{
CreateWord(info);
List<List<string>> list = new List<List<string>>();
foreach (var shop in info.Shops)
{
var ls = new List<string>
{
shop.ShopName,
shop.Address,
shop.OpeningDate.ToShortDateString()
};
list.Add(ls);
}
var wordTable = new WordTable
{
Headers = new List<string> {
"Название",
"Адрес",
"Дата открытия"},
Columns = 3,
RowText = list
};
CreateTable(wordTable);
SaveWord(info);
}
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateWord(WordInfo info);
/// <summary>
/// Создание абзаца с текстом
/// </summary>