edit format excel
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kamonwan taengsuk
2024-10-04 13:18:29 +07:00
parent ca8e2cd529
commit 2aa5821fff
15 changed files with 283 additions and 30 deletions

View File

@@ -9,6 +9,7 @@ using FastReport.Export.Csv;
using FastReport.Export.Mht;
using FastReport.Export.OoXML;
using FastReport.Export.Pdf;
using FastReport.Table;
using Microsoft.AspNetCore.Mvc;
using rmutr_report.Models;
using rmutr_report.Models.Personnel;
@@ -2877,33 +2878,35 @@ namespace rmutr_report.Controllers
var budgetExpenditure = new List<budget_expenditure_report_from_revenue_v2>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_v2.frx");
report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2");
report.Prepare();
MemoryStream stream = new MemoryStream();
switch (type)
if (type=="pdf")
{
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",
"budgetExpenditureV2_" + date + ".xlsx");
report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_v2.frx");
report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2");
report.Prepare();
PDFExport pdf = new PDFExport();
report.Export(pdf, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf");
}
if (type=="xls"||type=="xlsx")
{
report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_excel2.frx");
report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2");
report.Prepare();
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"budgetExpenditureV2_" + date + ".xlsx");
}
return Ok();
}