add report

This commit is contained in:
kamonwan taengsuk
2023-07-06 18:24:06 +07:00
parent 7d39937527
commit 2bdfb659c9
21 changed files with 333 additions and 2454 deletions

View File

@@ -1554,5 +1554,41 @@ namespace rmutr_report.Controllers
"basic_plan_all_" + date + ".xlsx");
}
}
[HttpPost, Route("reports/summary_strategic/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumStrategicReport([FromRoute] string type, [FromBody] summary_strategic summary_strategics)
{ var _summary_strategic = new List<summary_strategic>() { summary_strategics };
Report report = new Report();
report.Load(_setting.report_path + "summary_strategic.frx");
report.RegisterData(_summary_strategic, "summary_strategic");
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",
date + ".xlsx");
break;
}
return Ok();
}
}
}