Files
rmutr_report/Controllers/Budget.Controller.cs
kamonwan taengsuk 438286ba8b
All checks were successful
continuous-integration/drone/push Build is passing
Bug Fixed
2024-09-04 15:27:55 +07:00

4883 lines
317 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
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 rmutr_report.Models.Personnel;
using rmutr_report.Models.RoThree;
using Swashbuckle.AspNetCore.Annotations;
namespace rmutr_report.Controllers
{
[SwaggerTag("สำหรับรายงาน_budget")]
public class Budget : Controller
{
readonly Setting _setting;
public Budget(Setting setting)
{
_setting = setting;
}
[SwaggerOperation(Summary = "รายงานงบประมาณแยกตามพื้นที่")]
[HttpPost, Route("reports/budget_report/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSum1Report([FromRoute] string type, [FromBody] List<budget_report> budget_reports)
{
foreach (var x in budget_reports)
{
int sum1 = budget_reports.Sum(g => int.Parse(g.salaya));
x.sum1 = sum1;
int sum2 = budget_reports.Sum(g => int.Parse(g.bophitphimuk));
x.sum2 = sum2;
int sum3 = budget_reports.Sum(g => int.Parse(g.pohchang));
x.sum3 = sum3;
int sum4 = budget_reports.Sum(g => int.Parse(g.klai_kangwon));
x.sum4 = sum4;
int sum5 = budget_reports.Sum(g => int.Parse(g.total));
x.sum5 = sum5;
}
Report report = new Report();
report.Load(_setting.report_path + "budget_report.frx");
report.RegisterData(budget_reports, "budget_report");
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":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/vnd.ms-excel");
break;
case "mht":
MHTExport mht = new MHTExport();
report.Export(mht, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "multipart/related");
break;
case "csv":
CSVExport csv = new CSVExport();
report.Export(csv, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "text/csv");
break;
}
return Ok();
}
[SwaggerOperation(Summary = "รายงานสรุปงบประมาณรายจ่าย")]
[HttpPost, Route("reports/budget_summary_report/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumReport([FromRoute] string type,
[FromBody] budget_summary_report budget_summary_reports)
{
var _budget_summary_report = new List<budget_summary_report>() { budget_summary_reports };
var s1 = budget_summary_reports.summary.Sum(d => d.budget_1);
var s2 = budget_summary_reports.summary.Sum(d => d.budget_2);
var s3 = budget_summary_reports.summary.Sum(d => d.budget_3);
var s4 = budget_summary_reports.summary.Sum(d => d.budget_4);
var s5 = budget_summary_reports.summary.Sum(d => d.budget_5);
if (s1 != null || s2 != null || s3 != null || s4 != null || s5 != null)
{
var s6 = s1 + s2 + s3 + s4 + s5;
budget_summary_reports.total_budget = s6;
}
if (s1 != null || s2 != null || s3 != null || s4 != null || s5 != null)
{
budget_summary_reports.budget_1 = s1;
budget_summary_reports.budget_2 = s2;
budget_summary_reports.budget_3 = s3;
budget_summary_reports.budget_4 = s4;
budget_summary_reports.budget_5 = s5;
//budget_summary_reports.total_budget = s6;
}
if (s1 == null)
{
budget_summary_reports.budget_1 = null;
}
if (s2 == null)
{
budget_summary_reports.budget_2 = null;
}
if (s3 == null)
{
budget_summary_reports.budget_3 = null;
}
if (s4 == null)
{
budget_summary_reports.budget_4 = null;
}
if (s5 == null)
{
budget_summary_reports.budget_5 = null;
}
foreach (var budget in budget_summary_reports.summary)
{
if (budget.budget_1 != null || budget.budget_2 != null || budget.budget_3 != null ||
budget.budget_4 != null || budget.budget_5 != null)
{
budget.total_budget = budget.budget_1 + budget.budget_2 + budget.budget_3 + budget.budget_4 +
budget.budget_5;
}
else
{
return null;
}
}
if (budget_summary_reports.durable_articles_1 != null)
{
foreach (var bDetail in budget_summary_reports.durable_articles_1)
{
if (bDetail.color == 1)
{
budget_summary_reports.list = bDetail.list;
budget_summary_reports.total_amount = bDetail.total_amount;
}
// if (bDetail.color == 2)
// {
// budget_summary_reports.list = bDetail.list;
// budget_summary_reports.total_amount = bDetail.total_amount;
// }
// foreach (var bDetail2 in bDetail.durable_articles_2)
// {
// if (bDetail2.color == 3)
// {
// budget_summary_reports.list = bDetail2.list;
// budget_summary_reports.total_amount = bDetail2.total_amount;
// }
// foreach (var bDetail3 in bDetail2.durable_articles_3)
// {
// if (bDetail3.color == 4)
// {
// budget_summary_reports.list = bDetail3.list;
// budget_summary_reports.total_amount = bDetail3.total_amount;
// }
// foreach (var bDetail4 in bDetail3.durable_articles_4)
// {
// if (bDetail4.color == 5)
// {
// budget_summary_reports.list = bDetail4.list;
// budget_summary_reports.total_amount = bDetail4.total_amount;
// }
// }
// }
// }
}
}
if (budget_summary_reports.building_1 != null)
{
foreach (var bDetail in budget_summary_reports.building_1)
{
if (bDetail.color == 1)
{
budget_summary_reports.list1 = bDetail.list;
budget_summary_reports.total_amount1 = bDetail.total_amount;
}
// if (bDetail.color == 2)
// {
// budget_summary_reports.list1 = bDetail.list;
// budget_summary_reports.total_amount1 = bDetail.total_amount;
// }
}
}
Report report = new Report();
report.Load(_setting.report_path + "budget_summary_report.frx");
report.RegisterData(_budget_summary_report, "budget_summary_report");
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");
break;
case "mht":
MHTExport mht = new MHTExport();
report.Export(mht, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "multipart/related");
break;
case "csv":
CSVExport csv = new CSVExport();
report.Export(csv, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "text/csv");
break;
}
return Ok();
}
[SwaggerOperation("สรุปรายการสิ่งก่อสร้างที่เสนอขอ")]
[HttpPost, Route("reports/summary_building_table/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumbuildingReport([FromRoute] string type,
[FromBody] budget_summary_report budget_summary_reports)
{
var _budget_summary_report = new List<budget_summary_report>() { budget_summary_reports };
if (budget_summary_reports.building_1 != null)
{
foreach (var bDetail in budget_summary_reports.building_1)
{
if (bDetail.color == 1)
{
budget_summary_reports.list1 = bDetail.list;
budget_summary_reports.total_amount1 = bDetail.total_amount;
}
// if (bDetail.color == 2)
// {
// budget_summary_reports.list1 = bDetail.list;
// budget_summary_reports.total_amount1 = bDetail.total_amount;
// }
}
}
Report report = new Report();
report.Load(_setting.report_path + "summary_building_table.frx");
report.RegisterData(_budget_summary_report, "budget_summary_report");
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");
break;
case "mht":
MHTExport mht = new MHTExport();
report.Export(mht, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "multipart/related");
break;
case "csv":
CSVExport csv = new CSVExport();
report.Export(csv, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "text/csv");
break;
}
return Ok();
}
[SwaggerOperation("สรุปรายการครุภัณฑ์ที่เสนอขอ")]
[HttpPost, Route("reports/summary_durable_articles_table/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumDurableArticlesReport([FromRoute] string type,
[FromBody] budget_summary_report budget_summary_reports)
{
var _budget_summary_report = new List<budget_summary_report>() { budget_summary_reports };
Report report = new Report();
report.Load(_setting.report_path + "summary_durable_articles_table.frx");
report.RegisterData(_budget_summary_report, "budget_summary_report");
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");
break;
case "mht":
MHTExport mht = new MHTExport();
report.Export(mht, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "multipart/related");
break;
case "csv":
CSVExport csv = new CSVExport();
report.Export(csv, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "text/csv");
break;
}
return Ok();
}
[SwaggerOperation("ตารางและรายงานสรุปคำขอในส่วนของโครงการทั้งหมด")]
[HttpPost, Route("reports/summary_all_project_table/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumAllProjectReport([FromRoute] string type,
[FromBody] budget_summary_report budget_summary_reports)
{
var _budget_summary_report = new List<budget_summary_report>() { budget_summary_reports };
Report report = new Report();
report.Load(_setting.report_path + "summary_all_project_table.frx");
report.RegisterData(_budget_summary_report, "budget_summary_report");
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");
break;
case "mht":
MHTExport mht = new MHTExport();
report.Export(mht, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "multipart/related");
break;
case "csv":
CSVExport csv = new CSVExport();
report.Export(csv, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "text/csv");
break;
}
return Ok();
}
[SwaggerOperation("สรุปการเสนอของบประมาณโครงการประจำปีงบประมาณ")]
[HttpPost, Route("reports/summary_project_budget_proposals/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumPReport([FromRoute] string type, [FromBody] summary_project_budget_proposals eleven)
{
int a = 1;
foreach (var d1 in eleven.data_1)
{
foreach (var d2 in d1.data_2)
{
foreach (var d3 in d2.data_3)
{
foreach (var d4 in d3.data_4)
{
d4.row_no = a;
a++;
}
}
}
}
var ele = new List<summary_project_budget_proposals>() { eleven };
Report report = new Report();
report.Load(_setting.report_path + "summary_project_budget_proposals.frx");
report.RegisterData(ele, "summary_project_budget_proposals");
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();
}
[SwaggerOperation("งบประมาณแผ่นดิน พื้นฐาน")]
[HttpPost, Route("reports/basic_plan/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBasicPlanReport([FromRoute] string type,
[FromBody] national_budget personnel)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("พื้นฐาน");
ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + personnel.academic_year_name_th;
ws.Cell("A1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell("A1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A1").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 10;
ws.Cell("A1").Style.Font.Bold = true;
ws.Cell("A2").Value = personnel.agency_name_th;
ws.Cell("A2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell("A2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A2").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A2").Style.Font.FontSize = 10;
ws.Cell("A2").Style.Font.Bold = true;
ws.Cell("F2").Value = "แผนพื้นฐาน";
ws.Cell("F2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("F2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("F2").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("F2").Style.Font.FontSize = 10;
ws.Cell("F2").Style.Font.Bold = true;
//ws.Cell("K12").Style.NumberFormat.Format = "#,##0.0000";
ws.Column(1).Width = 40;
ws.Column(2).Width = 15;
ws.Column(3).Width = 15;
ws.Column(4).Width = 15;
ws.Column(5).Width = 15;
ws.Column(6).Width = 15;
ws.Column(7).Width = 15;
int row = 6;
//int no = 1;
if (personnel != null)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:A5").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A3:A5").Style.Font.SetBold().Font.FontSize = 10;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B3:F3").Merge().Value = "งบประมาณ " + personnel.academic_year_name_th + " (เบื้องต้น)";
ws.Range("B3:F3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("B3:F3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("B3:F3").Style.Font.FontName = "TH SarabunPSK";
ws.Range("B3:F3").Style.Font.SetBold().Font.FontSize = 10;
ws.Range("B3:F3").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("B3:F3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("B4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " วิทย์";
ws.Cell("B4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("B4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("B4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("B4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("B4").Style.Alignment.WrapText = true;
ws.Cell("B4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("C4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " สังคม";
ws.Cell("C4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("C4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("C4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("C4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("C4").Style.Alignment.WrapText = true;
ws.Cell("C4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("C4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("D4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " บริการวิชาการ";
ws.Cell("D4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("D4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("D4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("D4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("D4").Style.Alignment.WrapText = true;
ws.Cell("D4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("D4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("E4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " ทำนุบำรุง";
ws.Cell("E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("E4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("E4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("E4").Style.Alignment.WrapText = true;
ws.Cell("E4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("F4").Value = "งบประมาณปี " + personnel.academic_year_name_th.Substring(2, 2);
ws.Cell("F4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("F4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("F4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("F4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("F4").Style.Alignment.WrapText = true;
ws.Cell("F4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("B4:F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(4, 2), ws.Cell(4, 6)).Style.Alignment.WrapText = true;
ws.Cell(5, 2).Value = personnel.science;
ws.Cell(5, 3).Value = personnel.society;
ws.Cell(5, 4).Value = personnel.academic_service;
ws.Cell(5, 5).Value = personnel.nourish;
ws.Cell(5, 6).Value = personnel.budget;
ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.national_budget_details)
{
if (detail.topic_type == 1)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, 5).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 2)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, 5).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Fill.BackgroundColor =
XLColor.FromArgb(255, 204, 153);
row++;
}
if (detail.topic_type == 3)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, 5).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 4)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, 5).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Fill.BackgroundColor =
XLColor.FromArgb(255, 204, 204);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 5)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, 5).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Fill.BackgroundColor =
XLColor.FromArgb(255, 255, 204);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
}
}
var _national_budget = new List<national_budget>() { personnel };
Report report = new Report();
//report.Load();
report.RegisterData(_national_budget, "national_budget");
report.Prepare();
MemoryStream stream = new MemoryStream();
switch (type)
{
case "pdf":
{
workbook.SaveAs(stream);
var content = stream.ToArray();
stream.Position = 0;
// Set the content type and return the PDF file
return File(content, "application/pdf", "converted.pdf");
}
case "xlsx":
{
workbook.SaveAs(stream);
var content = stream.ToArray();
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"basic_plan_" + date + ".xlsx");
}
default:
return Ok();
}
}
[SwaggerOperation("งบประมาณแผ่นดิน แผนบูรณาการ+แผนยุทธศาสตร์")]
[HttpPost, Route("reports/integration_strategic_plan/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetInStrPlanReport([FromRoute] string type,
[FromBody] integration_strategic_plan personnel)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("แผนบูรณาการ+แผนยุทธศาสตร์");
ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + personnel.academic_year_name_th;
ws.Cell("A1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell("A1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A1").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 10;
ws.Cell("A1").Style.Font.Bold = true;
ws.Cell("A2").Value = personnel.agency_name_th;
ws.Cell("A2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell("A2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A2").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A2").Style.Font.FontSize = 10;
ws.Cell("A2").Style.Font.Bold = true;
ws.Cell("K2").Value = "แผนบูรณาการ+แผนยุทธศาสตร์";
ws.Cell("K2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell("K2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("K2").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("K2").Style.Font.FontSize = 10;
ws.Cell("K2").Style.Font.Bold = true;
//ws.Cell("K12").Style.NumberFormat.Format = "#,##0.0000";
ws.Column(1).Width = 30;
ws.Column(2).Width = 15;
ws.Column(3).Width = 15;
ws.Column(4).Width = 15;
ws.Column(5).Width = 15;
ws.Column(6).Width = 15;
ws.Column(7).Width = 15;
ws.Column(8).Width = 15;
ws.Column(9).Width = 15;
ws.Column(10).Width = 15;
ws.Column(11).Width = 15;
int row = 6;
//int no = 1;
if (personnel != null)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:A5").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A3:A5").Style.Font.SetBold().Font.FontSize = 10;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B3:G3").Merge().Value = "งบประมาณ " + personnel.academic_year_name_th + " (เบื้องต้น)";
ws.Range("B3:G3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("B3:G3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("B3:G3").Style.Font.FontName = "TH SarabunPSK";
ws.Range("B3:G3").Style.Font.SetBold().Font.FontSize = 10;
ws.Range("B3:G3").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("B3:G3").Style.Border.TopBorder = XLBorderStyleValues.Thin;
ws.Cell("B3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range("H3:K3").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("B4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานบูรณาการ พัฒนาและส่งเสริมเศรษฐกิจฐานราก";
ws.Cell("B4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("B4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("B4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("B4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("B4").Style.Alignment.WrapText = true;
ws.Cell("B4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("C4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานบูรณาการ สร้างรายได้ จากการท่องเที่ยว";
ws.Cell("C4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("C4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("C4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("C4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("C4").Style.Alignment.WrapText = true;
ws.Cell("C4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("C4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("D4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนบูรณาการพัฒนาด้านคมนาคมและระบบโลจิสติกส์";
ws.Cell("D4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("D4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("D4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("D4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("D4").Style.Alignment.WrapText = true;
ws.Cell("D4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("D4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("E4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนบูรณาการ พัฒนาภาค (ภาคกลาง)";
ws.Cell("E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("E4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("E4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("E4").Style.Alignment.WrapText = true;
ws.Cell("E4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("E4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("F4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานบูรณาการพัฒนาอุตสาหกรรมและบริการแห่งอนาคต";
ws.Cell("F4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("F4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("F4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("F4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("F4").Style.Alignment.WrapText = true;
ws.Cell("F4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("G4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์พัฒนาเศรษฐกิจและสังคมดิจิทัล";
ws.Cell("G4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("G4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("G4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("G4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("G4").Style.Alignment.WrapText = true;
ws.Cell("G4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("G4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("H4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์ (โครงการสำคัญ)";
ws.Cell("H4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("H4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("H4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("H4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("H4").Style.Alignment.WrapText = true;
ws.Cell("H4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("H4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("I4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์ฯโครงการพัฒนาและผลิตกำลังคนของประเทศฯ Thailand 4.0";
ws.Cell("I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("I4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("I4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("I4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("I4").Style.Alignment.WrapText = true;
ws.Cell("I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("I4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("J4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์การพัฒนาผู้ประกอบการ และวิสาหกิจ ขนาดกลางและขนาดย่อมสู่สากล (SME)";
ws.Cell("J4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("J4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("J4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("J4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("J4").Style.Alignment.WrapText = true;
ws.Cell("J4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("J4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("K4").Value = "งบประมาณ ปี " + personnel.academic_year_name_th.Substring(2, 2);
ws.Cell("K4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("K4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("K4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("K4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("K4").Style.Alignment.WrapText = true;
ws.Cell("K4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("K4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("H3:K3").Style.Border.TopBorder = XLBorderStyleValues.Thin;
ws.Cell("K3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(4, 2), ws.Cell(4, 11)).Style.Alignment.WrapText = true;
ws.Cell(5, 2).Value = personnel.plan_1;
ws.Cell(5, 3).Value = personnel.plan_2;
ws.Cell(5, 4).Value = personnel.plan_3;
ws.Cell(5, 5).Value = personnel.plan_4;
ws.Cell(5, 6).Value = personnel.plan_5;
ws.Cell(5, 7).Value = personnel.plan_6;
ws.Cell(5, 8).Value = personnel.plan_7;
ws.Cell(5, 9).Value = personnel.plan_8;
ws.Cell(5, 10).Value = personnel.plan_9;
ws.Cell(5, 11).Value = personnel.budget;
ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.integration_strategic_plan_details)
{
if (detail.topic_type == 1)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.plan_1;
ws.Cell(row, 3).Value = detail.plan_2;
ws.Cell(row, 4).Value = detail.plan_3;
ws.Cell(row, 5).Value = detail.plan_4;
ws.Cell(row, 6).Value = detail.plan_5;
ws.Cell(row, 7).Value = detail.plan_6;
ws.Cell(row, 8).Value = detail.plan_7;
ws.Cell(row, 9).Value = detail.plan_8;
ws.Cell(row, 10).Value = detail.plan_9;
ws.Cell(row, 11).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 2) //ชื่อแผน
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.plan_1;
ws.Cell(row, 3).Value = detail.plan_2;
ws.Cell(row, 4).Value = detail.plan_3;
ws.Cell(row, 5).Value = detail.plan_4;
ws.Cell(row, 6).Value = detail.plan_5;
ws.Cell(row, 7).Value = detail.plan_6;
ws.Cell(row, 8).Value = detail.plan_7;
ws.Cell(row, 9).Value = detail.plan_8;
ws.Cell(row, 10).Value = detail.plan_9;
ws.Cell(row, 11).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
//ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(204,153,255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 3) //ชื่อโครงการ
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.plan_1;
ws.Cell(row, 3).Value = detail.plan_2;
ws.Cell(row, 4).Value = detail.plan_3;
ws.Cell(row, 5).Value = detail.plan_4;
ws.Cell(row, 6).Value = detail.plan_5;
ws.Cell(row, 7).Value = detail.plan_6;
ws.Cell(row, 8).Value = detail.plan_7;
ws.Cell(row, 9).Value = detail.plan_8;
ws.Cell(row, 10).Value = detail.plan_9;
ws.Cell(row, 11).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
//ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(204,153,255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 4) //ชื่อกิจกรรม
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.plan_1;
ws.Cell(row, 3).Value = detail.plan_2;
ws.Cell(row, 4).Value = detail.plan_3;
ws.Cell(row, 5).Value = detail.plan_4;
ws.Cell(row, 6).Value = detail.plan_5;
ws.Cell(row, 7).Value = detail.plan_6;
ws.Cell(row, 8).Value = detail.plan_7;
ws.Cell(row, 9).Value = detail.plan_8;
ws.Cell(row, 10).Value = detail.plan_9;
ws.Cell(row, 11).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
//ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(204,153,255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
}
}
using (var stream1 = new MemoryStream())
{
workbook.SaveAs(stream1);
var content = stream1.ToArray();
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"integration_strategic_plan_" + date + ".xlsx");
}
}
[SwaggerOperation("งบประมาณแผ่นดิน รวมทุกแผน")]
[HttpPost, Route("reports/basic_plan_all/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBasicPlanAllReport([FromRoute] string type,
[FromBody] integration_strategic_plan personnel)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("รวมทุกแผน");
ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + personnel.academic_year_name_th + " (เบื้องต้น)";
ws.Cell("A1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell("A1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A1").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 10;
ws.Cell("A1").Style.Font.Bold = true;
ws.Cell("A2").Value = personnel.agency_name_th;
ws.Cell("A2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell("A2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A2").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A2").Style.Font.FontSize = 10;
ws.Cell("A2").Style.Font.Bold = true;
ws.Cell("O2").Value = "รวมทุกแผน";
ws.Cell("O2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("O2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("O2").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("O2").Style.Font.FontSize = 10;
ws.Cell("O2").Style.Font.Bold = true;
//ws.Cell("K12").Style.NumberFormat.Format = "#,##0.0000";
ws.Column(1).Width = 30;
ws.Column(2).Width = 10;
ws.Column(3).Width = 10;
ws.Column(4).Width = 10;
ws.Column(5).Width = 10;
ws.Column(6).Width = 10;
ws.Column(7).Width = 10;
ws.Column(8).Width = 10;
ws.Column(9).Width = 10;
ws.Column(10).Width = 10;
ws.Column(11).Width = 10;
ws.Column(12).Width = 10;
ws.Column(13).Width = 10;
ws.Column(14).Width = 10;
ws.Column(15).Width = 10;
ws.Column(16).Width = 10;
int row = 6;
//int no = 1;
if (personnel != null)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:A5").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A3:A5").Style.Font.SetBold().Font.FontSize = 10;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B3:O3").Merge().Value = "งบประมาณ " + personnel.academic_year_name_th + " (เบื้องต้น)";
ws.Range("B3:O3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("B3:O3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("B3:O3").Style.Font.FontName = "TH SarabunPSK";
ws.Range("B3:O3").Style.Font.SetBold().Font.FontSize = 10;
ws.Range("B3:O3").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("B3:O3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("B4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " วิทย์";
ws.Cell("B4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("B4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("B4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("B4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("B4").Style.Alignment.WrapText = true;
ws.Cell("B4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("C4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " สังคม";
ws.Cell("C4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("C4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("C4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("C4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("C4").Style.Alignment.WrapText = true;
ws.Cell("C4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("C4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("D4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " บริการวิชาการ";
ws.Cell("D4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("D4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("D4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("D4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("D4").Style.Alignment.WrapText = true;
ws.Cell("D4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("D4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("E4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) + " ทำนุบำรุง";
ws.Cell("E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("E4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("E4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("E4").Style.Alignment.WrapText = true;
ws.Cell("E4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("E4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("F4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานบูรณาการ พัฒนาและส่งเสริมเศรษฐกิจฐานราก";
ws.Cell("F4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("F4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("F4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("F4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("F4").Style.Alignment.WrapText = true;
ws.Cell("F4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("G4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานบูรณาการ สร้างรายได้ จากการท่องเที่ยว";
ws.Cell("G4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("G4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("G4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("G4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("G4").Style.Alignment.WrapText = true;
ws.Cell("G4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("G4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("H4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนบูรณาการพัฒนาด้านคมนาคมและระบบโลจิสติกส์";
ws.Cell("H4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("H4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("H4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("H4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("H4").Style.Alignment.WrapText = true;
ws.Cell("H4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("H4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("I4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนบูรณาการ พัฒนาภาค (ภาคกลาง)";
ws.Cell("I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("I4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("I4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("I4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("I4").Style.Alignment.WrapText = true;
ws.Cell("I4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("J4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานบูรณาการพัฒนาอุตสาหกรรมและบริการแห่งอนาคต";
ws.Cell("J4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("J4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("J4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("J4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("J4").Style.Alignment.WrapText = true;
ws.Cell("J4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("K4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์พัฒนาเศรษฐกิจและสังคมดิจิทัล";
ws.Cell("K4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("K4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("K4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("K4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("K4").Style.Alignment.WrapText = true;
ws.Cell("K4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("L4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์ (โครงการสำคัญ)";
ws.Cell("L4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("L4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("L4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("L4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("L4").Style.Alignment.WrapText = true;
ws.Cell("L4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("L4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("M4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์ฯโครงการพัฒนาและผลิตกำลังคนของประเทศฯ Thailand 4.0";
ws.Cell("M4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("M4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("M4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("M4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("M4").Style.Alignment.WrapText = true;
ws.Cell("M4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("M4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("N4").Value = " ปี " + personnel.academic_year_name_th.Substring(2, 2) +
" แผนงานยุทธศาสตร์การพัฒนาผู้ประกอบการ และวิสาหกิจ ขนาดกลางและขนาดย่อมสู่สากล (SME)";
ws.Cell("N4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("N4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("N4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("N4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("N4").Style.Alignment.WrapText = true;
ws.Cell("N4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("N4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("O4").Value = "งบประมาณ ปี " + personnel.academic_year_name_th.Substring(2, 2);
ws.Cell("O4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell("O4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("O4").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("O4").Style.Font.SetBold().Font.FontSize = 10;
ws.Cell("O4").Style.Alignment.WrapText = true;
ws.Cell("O4").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell("O4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B4:O4").Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range("B4:O4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(4, 2), ws.Cell(4, 14)).Style.Alignment.WrapText = true;
ws.Cell(5, 2).Value = personnel.science;
ws.Cell(5, 3).Value = personnel.society;
ws.Cell(5, 4).Value = personnel.academic_service;
ws.Cell(5, 5).Value = personnel.nourish;
ws.Cell(5, 6).Value = personnel.plan_1;
ws.Cell(5, 7).Value = personnel.plan_2;
ws.Cell(5, 8).Value = personnel.plan_3;
ws.Cell(5, 9).Value = personnel.plan_4;
ws.Cell(5, 10).Value = personnel.plan_5;
ws.Cell(5, 11).Value = personnel.plan_6;
ws.Cell(5, 12).Value = personnel.plan_7;
ws.Cell(5, 13).Value = personnel.plan_8;
ws.Cell(5, 14).Value = personnel.plan_9;
ws.Cell(5, 15).Value = personnel.budget;
ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.integration_strategic_plan_details)
{
if (detail.topic_type == 1)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, row).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.plan_1;
ws.Cell(row, 7).Value = detail.plan_2;
ws.Cell(row, 8).Value = detail.plan_3;
ws.Cell(row, 9).Value = detail.plan_4;
ws.Cell(row, 10).Value = detail.plan_5;
ws.Cell(row, 11).Value = detail.plan_6;
ws.Cell(row, 12).Value = detail.plan_7;
ws.Cell(row, 13).Value = detail.plan_8;
ws.Cell(row, 14).Value = detail.plan_9;
ws.Cell(row, 15).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 2)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, row).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.plan_1;
ws.Cell(row, 7).Value = detail.plan_2;
ws.Cell(row, 8).Value = detail.plan_3;
ws.Cell(row, 9).Value = detail.plan_4;
ws.Cell(row, 10).Value = detail.plan_5;
ws.Cell(row, 11).Value = detail.plan_6;
ws.Cell(row, 12).Value = detail.plan_7;
ws.Cell(row, 13).Value = detail.plan_8;
ws.Cell(row, 14).Value = detail.plan_9;
ws.Cell(row, 15).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor =
XLColor.FromArgb(153, 204, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 3)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, row).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.plan_1;
ws.Cell(row, 7).Value = detail.plan_2;
ws.Cell(row, 8).Value = detail.plan_3;
ws.Cell(row, 9).Value = detail.plan_4;
ws.Cell(row, 10).Value = detail.plan_5;
ws.Cell(row, 11).Value = detail.plan_6;
ws.Cell(row, 12).Value = detail.plan_7;
ws.Cell(row, 13).Value = detail.plan_8;
ws.Cell(row, 14).Value = detail.plan_9;
ws.Cell(row, 15).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
//ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor = XLColor.FromArgb(153,204,255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 4)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, row).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.plan_1;
ws.Cell(row, 7).Value = detail.plan_2;
ws.Cell(row, 8).Value = detail.plan_3;
ws.Cell(row, 9).Value = detail.plan_4;
ws.Cell(row, 10).Value = detail.plan_5;
ws.Cell(row, 11).Value = detail.plan_6;
ws.Cell(row, 12).Value = detail.plan_7;
ws.Cell(row, 13).Value = detail.plan_8;
ws.Cell(row, 14).Value = detail.plan_9;
ws.Cell(row, 15).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor =
XLColor.FromArgb(255, 204, 153);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 5)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.science;
ws.Cell(row, 3).Value = detail.society;
ws.Cell(row, 4).Value = detail.academic_service;
ws.Cell(row, row).Value = detail.nourish;
ws.Cell(row, 6).Value = detail.plan_1;
ws.Cell(row, 7).Value = detail.plan_2;
ws.Cell(row, 8).Value = detail.plan_3;
ws.Cell(row, 9).Value = detail.plan_4;
ws.Cell(row, 10).Value = detail.plan_5;
ws.Cell(row, 11).Value = detail.plan_6;
ws.Cell(row, 12).Value = detail.plan_7;
ws.Cell(row, 13).Value = detail.plan_8;
ws.Cell(row, 14).Value = detail.plan_9;
ws.Cell(row, 15).Value = detail.budget;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor =
XLColor.FromArgb(255, 255, 204);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
}
}
using (var stream1 = new MemoryStream())
{
workbook.SaveAs(stream1);
var content = stream1.ToArray();
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"basic_plan_all_" + date + ".xlsx");
}
}
[SwaggerOperation("ตารางสรุปประเด็นยุทธศาสตร์ เป้าหมายหลัก ตัวชี้วัดและกลยุทธ์")]
[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();
}
[SwaggerOperation("ร.15 ประมาณการรายรับจากการจัดการศึกษา")]
[HttpPost, Route("reports/budget_expenditure_from_revenue/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetReport([FromRoute] string type,
[FromBody] budget_expenditure_from_revenue budget_expenditure_from_revenues)
{
// var topic2 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(i => i.topic_type == 2).ToList();
// var topic3 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(i => i.topic_type == 3).OrderBy(f=>f.couse_uid).ThenBy(m=>m.major_uid)
// .ThenBy(r=>r.row).ToList();
// var sum_1 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.current_students);
// var sum_2 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.students_reduced);
// var sum_3 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.students_estimates);
// var sum_4 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.price_regis_flat_payment);
// var sum_5 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.library_total);
// var sum_6 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.utilities_total);
// var sum_7 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.student_club_library_total);
// var sum_8 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.accident_insurance_total);
// var sum_9 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.academic_activities_total);
// var sum_10 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.examination_and_x_rays_total);
// var sum_11 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.tuition_fee_total);
// var sum_12 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
// .Where(h => h.topic_type == 2).Sum(j =>
// j.education_fee_less_fee_total);
if (budget_expenditure_from_revenues.budget_expenditure_from_revenue_details != null)
{
// var _sum1 = topic3.Sum(g => g.current_students);
// var _sum2 = topic3.Sum(j =>
// j.students_reduced);
// var _sum3 = topic3.Sum(j =>
// j.students_estimates);
// var _sum4 = topic3.Sum(j =>
// j.price_regis_flat_payment);
// var _sum5 = topic3.Sum(j =>
// j.library_total);
// var _sum6 = topic3.Sum(j =>
// j.utilities_total);
// var _sum7 = topic3.Sum(j =>
// j.student_club_library_total);
// var _sum8 = topic3.Sum(j =>
// j.accident_insurance_total);
// var _sum9 = topic3.Sum(j =>
// j.academic_activities_total);
// var _sum10 = topic3.Sum(j =>
// j.examination_and_x_rays_total);
// var _sum11 = topic3.Sum(j =>
// j.tuition_fee_total);
// var _sum12 = topic3.Sum(j =>
// j.education_fee_less_fee_total);
foreach (var detail in budget_expenditure_from_revenues.budget_expenditure_from_revenue_details)
{
if (detail.topic_type == 1)
{
detail.topic_1 = detail.topic;
detail.topic_2 = null;
var sum1 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.current_students);
budget_expenditure_from_revenues.sum_1 = sum1;
var sum2 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.students_reduced);
budget_expenditure_from_revenues.sum_2 = sum2;
var sum3 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.students_estimates);
budget_expenditure_from_revenues.sum_3 = sum3;
var sum4 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.price_regis_flat_payment);
budget_expenditure_from_revenues.sum_4 = sum4;
var sum5 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.library_total);
budget_expenditure_from_revenues.sum_5 = sum5;
var sum6 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.utilities_total);
budget_expenditure_from_revenues.sum_6 = sum6;
var sum7 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.student_club_library_total);
budget_expenditure_from_revenues.sum_7 = sum7;
var sum8 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.accident_insurance_total);
budget_expenditure_from_revenues.sum_8 = sum8;
var sum9 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.academic_activities_total);
budget_expenditure_from_revenues.sum_9 = sum9;
var sum10 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.examination_and_x_rays_total);
budget_expenditure_from_revenues.sum_10 = sum10;
var sum11 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.tuition_fee_total);
budget_expenditure_from_revenues.sum_11 = sum11;
var sum12 = budget_expenditure_from_revenues.budget_expenditure_from_revenue_details
.Where(h => h.topic_type == 1).Sum(j =>
j.education_fee_less_fee_total);
budget_expenditure_from_revenues.sum_12 = sum12;
// detail.current_students = topic3.Sum(d=>d.current_students);
//
// detail.students_reduced = topic3.Sum(d=>d.students_reduced);
//
// detail.students_estimates = topic3.Sum(d=>d.students_estimates);
//
// detail.price_regis_flat_payment = topic3.Sum(d=>d.price_regis_flat_payment);
//
// detail.library_total = topic3.Sum(d=>d.library_total);
//
// detail.utilities_total =topic3.Sum(d=>d.utilities_total);
//
// detail.student_club_library_total = topic3.Sum(d=>d.student_club_library_total);
//
// detail.accident_insurance_total = topic3.Sum(d=>d.accident_insurance_total);
//
// detail.academic_activities_total = topic3.Sum(d=>d.academic_activities_total);
//
// detail.examination_and_x_rays_total = topic3.Sum(d=>d.examination_and_x_rays_total);
//
// detail.tuition_fee_total = topic3.Sum(d=>d.tuition_fee_total);
//
// detail.education_fee_less_fee_total = topic3.Sum(d=>d.education_fee_less_fee_total);
}
if (detail.topic_type == 2)
{
detail.topic_1 = detail.topic;
detail.topic_2 = null;
// detail.current_students = topic2.Sum(d=>d.current_students);
//
// detail.students_reduced = topic2.Sum(d=>d.students_reduced);
//
// detail.students_estimates = topic2.Sum(d=>d.students_estimates);
//
// detail.price_regis_flat_payment = topic2.Sum(d=>d.price_regis_flat_payment);
//
// detail.library_total = topic2.Sum(d=>d.library_total);
//
// detail.utilities_total =topic2.Sum(d=>d.utilities_total);
//
// detail.student_club_library_total = topic2.Sum(d=>d.student_club_library_total);
//
// detail.accident_insurance_total = topic2.Sum(d=>d.accident_insurance_total);
//
// detail.academic_activities_total = topic2.Sum(d=>d.academic_activities_total);
//
// detail.examination_and_x_rays_total = topic2.Sum(d=>d.examination_and_x_rays_total);
//
// detail.tuition_fee_total = topic2.Sum(d=>d.tuition_fee_total);
//
// detail.education_fee_less_fee_total = topic2.Sum(d=>d.education_fee_less_fee_total);
}
if (detail.topic_type == 3)
{
detail.topic_2 = detail.topic;
detail.topic_1 = null;
}
}
}
var _summarys = new List<budget_expenditure_from_revenue>() { budget_expenditure_from_revenues };
Report report = new Report();
report.Load(_setting.report_path + "budget_expenditure_from_revenue.frx");
report.RegisterData(_summarys, "budget_expenditure_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",
date + ".xlsx");
break;
}
return Ok();
}
[SwaggerOperation("สรุปรายรับและจัดสรรตามเกณฑ์")]
[HttpPost, Route("reports/revenue_estimates/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetRevenueEstimatesReport([FromRoute] string type,
[FromBody] revenue_estimates revenue_estimate)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("สรุปรายรับและจัดสรรตามเกณฑ์");
ws.Range("A1:S1").Merge().Value = "งบประมาณรายจ่ายจากเงินรายได้ ประจำปีงบประมาณ พ.ศ. " +
revenue_estimate.academic_year_name_th;
ws.Range("A1:S1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A1:S1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A1:S1").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A1:S1").Style.Font.SetBold().Font.FontSize = 16;
ws.Range("A2:S2").Merge().Value = "( " + revenue_estimate.start_and_end_date_report + " )";
ws.Range("A2:S2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A2:S2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A2:S2").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A2:S2").Style.Font.SetBold().Font.FontSize = 16;
ws.Range("A3:S3").Merge().Value = "สรุปประมาณการรายรับ และการจัดสรรตามเกณฑ์รายจ่าย การจัดการศึกษาระดับ" +
revenue_estimate.education_level;
ws.Range("A3:S3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:S3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:S3").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A3:S3").Style.Font.SetBold().Font.FontSize = 16;
ws.Range("A4:S4").Merge().Value = "คณะ/วิทยาลัย " + revenue_estimate.faculty_name_th + " " + "พื้นที่ " +
revenue_estimate.agency_name_th;
ws.Range("A4:S4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A4:S4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A4:S4").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A4:S4").Style.Font.SetBold().Font.FontSize = 16;
ws.Column(1).Width = 30;
ws.Column(2).Width = 15;
ws.Column(3).Width = 15;
ws.Column(4).Width = 15;
ws.Column(5).Width = 15;
ws.Column(6).Width = 15;
ws.Column(7).Width = 15;
ws.Column(8).Width = 15;
ws.Column(9).Width = 15;
ws.Column(10).Width = 15;
ws.Column(11).Width = 15;
ws.Column(12).Width = 15;
ws.Column(13).Width = 15;
ws.Column(14).Width = 15;
ws.Column(15).Width = 15;
ws.Column(16).Width = 15;
ws.Column(17).Width = 15;
ws.Column(18).Width = 15;
ws.Column(19).Width = 15;
ws.Row(5).Height = 30;
ws.Row(6).Height = 30;
int row = 7;
if (revenue_estimate != null)
{
ws.Range("A5:A6").Merge().Value = "ผลผลิต / ภาคการศึกษา / ภาคเรียน";
ws.Range("A5:A6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A5:A6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A5:A6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("A5:A6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("A5:A6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("A5:A6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B5:C6").Merge().Value = "ประมาณการรายรับ";
ws.Range("B5:C6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("B5:C6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("B5:C6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("B5:C6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("B5:C6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("B5:C6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("D5:E6").Merge().Value = "หัก ประมาณการรายรับคณะศิลปศาสตร์ ( ศึกษาทั่วไป )";
ws.Range("D5:E6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("D5:E6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("D5:E6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("D5:E6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("D5:E6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("D5:E6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("F5:G6").Merge().Value = "คงเหลือ ประมาณการรายรับก่อนหักรายได้สะสม และจัดสรรตามเกณฑ์";
ws.Range("F5:G6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("F5:G6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("F5:G6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("F5:G6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("F5:G6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("F5:G6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("H5:I6").Merge().Value = "หัก รายได้สะสม ร้อยละ 10";
ws.Range("H5:I6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("H5:I6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("H5:I6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("H5:I6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("H5:I6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("H5:I6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("J5:K6").Merge().Value = "คงเหลือ ประมาณการรายรับ ก่อนจัดสรรตามเกณฑ์";
ws.Range("J5:K6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("J5:K6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("J5:K6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("J5:K6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("J5:K6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("J5:K6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("L5:M6").Merge().Value = "สมทบค่าสาธารณูปโภคมหาวิทยาลัย ร้อยละ 5";
ws.Range("L5:M6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("L5:M6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("L5:M6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("L5:M6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("L5:M6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("L5:M6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("N5:O6").Merge().Value = "สมทบงบกลาง มหาวิทยาลัย ร้อยละ 15";
ws.Range("N5:O6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("N5:O6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("N5:O6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("N5:O6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("N5:O6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("N5:O6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("P5:Q6").Merge().Value = "สมทบรายจ่ายส่วนกลางมหาวิทยาลัย ร้อยละ 40/50/60";
ws.Range("P5:Q6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("P5:Q6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("P5:Q6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("P5:Q6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("P5:Q6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("P5:Q6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("R5:S6").Merge().Value = "กรอบวงเงินรายจ่ายของคณะ/วิทยาลัย ร้อยละ 40/50/60";
ws.Range("R5:S6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("R5:S6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("R5:S6").Style.Font.FontName = "TH SarabunPSK";
ws.Range("R5:S6").Style.Font.SetBold().Font.FontSize = 14;
ws.Range("R5:S6").Style.Fill.BackgroundColor = XLColor.FromArgb(248, 203, 173);
ws.Range("R5:S6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(5, 1), ws.Cell(6, 19)).Style.Alignment.WrapText = true;
int r1 = 1;
int r2 = 2;
var result = new List<revenue_estimates>();
var res = result.SelectMany(j => j.revenue_estimates_details).Where(t=>t.topic_type==2).ToList();
var sum1 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.revenue_estimates);
var sum2 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.less_revenue_estimates);
var sum3 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.balance_revenue_estimates);
var sum4 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.less_accumulated_income);
var sum5 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.balance_before_allocating_according);
var sum6 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.contribution_utility_bills);
var sum7 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.contribution_central_budget);
var sum8 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.contribution_central_expenditure);
var sum9 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.expenditure_limit);
var _sum1 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.revenue_estimates);
var _sum2 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.less_revenue_estimates);
var _sum3 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.balance_revenue_estimates);
var _sum4 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.less_accumulated_income);
var _sum5 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.balance_before_allocating_according);
var _sum6 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.contribution_utility_bills);
var _sum7 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.contribution_central_budget);
var _sum8 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.contribution_central_expenditure);
var _sum9 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.expenditure_limit);
foreach (var detail in revenue_estimate.revenue_estimates_details)
{
if (detail.topic_type == 1)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = _sum1;//detail.revenue_estimates;
ws.Cell(row, 3).Value = "บาท";
ws.Cell(row, 4).Value = _sum2;//detail.less_revenue_estimates;
ws.Cell(row, 5).Value = "บาท";
ws.Cell(row, 6).Value = _sum3;//detail.balance_revenue_estimates;
ws.Cell(row, 7).Value = "บาท";
ws.Cell(row, 8).Value = _sum4;//detail.less_accumulated_income;
ws.Cell(row, 9).Value = "บาท";
ws.Cell(row, 10).Value = _sum5;//detail.balance_before_allocating_according;
ws.Cell(row, 11).Value = "บาท";
ws.Cell(row, 12).Value = _sum6;//detail.contribution_utility_bills;
ws.Cell(row, 13).Value = "บาท";
ws.Cell(row, 14).Value = _sum7;//detail.contribution_central_budget;
ws.Cell(row, 15).Value = "บาท";
ws.Cell(row, 16).Value = _sum8;//detail.contribution_central_expenditure;
ws.Cell(row, 17).Value = "บาท";
ws.Cell(row, 18).Value = _sum9;//detail.expenditure_limit;
ws.Cell(row, 19).Value = "บาท";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor =
XLColor.FromArgb(252, 228, 214);
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 2)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = sum1;//detail.revenue_estimates;
ws.Cell(row, 3).Value = "บาท";
ws.Cell(row, 4).Value = sum2;//detail.less_revenue_estimates;
ws.Cell(row, 5).Value = "บาท";
ws.Cell(row, 6).Value = sum3;//detail.balance_revenue_estimates;
ws.Cell(row, 7).Value = "บาท";
ws.Cell(row, 8).Value = sum4;//detail.less_accumulated_income;
ws.Cell(row, 9).Value = "บาท";
ws.Cell(row, 10).Value = sum5;//detail.balance_before_allocating_according;
ws.Cell(row, 11).Value = "บาท";
ws.Cell(row, 12).Value = sum6;//detail.contribution_utility_bills;
ws.Cell(row, 13).Value = "บาท";
ws.Cell(row, 14).Value = sum7;//detail.contribution_central_budget;
ws.Cell(row, 15).Value = "บาท";
ws.Cell(row, 16).Value = sum8;//detail.contribution_central_expenditure;
ws.Cell(row, 17).Value = "บาท";
ws.Cell(row, 18).Value = sum9;//detail.expenditure_limit;
ws.Cell(row, 19).Value = "บาท";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 14;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
//ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(252, 228, 214);
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
}
if (detail.topic_type == 3)
{
ws.Cell(row, 1).Value = detail.topic;
ws.Cell(row, 2).Value = detail.revenue_estimates;
ws.Cell(row, 3).Value = "บาท";
ws.Cell(row, 4).Value = detail.less_revenue_estimates;
ws.Cell(row, 5).Value = "บาท";
ws.Cell(row, 6).Value = detail.balance_revenue_estimates;
ws.Cell(row, 7).Value = "บาท";
ws.Cell(row, 8).Value = detail.less_accumulated_income;
ws.Cell(row, 9).Value = "บาท";
ws.Cell(row, 10).Value = detail.balance_before_allocating_according;
ws.Cell(row, 11).Value = "บาท";
ws.Cell(row, 12).Value = detail.contribution_utility_bills;
ws.Cell(row, 13).Value = "บาท";
ws.Cell(row, 14).Value = detail.contribution_central_budget;
ws.Cell(row, 15).Value = "บาท";
ws.Cell(row, 16).Value = detail.contribution_central_expenditure;
ws.Cell(row, 17).Value = "บาท";
ws.Cell(row, 18).Value = detail.expenditure_limit;
ws.Cell(row, 19).Value = "บาท";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName =
"TH SarabunPSK";
//ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Font.FontSize = 14;
ws.Cell(row, 3).Style.Font.FontSize = 14;
ws.Cell(row, 4).Style.Font.FontSize = 14;
ws.Cell(row, 5).Style.Font.FontSize = 14;
ws.Cell(row, 6).Style.Font.FontSize = 14;
ws.Cell(row, 7).Style.Font.FontSize = 14;
ws.Cell(row, 8).Style.Font.FontSize = 14;
ws.Cell(row, 9).Style.Font.FontSize = 14;
ws.Cell(row, 10).Style.Font.FontSize = 14;
ws.Cell(row, 11).Style.Font.FontSize = 14;
ws.Cell(row, 12).Style.Font.FontSize = 14;
ws.Cell(row, 13).Style.Font.FontSize = 14;
ws.Cell(row, 14).Style.Font.FontSize = 14;
ws.Cell(row, 15).Style.Font.FontSize = 14;
ws.Cell(row, 16).Style.Font.FontSize = 14;
ws.Cell(row, 17).Style.Font.FontSize = 14;
ws.Cell(row, 18).Style.Font.FontSize = 14;
ws.Cell(row, 19).Style.Font.FontSize = 14;
row++;
}
if (detail.topic_type == 4)
{
ws.Cell(row, 1).Value = "รวม";
ws.Cell(row, 2).Value = _sum1;//detail.revenue_estimates;
ws.Cell(row, 3).Value = "บาท";
ws.Cell(row, 4).Value = _sum2;//detail.less_revenue_estimates;
ws.Cell(row, 5).Value = "บาท";
ws.Cell(row, 6).Value = _sum3;//detail.balance_revenue_estimates;
ws.Cell(row, 7).Value = "บาท";
ws.Cell(row, 8).Value = _sum4;//detail.less_accumulated_income;
ws.Cell(row, 9).Value = "บาท";
ws.Cell(row, 10).Value = _sum5;//detail.balance_before_allocating_according;
ws.Cell(row, 11).Value = "บาท";
ws.Cell(row, 12).Value = _sum6;//detail.contribution_utility_bills;
ws.Cell(row, 13).Value = "บาท";
ws.Cell(row, 14).Value = _sum7;//detail.contribution_central_budget;
ws.Cell(row, 15).Value = "บาท";
ws.Cell(row, 16).Value = _sum8;//detail.contribution_central_expenditure;
ws.Cell(row, 17).Value = "บาท";
ws.Cell(row, 18).Value = _sum9;//detail.expenditure_limit;
ws.Cell(row, 19).Value = "บาท";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor =
XLColor.FromArgb(252, 228, 214);
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
row++;
//}
}
if (detail.is_footer == true)
{
ws.Cell(row, 14).Value = "ลงชื่อ";
ws.Cell(row, 15).Value = revenue_estimate.author_name;
ws.Cell(row, 17).Value = "ผู้จัดทำ";
ws.Cell(row + r1, 14).Value = "ตำแหน่ง";
ws.Cell(row + r1, 15).Value = revenue_estimate.position_name;
ws.Cell(row + r2, 14).Value = "เบอร์โทรติดต่อ";
ws.Cell(row + r2, 15).Value = "'" + revenue_estimate.phone;
ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Font.SetBold().Font.FontSize = 14;
// ws.Range(ws.Cell(row, 15), ws.Cell(row, 16)).Style.Border.BottomBorder = XLBorderStyleValues.Dotted;
// ws.Range(ws.Cell(row+1, 15), ws.Cell(row, 16)).Style.Border.BottomBorder = XLBorderStyleValues.Dotted;
ws.Cell(row, 14).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
ws.Cell(row + 1, 14).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
ws.Cell(row + 2, 14).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Right;
ws.Cell(row + 1, 14).Style.Font.FontName =
"TH SarabunPSK";
ws.Cell(row + 2, 14).Style.Font.FontName =
"TH SarabunPSK";
ws.Cell(row + 1, 14).Style.Font.SetBold().Font.FontSize = 14;
ws.Cell(row + 2, 14).Style.Font.SetBold().Font.FontSize = 14;
ws.Range(ws.Cell(row, 15), ws.Cell(row, 16)).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row + 1, 15), ws.Cell(row, 16)).Style.Font.FontName =
"TH SarabunPSK";
ws.Cell(row + 2, 15).Style.Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 15), ws.Cell(row, 16)).Style.Font.SetBold().Font.FontSize = 14;
ws.Range(ws.Cell(row + 1, 15), ws.Cell(row, 16)).Style.Font.SetBold().Font.FontSize = 14;
ws.Cell(row + 2, 15).Style.Font.SetBold().Font.FontSize = 14;
ws.Range(ws.Cell(row, 15), ws.Cell(row, 16)).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row + 1, 15), ws.Cell(row, 16)).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Center;
ws.Cell(row + 2, 15).Style.Alignment.Horizontal =
XLAlignmentHorizontalValues.Center;
// ws.Cell(row+3, 15).Style.Font.FontName =
// "TH SarabunPSK";
// ws.Cell(row+3, 15).Style.Font.SetBold().Font.FontSize = 14;
// ws.Cell(row+3, 15).Style.Alignment.Horizontal =
// XLAlignmentHorizontalValues.Center;
row++;
row += r1;
row += r2;
}
}
}
using (var stream1 = new MemoryStream())
{
workbook.SaveAs(stream1);
var content = stream1.ToArray();
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"revenue_estimates_" + date + ".xlsx");
}
}
[SwaggerOperation("ตารางสรุปงบประมาณประจำปี แยกตามผลผลิตของมหาวิทยาลัย")]
[HttpPost, Route("reports/summary_budget_university/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumBudgetUniReport([FromRoute] string type,
[FromBody] summary_budget_university summary)
{
var summaryBudget = new List<summary_budget_university>() { summary };
Report report = new Report();
report.Load(_setting.report_path + "summary_budget_university.frx");
report.RegisterData(summaryBudget, "summary_budget_university");
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",
"summary_budget_university_" + date + ".xlsx");
}
return Ok();
}
[SwaggerOperation("แบบฟอร์มสรุปรายจ่าย v1")]
[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)
{
int no = 1;
var b = budget.budgets.ToArray();
foreach (var bb in b)
{
bb.personnel_list_s = new List<personnel_list> { bb.personnel_lists };
foreach (var detail in bb.personnel_list_s)
{
foreach (var detail2 in detail.budget_personnel_lists)
{
if (detail2.rate != null)
{
detail2.text1 = "อัตรา";
}
var cperson = detail.budget_personnel_lists.Count();
if (cperson == 1)
{
detail.budget_personnel_lists[0].topic = "งบบุคลากร";
}
foreach (var detail3 in detail2.budget_personnel_lists_2)
{
if (detail3.rate != null)
{
detail3.text1 = "อัตรา";
}
int no2 = 1;
if (detail3.topic != null)
{
detail3.row_no = no;
no++;
}
foreach (var detail4 in detail3.budget_rates)
{
if (detail4.rate != null)
{
detail4.text1 = "อัตรา";
}
int no3 = 1;
if (detail4.topic != null)
{
detail4.row_no = no2;
no2++;
}
foreach (var detail5 in detail4.details)
{
int no4 = 1;
if (detail5.rate != null)
{
detail5.text1 = "อัตรา";
}
if (detail5.position_level != null)
{
detail5.row_no = no3;
no3++;
}
if (detail5.details2 != null)
{
foreach (var detail6 in detail5.details2)
{
if (detail6.topic != null)
{
detail6.row_no = no4;
no4++;
detail6.text1 = "บาท";
}
}
}
if (detail5.details2.Any())
{
if (detail5.details2==null)
{
foreach (var detail6 in detail5.details2)
{
detail6.topic = null;
detail6.total = null;
detail6.row_no = null;
detail6.text1 = null;
}
}
}
else
{
detail5.details2.Add(new details2()
{
topic = "", total = 999999999
});
}
}
}
}
if (cperson == 2)
{
detail.budget_personnel_lists[0].topic = "งบบุคลากร";
detail.budget_personnel_lists[1].topic = "งบดําเนินงาน";
detail.budget_personnel_lists[1].text1 = null;
detail.budget_personnel_lists[1].budget_personnel_lists_2[0].text1 = null;
detail.budget_personnel_lists[1].budget_personnel_lists_2[0].row_no = null;
detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0]
.row_no = null;
detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0]
.text1 = null;
detail.budget_personnel_lists[1].budget_personnel_lists_2[0].budget_rates[0]
.details[0].text1 = null;
}
}
}
}
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();
}
[SwaggerOperation("แบบฟอร์มสรุปรายจ่าย v2")]
[HttpPost, Route("reports/budget_expenditure_report_from_revenue_v2/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetExpenditureRevenueReport([FromRoute] string type,
[FromBody] budget_expenditure_report_from_revenue_v2 budget)
{
int no1 = 1;
int no2 = 0;
int no3 = 0;
int no4 = 0;
int no5 = 1;
int no6 = 0;
int no7 = 1;
int no8 = 0;
int no9 = 0;
int no10 = 0;
bool numberingtype10 = false;
bool numberingtype13 = false;
bool startNumbering = false;
bool startNumbering2 = false;
bool startNumbering3 = false;
bool startNumbering4 = false;
bool startNumbering5 = false;
foreach (var indetail in budget.details)
{
if (indetail.topic_type==1)
{
indetail.topic1 = indetail.topic;
indetail.amount1 = indetail.value1;
indetail.text1 = "บาท";
}
if (indetail.topic_type==2)
{
indetail.topic2 = indetail.topic;
indetail.amount2 = indetail.value2;
indetail.text2 = "บาท";
}
if (indetail.topic_type==3)
{
indetail.topic3 = indetail.topic;
indetail.amount3 = indetail.value1;
indetail.amount4 = indetail.value2;
indetail.text3 = "อัตรา";
indetail.text4 = "บาท";
}
if (indetail.topic_type==4)
{
indetail.topic4 = indetail.topic;
indetail.amount5 = indetail.value1;
indetail.amount6 = indetail.value2;
indetail.text5 = "อัตรา";
indetail.text6 = "บาท";
indetail.row_no1 = no1;
no1++;
startNumbering = true;
no2 = 1;
}
if (startNumbering && indetail.topic_type==5)
{
indetail.topic5 = indetail.topic;
indetail.amount7 = indetail.value1;
indetail.amount8 = indetail.value2;
indetail.text7 = "อัตรา";
indetail.text8 = "บาท";
indetail.row_no2 = no2;
no2++;
startNumbering2 = true;
no3 = 1;
}
if (startNumbering2 &&indetail.topic_type==6)
{
indetail.topic9 = indetail.topic;
indetail.topic10 = indetail.qualification;
indetail.amount9 = indetail.value1;
indetail.amount10 = indetail.value2;
indetail.text9 = "อัตรา";
indetail.text10 = "บาท";
indetail.row_no3 = no3;
no3++;
}
if (indetail.topic_type==8)
{
indetail.topic12 = indetail.topic;
indetail.amount12 = indetail.value1;
indetail.text12 = "บาท";
indetail.row_no5 = no5;
no5++;
}
if (indetail.topic_type==9)
{
indetail.text13 = "รายการ";
indetail.text14 = "จำนวน";
indetail.text15 = "หน่วยนับ";
indetail.text16 = "ราคาต่อหน่วย";
indetail.text17 = "รวมเงิน";
numberingtype10 = true;
no6 = 1;
}
if (numberingtype10&&indetail.topic_type==10)//
{
indetail.topic13 = indetail.topic;
indetail.amount13 = indetail.value1;
indetail.amount14 = indetail.value2;
indetail.amount15 = indetail.value3;
indetail.text18 = "บาท";
indetail.text19 = ".";
indetail.row_no6 = no6;
no6++;
}
if (indetail.topic_type==11)
{
indetail.topic14 = indetail.topic;
indetail.amount16 = indetail.value2;
indetail.text20 = "บาท";
numberingtype13 = true;
no10 = 1;
}
if (indetail.topic_type==12)
{
indetail.topic15 = indetail.topic;
indetail.amount17 = indetail.value1;
indetail.text21 = "บาท";
indetail.text22 = ".";
indetail.row_no7 = no7;
no7++;
}
if (indetail.topic_type==13)//
{
indetail.topic16 = indetail.topic;
indetail.amount18 = indetail.value2;
indetail.text23 = "บาท";
startNumbering3 = true;
no8 = 1;
}
//if (numberingtype13&&indetail.topic_type==13&&indetail.topic=="เงินอุดหนุน ค่าใช้จ่ายโครงการ"||indetail.topic=="ค่าครุภัณฑ์"||indetail.topic=="ค่าที่ดินและสิ่งก่อสร้าง")
if (numberingtype13&&indetail.topic_type==13&&indetail.topic!="ค่าตอบแทน ค่าใช้สอยและค่าวัสดุ"&&indetail.topic!="ค่าใช้จ่ายดำเนินงาน")
{
indetail.row_no10 = no10;
no10++;
}
if (startNumbering3&&indetail.topic_type==14)//
{
indetail.topic17 = indetail.topic;
indetail.amount19 = indetail.value2;
indetail.text24 = "บาท";
indetail.row_no8 = no8;
no8++;
startNumbering4 = true;
no4 = 1;
}
if (startNumbering4 &&indetail.topic_type==7&&indetail.is_other==null)//
{
indetail.topic11 = indetail.topic;
indetail.amount11 = indetail.value1;
indetail.text11 = "บาท";
indetail.row_no4 = no4;
no4++;
startNumbering5 = true;
no9 = 1;
}
if (startNumbering5&&indetail.topic_type==7&&indetail.is_other==true)
{
indetail.topic18 = indetail.topic;
indetail.amount20 = indetail.value1;
indetail.text25 = "บาท";
indetail.text26 = ".";
indetail.row_no9 = no9;
no9++;
}
}
int academic_year_name_th = Convert.ToInt32(budget.academic_year_name_th);
budget.academic_year_1 = (academic_year_name_th-1).ToString();
budget.academic_year_2 = academic_year_name_th.ToString();
var sum1 = budget.details.Where(f=>f.topic_type==1).Sum(d => d.value1);
var sum2 = budget.details.Where(f=>f.topic_type==2&&f.topic == "รายการบุคลากร").Sum(d => d.value2);
budget.total = sum1+sum2;
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)
{
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");
}
return Ok();
}
[SwaggerOperation("สรุปงบประมาณแผนปฏิบัติราชการประจำปี")]
[HttpPost, Route("reports/summary_government_budget_plan/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetSumGovernmentPlanReport([FromRoute] string type,
[FromBody] summary_government_budget_plan government_budget)
{
var budget1 = government_budget.data.Sum(h => h.personnel_government_budget);
var budget2 = government_budget.data.Sum(h => h.personnel_income_budget);
var budget3 = budget1 + budget2;
var budget4 = government_budget.data.Sum(h => h.operating_government_budget);
var budget5 = government_budget.data.Sum(h => h.operating_income_budget);
var budget6 = budget4 + budget5;
var budget7 = government_budget.data.Sum(h => h.investment_government_budget);
var budget8 = government_budget.data.Sum(h => h.investment_income_budget);
var budget9 = budget7 + budget8;
var budget10 = government_budget.data.Sum(h => h.subsidy_government_budget);
var budget11 = government_budget.data.Sum(h => h.subsidy_income_budget);
var budget12 = budget10 + budget11;
var budget13 = government_budget.data.Sum(h => h.expenses_government_budget);
var budget14 = government_budget.data.Sum(h => h.expenses_income_budget);
var budget15 = budget13 + budget14;
var budget16 = budget1 + budget4 + budget7 + budget10 + budget13;
var budget17 = budget2 + budget5 + budget8 + budget11 + budget14;
var budget18 = budget16 + budget17;
int row = 1;
//int datarow = 1;
foreach (var datas in government_budget.data)
{
datas.total_personnel_income_budget = datas.personnel_government_budget + datas.personnel_income_budget;
datas.total_operating_income_budget = datas.operating_government_budget + datas.operating_income_budget;
datas.total_investment_income_budget =
datas.investment_government_budget + datas.investment_income_budget;
datas.total_subsidy_income_budget = datas.subsidy_government_budget + datas.subsidy_income_budget;
datas.total_expenses_income_budget = datas.expenses_government_budget + datas.expenses_income_budget;
datas.government_budget = datas.personnel_government_budget + datas.operating_government_budget +
datas.investment_government_budget +
datas.subsidy_government_budget + datas.expenses_government_budget;
datas.government_income_budget =
datas.personnel_income_budget + datas.operating_income_budget + datas.investment_income_budget +
datas.subsidy_income_budget + datas.expenses_income_budget;
datas.total_government_income_budget = datas.government_budget + datas.government_income_budget;
government_budget.budget_1 = budget1;
government_budget.budget_2 = budget2;
government_budget.budget_3 = budget3;
government_budget.budget_4 = budget4;
government_budget.budget_5 = budget5;
government_budget.budget_6 = budget6;
government_budget.budget_7 = budget7;
government_budget.budget_8 = budget8;
government_budget.budget_9 = budget9;
government_budget.budget_10 = budget10;
government_budget.budget_11 = budget11;
government_budget.budget_12 = budget12;
government_budget.budget_13 = budget13;
government_budget.budget_14 = budget14;
government_budget.budget_15 = budget15;
government_budget.budget_16 = budget16;
government_budget.budget_17 = budget17;
government_budget.budget_18 = budget18;
// if (datas.topic_type == 2)
// {
// datas.row_no = datarow.ToString();
// datarow++;
// }
}
foreach (var notation in government_budget.notations)
{
string bath = " บาท";
int subrow = 1;
notation.row_no = row.ToString();
if (notation.row_no == "1")
{
notation.row_no = "หมายเหตุ : " + "1";
}
if (notation.amount != null)
{
notation.amounts = bath;
}
if (notation.amount == null)
{
notation.amounts = null;
}
foreach (var notation2 in notation.notations_detail)
{
if (notation2.list != null && notation2.amount != null)
{
notation2.sub_row_no = row + "." + subrow;
subrow++;
notation2.free_text = "บาท";
}
if (notation2.list == null || notation2.list == "")
{
notation2.sub_row_no = null;
notation2.free_text = null;
}
}
row++;
}
var governmentbudget = new List<summary_government_budget_plan>() { government_budget };
Report report = new Report();
report.Load(_setting.report_path + "summary_government_budget_plan.frx");
report.RegisterData(governmentbudget, "summary_government_budget_plan");
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 "doc":
Word2007Export word = new Word2007Export();
report.Export(word, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "appllication/vnd.ms-word");
case "docx":
Word2007Export word1 = new Word2007Export();
report.Export(word1, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "appllication/vnd.ms-word");
case "xlsx":
Excel2007Export excel = new Excel2007Export();
report.Export(excel, stream);
stream.Seek(0, SeekOrigin.Begin);
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"summary_government_budget_plan" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("แผนงาน/ผลผลิตของมหาวิทยาลัยฯ")]
[HttpPost, Route("reports/budget_projects/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetProjectsReport([FromRoute] string type,
[FromBody] budget_projects budget)
{
var budgets = new List<budget_projects>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "budget_projects.frx");
report.RegisterData(budgets, "budget_projects");
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);
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
stream,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"budget_project_" + date + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ข้อมูลงบประมาณเงินแผ่นดิน งบประมาณเงินรายได้")]
[HttpPost, Route("reports/total_budget/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetTotalReport([FromRoute] string type,
[FromBody] total_budget budget)
{
var summaryBudget = new List<total_budget>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "total_budget.frx");
report.RegisterData(summaryBudget, "total_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");
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",
"total_budget_" + date + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ร.6 สรุปโครงการงบดำเนินงาน")]
[HttpPost, Route("reports/summary_subsidy_projects/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetSubsidySummaryReport([FromRoute] string type,
[FromBody] summary_subsidy_projects budget)
{
int row = 1;
string myStr = budget.budget_project_name_th;
string[] projectname = myStr.Split("ผลผลิต ");
foreach (string projectnames in projectname)
{
budget.budget_project_name_th2 = projectnames;
}
foreach (var detail in budget.data)
{
if (detail.topic_type == 3)
{
detail.row_no = row;
row++;
}
else
{
detail.row_no = null;
}
}
var summaryBudget = new List<summary_subsidy_projects>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "summary_subsidy_projects.frx");
report.RegisterData(summaryBudget, "summary_subsidy_projects");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"project_summary_subsidy" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ตารางเป้าหมายผลผลิต")]
[HttpPost, Route("reports/target_budget_project/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetTargetBudgetReport([FromRoute] string type,
[FromBody] List<target_budget_project> targetBudgetProjectsbudget)
{
Report report = new Report();
report.Load(_setting.report_path + "target_budget_project.frx");
report.RegisterData(targetBudgetProjectsbudget, "target_budget_project");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"target_budget_project" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("แผนการรับนักศึกษา")]
[HttpPost, Route("reports/student_admission_plan/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetStdAdmissionReport([FromRoute] string type,
[FromBody] student_admission_plan studentAdmission)
{
if (studentAdmission.student_type_code == 1)
{
studentAdmission.student_type_name = "นักศึกษารับใหม่";
studentAdmission.text = "ภาคสมทบ";
}
if (studentAdmission.student_type_code == 2)
{
studentAdmission.student_type_name = "นักศึกษาทั้งหมด";
studentAdmission.text = "ภาคสมทบ/ภาคพิเศษ";
}
if (studentAdmission.student_type_code == 3)
{
studentAdmission.student_type_name = "นักศึกษาสำเร็จ";
studentAdmission.text = "ภาคสมทบ/ภาคพิเศษ";
}
foreach (var detail in studentAdmission.data)
{
if (detail.topic_type == 4)
{
detail.topic = "- " + detail.topic;
}
}
var studentAdmissionPlans = new List<student_admission_plan>() { studentAdmission };
Report report = new Report();
report.Load(_setting.report_path + "student_admission_plan.frx");
report.RegisterData(studentAdmissionPlans, "student_admission_plan");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"student_admission_plan" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("รายงานภาพรวมนักศึกษา")]
[HttpPost, Route("reports/student_overview/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetStdoverviewReport([FromRoute] string type,
[FromBody] student_overview studentOverview)
{
if (studentOverview.student_type_code == 1)
{
studentOverview.student_type_name = "นักศึกษาทั้งหมด";
}
if (studentOverview.student_type_code == 2)
{
studentOverview.student_type_name = "นักศึกษารับใหม่";
}
if (studentOverview.student_type_code == 3)
{
studentOverview.student_type_name = "นักศึกษาสำเร็จ";
}
if (studentOverview.student_type_code == 4)
{
studentOverview.student_type_name = "นักศึกษาปกติทั้งหมด";
}
if (studentOverview.student_type_code == 5)
{
studentOverview.student_type_name = "นักศึกษาปกติรับใหม่";
}
if (studentOverview.student_type_code == 6)
{
studentOverview.student_type_name = "นักศึกษาปกติสำเร็จ";
}
if (studentOverview.student_type_code == 7)
{
studentOverview.student_type_name = "นักศึกษาสมทบ/พิเศษทั้งหมด";
}
if (studentOverview.student_type_code == 8)
{
studentOverview.student_type_name = "นักศึกษาสมทบ/พิเศษรับใหม่";
}
if (studentOverview.student_type_code == 9)
{
studentOverview.student_type_name = "นักศึกษาสมทบ/พิเศษสำเร็จ";
}
var sum1 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_science_1);
var sum2 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_social_1);
var sum3 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_total_1);
var sum4 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_science_1);
var sum5 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_social_1);
var sum6 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_total_1);
var sum7 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_science_1);
var sum8 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_social_1);
var sum9 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_total_1);
var sum10 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_science_1);
var sum11 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_social_1);
var sum12 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_1);
var sum13 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_science_2);
var sum14 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_social_2);
var sum15 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_total_2);
var sum16 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_science_2);
var sum17 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_social_2);
var sum18 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_total_2);
var sum19 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_science_2);
var sum20 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_social_2);
var sum21 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_total_2);
var sum22 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_science_2);
var sum23 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_social_2);
var sum24 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_2);
var sum25 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_science_3);
var sum26 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_social_3);
var sum27 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_total_3);
var sum28 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_science_3);
var sum29 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_social_3);
var sum30 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_total_3);
var sum31 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_science_3);
var sum32 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_social_3);
var sum33 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_total_3);
var sum34 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_science_3);
var sum35 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_social_3);
var sum36 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_3);
var sum37 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_science_4);
var sum38 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_social_4);
var sum39 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_total_4);
var sum40 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_science_4);
var sum41 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_social_4);
var sum42 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_total_4);
var sum43 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_science_4);
var sum44 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_social_4);
var sum45 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_total_4);
var sum46 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_science_4);
var sum47 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_social_4);
var sum48 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_4);
var sum49 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_science_5);
var sum50 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_social_5);
var sum51 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_total_5);
var sum52 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_science_5);
var sum53 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_social_5);
var sum54 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_total_5);
var sum55 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_science_5);
var sum56 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_social_5);
var sum57 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_total_5);
var sum58 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_science_5);
var sum59 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_social_5);
var sum60 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_5);
var sum61 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_science_6);
var sum62 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_social_6);
var sum63 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ba_degree_total_6);
var sum64 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_science_6);
var sum65 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_social_6);
var sum66 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.ma_degree_total_6);
var sum67 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_science_6);
var sum68 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_social_6);
var sum69 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.doctor_degree_total_6);
var sum70 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_science_6);
var sum71 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_social_6);
var sum72 = studentOverview.data.Where(g => g.topic_type == 1).Sum(d => d.total_6);
studentOverview.ba_degree_science_1 = sum1;
studentOverview.ba_degree_social_1 = sum2;
studentOverview.ba_degree_total_1 = sum3;
studentOverview.ma_degree_science_1 = sum4;
studentOverview.ma_degree_social_1 = sum5;
studentOverview.ma_degree_total_1 = sum6;
studentOverview.doctor_degree_science_1 = sum7;
studentOverview.doctor_degree_social_1 = sum8;
studentOverview.doctor_degree_total_1 = sum9;
studentOverview.total_science_1 = sum10;
studentOverview.total_social_1 = sum11;
studentOverview.total_1 = sum12;
studentOverview.ba_degree_science_2 = sum13;
studentOverview.ba_degree_social_2 = sum14;
studentOverview.ba_degree_total_2 = sum15;
studentOverview.ma_degree_science_2 = sum16;
studentOverview.ma_degree_social_2 = sum17;
studentOverview.ma_degree_total_2 = sum18;
studentOverview.doctor_degree_science_2 = sum19;
studentOverview.doctor_degree_social_2 = sum20;
studentOverview.doctor_degree_total_2 = sum21;
studentOverview.total_science_2 = sum22;
studentOverview.total_social_2 = sum23;
studentOverview.total_2 = sum24;
studentOverview.ba_degree_science_3 = sum25;
studentOverview.ba_degree_social_3 = sum26;
studentOverview.ba_degree_total_3 = sum27;
studentOverview.ma_degree_science_3 = sum28;
studentOverview.ma_degree_social_3 = sum29;
studentOverview.ma_degree_total_3 = sum30;
studentOverview.doctor_degree_science_3 = sum31;
studentOverview.doctor_degree_social_3 = sum32;
studentOverview.doctor_degree_total_3 = sum33;
studentOverview.total_science_3 = sum34;
studentOverview.total_social_3 = sum35;
studentOverview.total_3 = sum36;
studentOverview.ba_degree_science_4 = sum37;
studentOverview.ba_degree_social_4 = sum38;
studentOverview.ba_degree_total_4 = sum39;
studentOverview.ma_degree_science_4 = sum40;
studentOverview.ma_degree_social_4 = sum41;
studentOverview.ma_degree_total_4 = sum42;
studentOverview.doctor_degree_science_4 = sum43;
studentOverview.doctor_degree_social_4 = sum44;
studentOverview.doctor_degree_total_4 = sum45;
studentOverview.total_science_4 = sum46;
studentOverview.total_social_4 = sum47;
studentOverview.total_4 = sum48;
studentOverview.ba_degree_science_5 = sum49;
studentOverview.ba_degree_social_5 = sum50;
studentOverview.ba_degree_total_5 = sum51;
studentOverview.ma_degree_science_5 = sum52;
studentOverview.ma_degree_social_5 = sum53;
studentOverview.ma_degree_total_5 = sum54;
studentOverview.doctor_degree_science_5 = sum55;
studentOverview.doctor_degree_social_5 = sum56;
studentOverview.doctor_degree_total_5 = sum57;
studentOverview.total_science_5 = sum58;
studentOverview.total_social_5 = sum59;
studentOverview.total_5 = sum60;
studentOverview.ba_degree_science_6 = sum61;
studentOverview.ba_degree_social_6 = sum62;
studentOverview.ba_degree_total_6 = sum63;
studentOverview.ma_degree_science_6 = sum64;
studentOverview.ma_degree_social_6 = sum65;
studentOverview.ma_degree_total_6 = sum66;
studentOverview.doctor_degree_science_6 = sum67;
studentOverview.doctor_degree_social_6 = sum68;
studentOverview.doctor_degree_total_6 = sum69;
studentOverview.total_science_6 = sum70;
studentOverview.total_social_6 = sum71;
studentOverview.total_6 = sum72;
var studentOverviews = new List<student_overview>() { studentOverview };
Report report = new Report();
report.Load(_setting.report_path + "student_overview.frx");
report.RegisterData(studentOverviews, "student_overview");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"student_overview" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("สรุปงบประมาณรายจ่าย")]
[HttpPost, Route("reports/summary_budget_expense/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetSummaryExpenseReport([FromRoute] string type,
[FromBody] summary_budget_expense budget)
{
var summaryBudget = new List<summary_budget_expense>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "summary_budget_expense.frx");
report.RegisterData(summaryBudget, "summary_budget_expense");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"summary_budget_expense" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("ประมาณการรายรับ รายจ่าย")]
[HttpPost, Route("reports/estimate_income_expenses/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetEstimateReport([FromRoute] string type,
[FromBody] estimate_income_expenses budget)
{
var summaryBudget = new List<estimate_income_expenses>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "estimate_income_expenses.frx");
report.RegisterData(summaryBudget, "estimate_income_expenses");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"estimate_income_expenses" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("สรุปรายรับ และการจัดสรร")]
[HttpPost, Route("reports/summary_income_allocation/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetAllocationReport([FromRoute] string type,
[FromBody] estimate_income_expenses budget)
{
var summaryBudget = new List<estimate_income_expenses>() { budget };
Report report = new Report();
report.Load(_setting.report_path + "summary_income_allocation.frx");
report.RegisterData(summaryBudget, "estimate_income_expenses");
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.openxmlformats-officedocument.spreadsheetml.sheet",
"summary_income_allocation" + ".xlsx");
}
return Ok();
}
[SwaggerOperation("รวมทุกแผน")]
[HttpPost, Route("reports/request_summary_all_plans/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetRequestSummaryAllReport([FromRoute] string type, [FromBody] request_summary requestSummary)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("Sheet1");
//ws.Columns("A").AdjustToContents();
ws.Column(1).Width = 45;
ws.Column(2).Width = 20;
ws.Column(3).Width = 20;
ws.Column(4).Width = 20;
ws.Column(5).Width = 20;
ws.Column(6).Width = 20;
ws.Column(8).Width = 20;
ws.Column(9).Width = 20;
ws.Column(10).Width = 20;
ws.Column(11).Width = 20;
ws.Column(12).Width = 20;
ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. "+requestSummary.budget_year+" (คำขอ)";
ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 10;
ws.Cell("A2").Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
ws.Cell("A2").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A2").Style.Font.FontSize = 10;
int col = 2;
int cols = 2;
int rowheads = 3;
int rowhead = 4;
int rowvalue = 5;
int row = 6;
int rowno = 1;
if (requestSummary != null)
{
var countbudgetplan = requestSummary.plans.Count;
if (countbudgetplan==1)
{
foreach (var i in requestSummary.plans)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
ws.Cell(4, 2).Value = i.budget_plan_name;
ws.Cell(5, 2).Value = i.value??0;
ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(4, 2).Style.Font.FontSize = 10;
ws.Cell(4, 2).Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A3").Style.Font.FontSize = 10;
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(3, 2).Style.Font.FontSize = 10;
ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(3, 2).Style.Alignment.WrapText = true;
ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(4, 2).Style.Font.FontSize = 10;
ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(5, 2).Style.Font.FontSize = 10;
ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(5, 2).Style.Alignment.WrapText = true;
}
foreach (var detail in requestSummary.data_1)
{
ws.Cell(row, 1).Value = detail.rowno + detail.list;
foreach (var budgetPlan in detail.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
foreach (var detail2 in detail.data_2)
{
if (detail2.color=="1" && detail2.is_bold==true)
{
ws.Cell(row, 1).Value = detail2.list;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
}
if (detail2.color=="2" && detail2.is_bold==null)
{
ws.Cell(row, 1).Value = detail2.list;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor =XLColor.FromArgb(255, 204, 153);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
}
if (detail2.color=="3" && detail2.is_bold==null)
{
ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
}
if (detail2.color==null && detail2.is_bold==null)
{
ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
}
foreach (var detail3 in detail2.data_3)
{
if (detail3.is_bold==true)
{
ws.Cell(row, 1).Value = detail3.rowno+detail3.list;
foreach (var budgetPlan in detail3.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
}
}
}
}
}
if (countbudgetplan>1)
{
foreach (var i in requestSummary.plans)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Merge().Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
ws.Cell(rowhead, col).Value = i.budget_plan_name;
ws.Cell(rowvalue, col).Value = i.value??0;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style
.Border
.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.WrapText = true;
ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(rowhead, col).Style.Font.FontSize = 10;
ws.Cell(rowhead, col).Style.Alignment.WrapText = true;
ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("A3").Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A3").Style.Font.FontSize = 10;
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(rowvalue, col).Style.Font.FontSize = 10;
ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(rowvalue, col).Style.Alignment.WrapText = true;
ws.Cell(rowheads, col).Style.Alignment.WrapText = true;
col++;
}
foreach (var detail in requestSummary.data_1)
{
int col2 = 2;
ws.Cell(row, 1).Value = detail.rowno + detail.list;
// int col2 = 2;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
foreach (var budgetPlan in detail.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255);
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, cols).Style.Alignment.WrapText = true;
col2++;
}
row++;
foreach (var detail2 in detail.data_2)
{
if (detail2.color=="1" && detail2.is_bold==true)//ฟ้า
{
ws.Cell(row, 1).Value = detail2.list;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
col2 = 2;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
// col2++;
row++;
}
if (detail2.color=="2" && detail2.is_bold==null)//ส้ม
{
ws.Cell(row, 1).Value = detail2.list;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor =XLColor.FromArgb(255, 204, 153);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
col2 = 2;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153);
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
//col2++;
row++;
}
if (detail2.color=="3" && detail2.is_bold==null)//เหลือง
{
ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText =true;
col2 = 2;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204);
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
// col2++;
row++;
}
if (detail2.color==null && detail2.is_bold==null)
{
ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontSize = 10;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
col2 = 2;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
//col2++;
row++;
}
foreach (var detail3 in detail2.data_3)
{
// if (detail3.is_bold==true)
// {
ws.Cell(row, 1).Value = detail3.rowno+detail3.list;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
col2 = 2;
foreach (var budgetPlan in detail3.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
// col2++;
row++;
//}
}
}
}
}
}
using (var stream = new MemoryStream())
{
workbook.SaveAs(stream);
var content = stream.ToArray();
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"all_plans" + ".xlsx");
}
}
// [SwaggerOperation("รวมทุกแผน")]
// [HttpPost, Route("reports/request_summary_all_plans/{type}")]
// [ApiExplorerSettings(GroupName = "reports")]
// public IActionResult GetRequestSummaryAllReport([FromRoute] string type, [FromBody] request_summary requestSummary)
// {
// var workbook = new XLWorkbook();
// var ws = workbook.Worksheets.Add("Sheet1");
// //ws.Columns("A").AdjustToContents();
// ws.Column(1).Width = 45;
// ws.Column(2).Width = 20;
// ws.Column(3).Width = 20;
// ws.Column(4).Width = 20;
// ws.Column(5).Width = 20;
// ws.Column(6).Width = 20;
// ws.Column(8).Width = 20;
// ws.Column(9).Width = 20;
// ws.Column(10).Width = 20;
// ws.Column(11).Width = 20;
// ws.Column(12).Width = 20;
//
//
// ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. "+requestSummary.budget_year+" (คำขอ)";
// ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell("A1").Style.Font.FontSize = 10;
// ws.Cell("A2").Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
// ws.Cell("A2").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell("A2").Style.Font.FontSize = 10;
//
// int col = 2;
// int cols = 2;
// int rowheads = 3;
// int rowhead = 4;
// int rowvalue = 5;
// int row = 6;
//
// int rowno = 1;
//
// if (requestSummary != null)
// {
// var countbudgetplan = requestSummary.plans.Count;
// if (countbudgetplan==1)
// {
// foreach (var i in requestSummary.plans)
// {
// ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
// ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
// ws.Cell(4, 2).Value = i.budget_plan_name;
// ws.Cell(5, 2).Value = i.value??0;
// ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin;
// ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(4, 2).Style.Font.FontSize = 10;
// ws.Cell(4, 2).Style.Alignment.WrapText = true;
// ws.Cell("A3").Style.Alignment.WrapText = true;
// ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell("A3").Style.Font.FontSize = 10;
// ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell(3, 2).Style.Font.FontSize = 10;
// ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(3, 2).Style.Alignment.WrapText = true;
// ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell(4, 2).Style.Font.FontSize = 10;
// ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
//
// ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell(5, 2).Style.Font.FontSize = 10;
// ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(5, 2).Style.Alignment.WrapText = true;
// }
//
// foreach (var detail in requestSummary.data_1)
// {
//
// ws.Cell(row, 1).Value = detail.rowno + detail.list;
// foreach (var budgetPlan in detail.plans)
// {
// ws.Cell(row, 2).Value = budgetPlan.value??0;
// }
//
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical =
// XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder =
// XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName =
// "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor =
// XLColor.FromArgb(204, 153, 255);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// row++;
//
// foreach (var detail2 in detail.data_2)
// {
// if (detail2.color=="1" && detail2.is_bold==true)
// {
// ws.Cell(row, 1).Value = detail2.list;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, 2).Value = budgetPlan.value??0;
// }
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// row++;
// }
// if (detail2.color=="2" && detail2.is_bold==null)
// {
// ws.Cell(row, 1).Value = detail2.list;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, 2).Value = budgetPlan.value??0;
// }
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor =XLColor.FromArgb(255, 204, 153);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// row++;
// }
// if (detail2.color=="3" && detail2.is_bold==null)
// {
// ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, 2).Value = budgetPlan.value??0;
// }
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// row++;
// }
// if (detail2.color==null && detail2.is_bold==null)
// {
// ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, 2).Value = budgetPlan.value??0;
// }
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// // ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// row++;
// }
// foreach (var detail3 in detail2.data_3)
// {
// if (detail3.is_bold==true)
// {
// ws.Cell(row, 1).Value = detail3.rowno+detail3.list;
// foreach (var budgetPlan in detail3.plans)
// {
// ws.Cell(row, 2).Value = budgetPlan.value??0;
// }
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// row++;
// }
//
// }
// }
//
// }
//
//
// }
//
// if (countbudgetplan>1)
// {
// foreach (var i in requestSummary.plans)
// {
//
// ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Merge().Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
// ws.Cell(rowhead, col).Value = i.budget_plan_name;
// ws.Cell(rowvalue, col).Value = i.value??0;
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style
// .Border
// .OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.WrapText = true;
//
// ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin;
// ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(rowhead, col).Style.Font.FontSize = 10;
// ws.Cell(rowhead, col).Style.Alignment.WrapText = true;
// ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell("A3").Style.Alignment.WrapText = true;
// ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell("A3").Style.Font.FontSize = 10;
// ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
// ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Cell(rowvalue, col).Style.Font.FontSize = 10;
// ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(rowvalue, col).Style.Alignment.WrapText = true;
// ws.Cell(rowheads, col).Style.Alignment.WrapText = true;
// col++;
// }
//
// foreach (var detail in requestSummary.data_1)
// {
// int col2 = 2;
// ws.Cell(row, 1).Value = detail.rowno + detail.list;
// // int col2 = 2;
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical =
// XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder =
// XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName =
// "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor =
// XLColor.FromArgb(204, 153, 255);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// ws.Cell(row, 2).Style.Alignment.WrapText = true;
// foreach (var budgetPlan in detail.plans)
// {
// ws.Cell(row, col2).Value = budgetPlan.value??0;
// ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255);
// ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
// ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, cols).Style.Alignment.WrapText = true;
//
// col2++;
// }
// row++;
//
// foreach (var detail2 in detail.data_2)
// {
// if (detail2.color=="1" && detail2.is_bold==true)
// {
// ws.Cell(row, 1).Value = detail2.list;
//
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
//
// col2 = 2;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, col2).Value = budgetPlan.value??0;
// ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255);
// ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
// ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, col2).Style.Alignment.WrapText = true;
// col2++;
// }
// // col2++;
// row++;
//
// }
// if (detail2.color=="2" && detail2.is_bold==null)
// {
// ws.Cell(row, 1).Value = detail2.list;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor =XLColor.FromArgb(255, 204, 153);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// col2 = 2;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, col2).Value = budgetPlan.value??0;
// ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153);
// ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(row, col2).Style.Font.FontSize = 10;
// ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, col2).Style.Alignment.WrapText = true;
// col2++;
//
// }
// //col2++;
// row++;
//
// }
// if (detail2.color=="3" && detail2.is_bold==null)
// {
// ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204);
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.WrapText =true;
// col2 = 2;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, col2).Value = budgetPlan.value??0;
// ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204);
// ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(row, col2).Style.Font.FontSize = 10;
// ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, col2).Style.Alignment.WrapText = true;
// col2++;
//
// }
// // col2++;
// row++;
//
// }
// if (detail2.color==null && detail2.is_bold==null)
// {
// ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
//
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// col2 = 2;
// foreach (var budgetPlan in detail2.plans)
// {
// ws.Cell(row, col2).Value = budgetPlan.value??0;
// ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(row, col2).Style.Font.FontSize = 10;
// ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, col2).Style.Alignment.WrapText = true;
// col2++;
//
// }
// //col2++;
// row++;
//
// }
// foreach (var detail3 in detail2.data_3)
// {
// if (detail3.is_bold==true)
// {
// ws.Cell(row, 1).Value = detail3.rowno+detail3.list;
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
// ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
// ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.WrapText = true;
// col2 = 2;
// foreach (var budgetPlan in detail3.plans)
// {
// ws.Cell(row, col2).Value = budgetPlan.value??0;
// ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
// ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
// ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
// ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
// ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
// ws.Cell(row, col2).Style.Alignment.WrapText = true;
// col2++;
// }
// // col2++;
// row++;
//
// }
//
// }
// }
//
// }
//
//
// }
// }
// using (var stream = new MemoryStream())
// {
// workbook.SaveAs(stream);
// var content = stream.ToArray();
// return File(
// content,
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
// "all_plans" + ".xlsx");
// }
// }
[SwaggerOperation("แผนบูรณาการแผนยุทธศาสตร์")]
[HttpPost, Route("reports/request_summary_integrated_strategic/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetRequestSummary2Report([FromRoute] string type, [FromBody] request_summary requestSummary)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("Sheet1");
//ws.Columns("A").AdjustToContents();
ws.Column(1).Width = 45;
ws.Column(2).Width = 20;
ws.Column(3).Width = 20;
ws.Column(4).Width = 20;
ws.Column(5).Width = 20;
ws.Column(6).Width = 20;
ws.Column(8).Width = 20;
ws.Column(9).Width = 20;
ws.Column(10).Width = 20;
ws.Column(11).Width = 20;
ws.Column(12).Width = 20;
ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. "+requestSummary.budget_year+" (คำขอ)";
ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 10;
ws.Cell("A2").Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
ws.Cell("A2").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A2").Style.Font.FontSize = 10;
int col = 2;
int cols = 2;
int rowheads = 3;
int rowhead = 4;
int rowvalue = 5;
int row = 6;
int rowno = 1;
if (requestSummary != null)
{
var countbudgetplan = requestSummary.plans.Count;
if (countbudgetplan==1)
{
foreach (var i in requestSummary.plans)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
ws.Cell(4, 2).Value = i.budget_plan_name;
ws.Cell(5, 2).Value = i.value??0;
ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(4, 2).Style.Font.FontSize = 10;
ws.Cell(4, 2).Style.Alignment.WrapText = true;
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("A3").Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A3").Style.Font.FontSize = 10;
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(3, 2).Style.Font.FontSize = 10;
ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(3, 2).Style.Alignment.WrapText = true;
ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(4, 2).Style.Font.FontSize = 10;
ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(5, 2).Style.Font.FontSize = 10;
ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(5, 2).Style.Alignment.WrapText = true;
}
foreach (var detail in requestSummary.data_1)
{
ws.Cell(row, 1).Value = detail.rowno + detail.list;
foreach (var budgetPlan in detail.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
foreach (var detail2 in detail.data_2)
{
ws.Cell(row, 1).Value = detail2.rowno + detail2.list;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
foreach (var detail3 in detail2.data_3)
{
ws.Cell(row, 1).Value = detail3.rowno+detail3.list;
foreach (var budgetPlan in detail3.plans)
{
ws.Cell(row, 2).Value = budgetPlan.value??0;
}
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 2).Style.Alignment.WrapText = true;
row++;
}
}
}
}
if (countbudgetplan>1)
{
foreach (var i in requestSummary.plans)
{
ws.Range("A3:A5").Merge().Value = "งบรายจ่าย";
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Merge().Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)";
ws.Cell(rowhead, col).Value = i.budget_plan_name;
ws.Cell(rowvalue, col).Value = i.value??0;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style
.Border
.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.WrapText = true;
ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(rowhead, col).Style.Font.FontSize = 10;
ws.Cell(rowhead, col).Style.Alignment.WrapText = true;
ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell("A3").Style.Alignment.WrapText = true;
ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A3").Style.Font.FontSize = 10;
ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204);
ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell(rowvalue, col).Style.Font.FontSize = 10;
ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(rowvalue, col).Style.Alignment.WrapText = true;
col++;
}
foreach (var detail in requestSummary.data_1)
{
int col2 = 2;
ws.Cell(row, 1).Value = detail.rowno + detail.list;
// int col2 = 2;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName =
"TH SarabunPSK";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor =
XLColor.FromArgb(204, 153, 255);
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
foreach (var budgetPlan in detail.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255);
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
row++;
foreach (var detail2 in detail.data_2)
{
ws.Cell(row, 1).Value =detail2.rowno + detail2.list;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
col2 = 2;
foreach (var budgetPlan in detail2.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
row++;
foreach (var detail3 in detail2.data_3)
{
ws.Cell(row, 1).Value = detail3.rowno+detail3.list;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10;
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.WrapText = true;
col2 = 2;
foreach (var budgetPlan in detail3.plans)
{
ws.Cell(row, col2).Value = budgetPlan.value??0;
ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row, col2).Style.Font.FontSize = 10;
ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0");
ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, col2).Style.Alignment.WrapText = true;
col2++;
}
row++;
}
}
}
}
}
using (var stream = new MemoryStream())
{
workbook.SaveAs(stream);
var content = stream.ToArray();
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"integrated_strategic" + ".xlsx");
}
}
}
}