add ง.5-1
This commit is contained in:
88
Controllers/RequestProjectBudget.Controller.cs
Normal file
88
Controllers/RequestProjectBudget.Controller.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ClosedXML.Excel;
|
||||
using FastReport;
|
||||
using FastReport.Export.Csv;
|
||||
using FastReport.Export.Mht;
|
||||
using FastReport.Export.OoXML;
|
||||
using FastReport.Export.Pdf;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using rmutr_report.Models;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
namespace rmutr_report.Controllers
|
||||
{
|
||||
[SwaggerTag("สำหรับรายงาน ง.5-1")]
|
||||
public class RequestProjectBudget: Controller
|
||||
{
|
||||
readonly Setting _setting;
|
||||
|
||||
public RequestProjectBudget(Setting setting)
|
||||
{
|
||||
this._setting = setting;
|
||||
}
|
||||
[HttpPost, Route("reports/request_project_budget/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetRequestProjectBudgetReport([FromRoute] string type, [FromBody] request_project_budget project)
|
||||
{
|
||||
|
||||
// foreach (var v in project.five)
|
||||
// {
|
||||
// string na = "ประเด็นยุทธศาสตร์ที่ " ;
|
||||
// v.strategic_issues = na + v.strategic_issues;
|
||||
// string na2 = "กลยุทธ์ที่ " ;
|
||||
// v.measure = na2 + v.measure;
|
||||
// }
|
||||
// foreach (var v in project.eleventh)
|
||||
// {
|
||||
// foreach (var vv in v.elevenths)
|
||||
// {
|
||||
// string na = "ครั้งที่ ";
|
||||
// vv.the_time = na + vv.the_time;
|
||||
// }
|
||||
// }
|
||||
|
||||
var _project = new List<request_project_budget>() {project};
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "request_project_budget.frx");
|
||||
report.RegisterData(_project, "request_project_budget");
|
||||
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");
|
||||
break;
|
||||
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;
|
||||
case "doc":
|
||||
case "docx":
|
||||
Word2007Export word = new Word2007Export();
|
||||
report.Export(word, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "appllication/vnd.ms-word");
|
||||
break;
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user