add excell report

This commit is contained in:
Zakharov_Rostislav 2024-05-27 00:10:56 +04:00
parent 610aae94b1
commit 0c88044384
4 changed files with 74 additions and 33 deletions

View File

@ -24,54 +24,86 @@ namespace BankBusinessLogic.OfficePackage
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
CellToName = "E1"
});
uint rowIndex = 2;
foreach (var transfer in info.Transfers)
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 2,
Text = "Номер счёта",
StyleInfo = ExcelStyleInfoType.Title
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = 2,
Text = "Номер заявки",
StyleInfo = ExcelStyleInfoType.Title
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = 2,
Text = "Статус заявки",
StyleInfo = ExcelStyleInfoType.Title
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "D",
RowIndex = 2,
Text = "Сумма заявки",
StyleInfo = ExcelStyleInfoType.Title
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "E",
RowIndex = 2,
Text = "Дата заявки",
StyleInfo = ExcelStyleInfoType.Title
});
uint rowIndex = 3;
foreach (var report in info.Requests)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "",
Text = report.AccountNumber,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var component in transfer.Transfers)
foreach (var request in report.Requests)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = "",
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = request.Id.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = "",
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = request.Status.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "D",
RowIndex = rowIndex,
Text = request.Sum.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "E",
RowIndex = rowIndex,
Text = request.RequestTime.ToString(),
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);
}

View File

@ -44,10 +44,10 @@ namespace BankBusinessLogic.OfficePackage
var wordTable = new WordTable
{
Headers = new List<string> {
"Номер карты",
"Номер счёта",
"Номер заявки",
"Статус заявки",
"Сумма выдачи",
"Сумма заявки",
"Дата заявки"},
Columns = 5,
RowText = table

View File

@ -494,7 +494,7 @@ namespace BankManagersClientApp.Controllers
APIClient.PostRequest("/api/report/saverequeststoexcel", new ReportBindingModel
{
SelectedAccountIds = accounts,
FileName = "C:\\Users\\user\\Downloads\\RequestList.docx",
FileName = "C:\\Users\\user\\Downloads\\RequestList.xlsx",
});
break;
default:

View File

@ -26,15 +26,24 @@ namespace BankRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения переводов в ворд");
_logger.LogError(ex, "Ошибка сохранения переводов в Word");
throw;
}
}
[HttpPost]
public void SaveRequestsToExcel(ReportBindingModel? model)
{
public void SaveRequestsToExcel(ReportBindingModel model)
{
try
{
_logic.SaveRequestsToExcelFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения переводов в Excel");
throw;
}
}
}
[HttpPost]
public void SaveTransfersToWord(ReportBindingModel model)
{