add report

This commit is contained in:
kamonwan taengsuk
2023-07-13 17:53:23 +07:00
parent b18118e309
commit ebcdbffb23
8 changed files with 210 additions and 1 deletions

View File

@@ -2315,6 +2315,42 @@ namespace rmutr_report.Controllers
"summary_budget_university_" + date + ".xlsx");
}
return Ok();
}
[HttpPost, Route("reports/budget_expenditure_report_from_revenue/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetExpenditureRevenueReport([FromRoute] string type,
[FromBody] budget_expenditure_report_from_revenue budget)
{
var budgetExpenditure = new List<budget_expenditure_report_from_revenue>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "budget_expenditure_report_from_revenue.frx");
report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue");
report.Prepare();
MemoryStream stream = new MemoryStream();
switch (type)
{
case "pdf":
PDFExport pdf = new PDFExport();
report.Export(pdf, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf");
case "xls":
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
//return File(stream, "application/vnd.ms-excel");
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"budgetExpenditure_" + date + ".xlsx");
}
return Ok();
}
}