add export excel
This commit is contained in:
267
Controllers/DetailKpi.Controller.cs
Normal file
267
Controllers/DetailKpi.Controller.cs
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Data;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ClosedXML.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using ExcelDataReader;
|
||||||
|
using FastReport;
|
||||||
|
using FastReport.Export.Csv;
|
||||||
|
using FastReport.Export.Mht;
|
||||||
|
using FastReport.Export.OoXML;
|
||||||
|
using FastReport.Export.Pdf;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using rmutr_report.Models;
|
||||||
|
using rmutr_report.Models.Hr;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace rmutr_report.Controllers
|
||||||
|
{
|
||||||
|
[SwaggerTag("สำหรับรายงานรายละเอียดตัวชี้วัดแผนกลยุทธ์")]
|
||||||
|
public class DetailKpi : Controller
|
||||||
|
{
|
||||||
|
readonly Setting _setting;
|
||||||
|
|
||||||
|
public DetailKpi(Setting setting)
|
||||||
|
{
|
||||||
|
_setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, Route("reports/detail_kpi/{type}")]
|
||||||
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
|
public IActionResult GetDetailsKpiReport([FromRoute] string type, [FromBody] detail_kpi _kpi)
|
||||||
|
{
|
||||||
|
var workbook = new XLWorkbook();
|
||||||
|
var ws = workbook.Worksheets.Add("detailkpi");
|
||||||
|
ws.Range("A1:W1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year;
|
||||||
|
ws.Cell("A1").Style.Font.Bold = true;
|
||||||
|
ws.Cell("A1").Style.Alignment.WrapText = true;
|
||||||
|
ws.Range("A1:W1").Style.Fill.BackgroundColor = XLColor.Yellow;
|
||||||
|
ws.Range("A2:A3").Merge().Value = "ลำดับตัวชี้วัด";
|
||||||
|
ws.Range("A2:A3").Style.Font.Bold = true;
|
||||||
|
ws.Range("B2:B3").Merge().Value = "ตัวชี้วัด";
|
||||||
|
ws.Range("B2:B3").Style.Font.Bold = true;
|
||||||
|
ws.Range("B2:B3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("C2:C3").Merge().Value = "หน่วยนับ";
|
||||||
|
ws.Range("C2:C3").Style.Font.Bold = true;
|
||||||
|
ws.Range("C2:C3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("D2:D3").Merge().Value = "เป้าหมายปี "+_kpi.budget_year.Substring(2, 2);
|
||||||
|
ws.Range("D2:D3").Style.Font.Bold = true;
|
||||||
|
ws.Range("D2:D3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("E2:E3").Merge().Value = "ผู้กำกับ";
|
||||||
|
ws.Range("E2:E3").Style.Font.Bold = true;
|
||||||
|
ws.Range("E2:E3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("F2:F3").Merge().Value = "ผู้รับผิดชอบ";
|
||||||
|
ws.Range("F2:F3").Style.Font.Bold = true;
|
||||||
|
ws.Range("F2:F3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("G2:G3").Merge().Value = "ผู้รวบรวมและรายงานผล";
|
||||||
|
ws.Range("G2:G3").Style.Font.Bold = true;
|
||||||
|
ws.Range("G2:G3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("H2:W2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน";
|
||||||
|
ws.Range("H2:W2").Style.Font.Bold = true;
|
||||||
|
ws.Range("H2:H3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("H2:W2").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Range("H2:W2").Style.Font.FontSize = 16;
|
||||||
|
ws.Cell("H3").Value = _kpi.text1;
|
||||||
|
ws.Cell("I3").Value = _kpi.text2;
|
||||||
|
ws.Cell("J3").Value = _kpi.text3;
|
||||||
|
ws.Cell("K3").Value = _kpi.text4;
|
||||||
|
ws.Cell("L3").Value = _kpi.text5;
|
||||||
|
ws.Cell("M3").Value = _kpi.text6;
|
||||||
|
ws.Cell("N3").Value = _kpi.text7;
|
||||||
|
ws.Cell("O3").Value = _kpi.text8;
|
||||||
|
ws.Cell("P3").Value = _kpi.text9;
|
||||||
|
ws.Cell("Q3").Value = _kpi.text10;
|
||||||
|
ws.Cell("R3").Value = _kpi.text11;
|
||||||
|
ws.Cell("S3").Value = _kpi.text12;
|
||||||
|
ws.Cell("T3").Value = _kpi.text13;
|
||||||
|
ws.Cell("U3").Value = _kpi.text14;
|
||||||
|
ws.Cell("V3").Value = _kpi.text15;
|
||||||
|
ws.Cell("W3").Value = _kpi.text16;
|
||||||
|
ws.Range("A1:W1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A1:W1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("H3:W3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("H3:W3").Style.Alignment.SetTextRotation(90);
|
||||||
|
ws.Range("H3:W3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A2:G3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A2:G3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
|
||||||
|
ws.Range("A2:G3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("B2:C3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A2:W3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("H2:W2").Style.Border.BottomBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("H2:H3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("H3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("I3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("J3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("K3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("L3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("M3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("N3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("O3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("P3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("Q3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("R3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("S3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("T3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("U3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("V3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("W3").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
|
||||||
|
ws.Column(1).Width = 15;
|
||||||
|
ws.Column(2).Width = 40;
|
||||||
|
ws.Column(3).Width = 30;
|
||||||
|
ws.Column(4).Width = 30;
|
||||||
|
ws.Column(5).Width = 30;
|
||||||
|
ws.Column(6).Width = 30;
|
||||||
|
ws.Column(7).Width = 30;
|
||||||
|
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(15).Width = 10;
|
||||||
|
ws.Column(16).Width = 10;
|
||||||
|
ws.Column(17).Width = 10;
|
||||||
|
ws.Column(18).Width = 10;
|
||||||
|
ws.Column(19).Width = 10;
|
||||||
|
ws.Column(20).Width = 10;
|
||||||
|
ws.Column(21).Width = 10;
|
||||||
|
ws.Column(22).Width = 10;
|
||||||
|
ws.Column(23).Width = 10;
|
||||||
|
ws.Column(1).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(1).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(2).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(2).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(3).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(3).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(4).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(4).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(5).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(5).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(6).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(6).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(7).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(7).Style.Font.FontSize = 16;
|
||||||
|
ws.Range("H3:W3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Range("H3:W3").Style.Font.FontSize = 16;
|
||||||
|
int col = 1;
|
||||||
|
// int rowh = 4;
|
||||||
|
//int rowh2 = 5;
|
||||||
|
int row = 5;
|
||||||
|
int no = 1;
|
||||||
|
int rowno = 1;
|
||||||
|
// foreach (var kpis in _kpi)
|
||||||
|
// {
|
||||||
|
if (_kpi != null)
|
||||||
|
{
|
||||||
|
foreach (var header in _kpi.header_data)
|
||||||
|
{
|
||||||
|
ws.Range("A4:W4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range;
|
||||||
|
ws.Cell("A4").Style.Font.Bold = true;
|
||||||
|
ws.Cell("A4").Style.Alignment.WrapText = true;
|
||||||
|
ws.Range("A4:W4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A4:W4").Style.Fill.BackgroundColor = XLColor.PurpleX11;
|
||||||
|
ws.Cell("W4").Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
string kpiname = "ประเด็นยุทธ์ศาสตร์ที่ " + no + " " + header.strategic_issues;
|
||||||
|
no++;
|
||||||
|
ws.Cell(row, 1).SetValue(kpiname).Style.Font.Bold = true;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder =
|
||||||
|
XLBorderStyleValues.None;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Merge().Style.Fill.BackgroundColor =
|
||||||
|
XLColor.BlizzardBlue;
|
||||||
|
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row, 23).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
row++;
|
||||||
|
foreach (var data1 in header.data)
|
||||||
|
{
|
||||||
|
// if ( rowno > 1 )
|
||||||
|
// {
|
||||||
|
// ws.Range(ws.Cell(row, 1), ws.Cell(row,1)).Merge()
|
||||||
|
// }
|
||||||
|
ws.Cell(row, 1).Value = rowno;
|
||||||
|
ws.Cell(row, 2).Value = data1.name;
|
||||||
|
ws.Cell(row, 3).Value = data1.unit;
|
||||||
|
ws.Cell(row, 4).Value = data1.target;
|
||||||
|
ws.Cell(row, 5).Value = data1.director;
|
||||||
|
ws.Cell(row, 6).Value = data1.responsible_person;
|
||||||
|
ws.Cell(row, 7).Value = data1.compiler_reporter;
|
||||||
|
ws.Cell(row, 8).Value = data1.value1;
|
||||||
|
ws.Cell(row, 9).Value = data1.value2;
|
||||||
|
ws.Cell(row, 10).Value = data1.value3;
|
||||||
|
ws.Cell(row, 11).Value = data1.value4;
|
||||||
|
ws.Cell(row, 12).Value = data1.value5;
|
||||||
|
ws.Cell(row, 13).Value = data1.value6;
|
||||||
|
ws.Cell(row, 14).Value = data1.value7;
|
||||||
|
ws.Cell(row, 15).Value = data1.value8;
|
||||||
|
ws.Cell(row, 16).Value = data1.value9;
|
||||||
|
ws.Cell(row, 17).Value = data1.value10;
|
||||||
|
ws.Cell(row, 18).Value = data1.value11;
|
||||||
|
ws.Cell(row, 19).Value = data1.value12;
|
||||||
|
ws.Cell(row, 20).Value = data1.value13;
|
||||||
|
ws.Cell(row, 21).Value = data1.value14;
|
||||||
|
ws.Cell(row, 22).Value = data1.value15;
|
||||||
|
ws.Cell(row, 23).Value = data1.value16;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,23)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,23)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.RightBorder = 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, 20).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 21).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 22).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 23).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,23)).Style.Alignment.WrapText = true;
|
||||||
|
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,23)).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,23)).Style.Font.FontSize = 16;
|
||||||
|
row++;
|
||||||
|
rowno++;
|
||||||
|
//rowh2++;
|
||||||
|
}
|
||||||
|
//rowh2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
var content = stream.ToArray();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
|
return File(
|
||||||
|
content,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
date + ".xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -171,7 +171,7 @@ namespace rmutr_report.Controllers
|
|||||||
XLBorderStyleValues.Thin;
|
XLBorderStyleValues.Thin;
|
||||||
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
row++;
|
row++;
|
||||||
ws.Cell(row, 1).Value = "ตัวชี้วัดกลยุทธ์";
|
ws.Cell(row, 1).Value = "ตัวชี้วัดกลยุทธ์ : " + header.indicator_type_name_th;
|
||||||
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Beige;
|
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Beige;
|
||||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder =
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder =
|
||||||
XLBorderStyleValues.Thin;
|
XLBorderStyleValues.Thin;
|
||||||
|
|||||||
134
Controllers/KpiNotAchieve.Controller.cs
Normal file
134
Controllers/KpiNotAchieve.Controller.cs
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using ClosedXML.Excel;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using rmutr_report.Models;
|
||||||
|
using rmutr_report.Models.Hr;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace rmutr_report.Controllers
|
||||||
|
{
|
||||||
|
[SwaggerTag("สำหรับรายงานผลการปฏิบัติงานตัวชี้วัดที่ไม่บรรลุแผนกลยุทธ์ทางการเงิน")]
|
||||||
|
public class kpi_not_achieve : Controller
|
||||||
|
{
|
||||||
|
readonly Setting _setting;
|
||||||
|
|
||||||
|
public kpi_not_achieve(Setting setting)
|
||||||
|
{
|
||||||
|
_setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, Route("reports/kpi_not_achieve/{type}")]
|
||||||
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
|
public IActionResult GetDetailKpiReport([FromRoute] string type, [FromBody] kpi_not_achieves _kpi)
|
||||||
|
{
|
||||||
|
var workbook = new XLWorkbook();
|
||||||
|
var ws = workbook.Worksheets.Add("kpi");
|
||||||
|
ws.Range("A1:E1").Merge().Value = "ผลการปฏิบัติงานตัวชี้วัดแผนกลยุทธ์ทางการเงิน (พ.ศ. " + _kpi.year_range+ ") "+"มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์ ประจำปี "+_kpi.budget_year
|
||||||
|
+" รอบ "+_kpi.budget_month+" เดือน";
|
||||||
|
ws.Cell("A1").Style.Font.Bold = true;
|
||||||
|
ws.Cell("A1").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("A2").Value = "ลำดับ";
|
||||||
|
ws.Cell("A2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("B2").Value = "ตัวชี้วัด";
|
||||||
|
ws.Cell("B2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("B2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("C2").Value = "แผนปี "+ _kpi.plan_year.Substring(2,2);;
|
||||||
|
ws.Cell("C2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("C2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("D2").Value = "ผลลัพธ์";
|
||||||
|
ws.Cell("D2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("D2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("E2").Value = "หมายเหตุ";
|
||||||
|
ws.Cell("E2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("E2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A2:E2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A2:E2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A2:E2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A1:E1").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A1:E1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A1:E1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Column(1).Width = 10;
|
||||||
|
ws.Column(2).Width = 40;
|
||||||
|
ws.Column(3).Width = 20;
|
||||||
|
ws.Column(4).Width = 30;
|
||||||
|
ws.Column(5).Width = 30;
|
||||||
|
ws.Column(1).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(1).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(2).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(2).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(3).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(3).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(4).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(4).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(5).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(5).Style.Font.FontSize = 16;
|
||||||
|
int col = 1;
|
||||||
|
int row = 3;
|
||||||
|
int no = 1;
|
||||||
|
int rowno = 1;
|
||||||
|
// foreach (var kpis in _kpi)
|
||||||
|
// {
|
||||||
|
if (_kpi != null)
|
||||||
|
{
|
||||||
|
foreach (var header in _kpi.header_data)
|
||||||
|
{
|
||||||
|
string kpiname = "ประเด็นยุทธ์ศาสตร์ที่ " + no +" : " + header.strategic_issues;
|
||||||
|
no++;
|
||||||
|
ws.Cell(row, 1).SetValue(kpiname).Style.Font.Bold = true;
|
||||||
|
// ws.Cell(row, 2).Value = header.header_1;
|
||||||
|
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Bisque;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder =
|
||||||
|
XLBorderStyleValues.None;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 5)).Merge().Style.Fill.BackgroundColor = XLColor.Bisque;
|
||||||
|
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row,5).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
row++;
|
||||||
|
foreach (var data1 in header.data)
|
||||||
|
{
|
||||||
|
// if ( rowno > 1 )
|
||||||
|
// {
|
||||||
|
// ws.Range(ws.Cell(row, 1), ws.Cell(row,1)).Merge()
|
||||||
|
// }
|
||||||
|
ws.Cell(row, 1).Value = rowno;
|
||||||
|
ws.Cell(row, 2).Value = data1.name;
|
||||||
|
ws.Cell(row, 3).Value = data1.value;
|
||||||
|
ws.Cell(row, 4).Value = data1.result;
|
||||||
|
ws.Cell(row, 5).Value = data1.note;
|
||||||
|
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,5)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,5)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.RightBorder = 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.Range(ws.Cell(row, 1),ws.Cell(row,5)).Style.Alignment.WrapText = true;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,5)).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,5)).Style.Font.FontSize = 16;
|
||||||
|
row++;
|
||||||
|
rowno++;
|
||||||
|
}
|
||||||
|
//row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
var content = stream.ToArray();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
|
return File(
|
||||||
|
content,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
date + ".xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -142,10 +142,22 @@ namespace rmutr_report.Controllers
|
|||||||
data.sum_degree = s4;
|
data.sum_degree = s4;
|
||||||
data.total12 = data.total10 + data.total11;
|
data.total12 = data.total10 + data.total11;
|
||||||
//data.sum_degree = (data.ph_degree_science + data.master_science)+(data.ph_degree_social + data.master_social);
|
//data.sum_degree = (data.ph_degree_science + data.master_science)+(data.ph_degree_social + data.master_social);
|
||||||
|
// if (data.ph_degree_science != 0 && data.master_science != 0 && data.sum_degree_science != 0&& data.sum_degree_social != 0)
|
||||||
|
// {
|
||||||
data.sum_percentage_science = ((data.ph_degree_science + data.master_science) * 100) /
|
data.sum_percentage_science = ((data.ph_degree_science + data.master_science) * 100) /
|
||||||
(data.sum_degree_science + data.sum_degree_social);
|
(data.sum_degree_science + data.sum_degree_social);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// data.sum_percentage_science = ((data.ph_degree_science + data.master_science) * 100) /
|
||||||
|
// (data.sum_degree_science + data.sum_degree_social);
|
||||||
|
|
||||||
|
// if (data.ph_degree_social != 0 && data.master_social != 0 && data.sum_degree_science != 0&& data.sum_degree_social != 0)
|
||||||
|
// {
|
||||||
data.sum_percentage_social = ((data.ph_degree_social + data.master_social) * 100) /
|
data.sum_percentage_social = ((data.ph_degree_social + data.master_social) * 100) /
|
||||||
(data.sum_degree_science + data.sum_degree_social);
|
(data.sum_degree_science + data.sum_degree_social);
|
||||||
|
//}
|
||||||
|
// data.sum_percentage_social = ((data.ph_degree_social + data.master_social) * 100) /
|
||||||
|
// (data.sum_degree_science + data.sum_degree_social);
|
||||||
|
|
||||||
data.total13 = (data.total10 * 100) / data.total12;
|
data.total13 = (data.total10 * 100) / data.total12;
|
||||||
data.total14 = (data.total11 * 100) / data.total12;
|
data.total14 = (data.total11 * 100) / data.total12;
|
||||||
|
|||||||
189
Controllers/kpi_performance_finance.Controller.cs
Normal file
189
Controllers/kpi_performance_finance.Controller.cs
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Data;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ClosedXML.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using ExcelDataReader;
|
||||||
|
using FastReport;
|
||||||
|
using FastReport.Export.Csv;
|
||||||
|
using FastReport.Export.Mht;
|
||||||
|
using FastReport.Export.OoXML;
|
||||||
|
using FastReport.Export.Pdf;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using rmutr_report.Models;
|
||||||
|
using rmutr_report.Models.Hr;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace rmutr_report.Controllers
|
||||||
|
{
|
||||||
|
[SwaggerTag("สำหรับรายงานผลการปฏิบัติงานตัวชี้วัดแผนกลยุทธ์ทางการเงิน")]
|
||||||
|
public class kpiperformancefinance : Controller
|
||||||
|
{
|
||||||
|
readonly Setting _setting;
|
||||||
|
|
||||||
|
public kpiperformancefinance(Setting setting)
|
||||||
|
{
|
||||||
|
_setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, Route("reports/kpi_performance_finance/{type}")]
|
||||||
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
|
public IActionResult GetDetailKpiReport([FromRoute] string type, [FromBody] kpi_performance_finance _kpi)
|
||||||
|
{
|
||||||
|
var workbook = new XLWorkbook();
|
||||||
|
var ws = workbook.Worksheets.Add("kpi");
|
||||||
|
ws.Range("A1:J1").Merge().Value = "ผลการปฏิบัติงานตัวชี้วัดแผนกลยุทธ์ทางการเงิน (พ.ศ. " + _kpi.year_range+ ") "+"มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์ ประจำปี "+_kpi.budget_year
|
||||||
|
+" รอบ "+_kpi.budget_month+" เดือน";
|
||||||
|
ws.Cell("A1").Style.Font.Bold = true;
|
||||||
|
ws.Cell("A1").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("A2").Value = "ลำดับ";
|
||||||
|
ws.Cell("A2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("B2").Value = "ตัวชี้วัด";
|
||||||
|
ws.Cell("B2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("B2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("C2").Value = "หน่วยนับ";
|
||||||
|
ws.Cell("C2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("C2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("D2").Value = "ผู้กำกับ";
|
||||||
|
ws.Cell("D2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("D2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("E2").Value = "ผู้รับผิดชอบ";
|
||||||
|
ws.Cell("E2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("E2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("F2").Value = "ผู้รวบรวมและรายงานผล";
|
||||||
|
ws.Cell("F2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("F2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("G2").Value = "แผนปี " + _kpi.plan_year.Substring(2,2);
|
||||||
|
ws.Cell("G2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("G2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("H2").Value = "ผลลัพธ์";
|
||||||
|
ws.Cell("H2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("H2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("I2").Value = "บรรลุ √ ไม่บรรลุ X";
|
||||||
|
ws.Cell("I2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("I2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("J2").Value = "หมายเหตุ";
|
||||||
|
ws.Cell("J2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("J2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A2:J2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A2:J2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A2:J2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A1:J1").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A1:J1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A1:J1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Column(1).Width = 10;
|
||||||
|
ws.Column(2).Width = 40;
|
||||||
|
ws.Column(3).Width = 20;
|
||||||
|
ws.Column(4).Width = 30;
|
||||||
|
ws.Column(5).Width = 30;
|
||||||
|
ws.Column(6).Width = 30;
|
||||||
|
ws.Column(7).Width = 30;
|
||||||
|
ws.Column(8).Width = 10;
|
||||||
|
ws.Column(9).Width = 20;
|
||||||
|
ws.Column(10).Width = 30;
|
||||||
|
|
||||||
|
ws.Column(1).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(1).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(2).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(2).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(3).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(3).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(4).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(4).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(5).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(5).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(6).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(6).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(7).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(7).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(8).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(8).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(9).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(9).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(10).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(10).Style.Font.FontSize = 16;
|
||||||
|
|
||||||
|
int col = 1;
|
||||||
|
int row = 3;
|
||||||
|
int no = 1;
|
||||||
|
int rowno = 1;
|
||||||
|
// foreach (var kpis in _kpi)
|
||||||
|
// {
|
||||||
|
if (_kpi != null)
|
||||||
|
{
|
||||||
|
foreach (var header in _kpi.header_data)
|
||||||
|
{
|
||||||
|
string kpiname = "ประเด็นยุทธ์ศาสตร์ที่ " + no +" " + header.strategic_issues;
|
||||||
|
no++;
|
||||||
|
ws.Cell(row, 1).SetValue(kpiname).Style.Font.Bold = true;
|
||||||
|
// ws.Cell(row, 2).Value = header.header_1;
|
||||||
|
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Bisque;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder =
|
||||||
|
XLBorderStyleValues.None;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Merge().Style.Fill.BackgroundColor = XLColor.Bisque;
|
||||||
|
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row,10).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
row++;
|
||||||
|
foreach (var data1 in header.data)
|
||||||
|
{
|
||||||
|
// if ( rowno > 1 )
|
||||||
|
// {
|
||||||
|
// ws.Range(ws.Cell(row, 1), ws.Cell(row,1)).Merge()
|
||||||
|
// }
|
||||||
|
ws.Cell(row, 1).Value = rowno;
|
||||||
|
ws.Cell(row, 2).Value = data1.name;
|
||||||
|
ws.Cell(row, 3).Value = data1.unit;
|
||||||
|
ws.Cell(row, 4).Value = data1.director;
|
||||||
|
ws.Cell(row, 5).Value = data1.responsible_person;
|
||||||
|
ws.Cell(row, 6).Value = data1.compiler_reporter;
|
||||||
|
ws.Cell(row, 7).Value = data1.value;
|
||||||
|
ws.Cell(row, 8).Value = data1.result;
|
||||||
|
ws.Cell(row, 9).Value = data1.achieve;
|
||||||
|
ws.Cell(row, 10).Value = data1.note;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.RightBorder = 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.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Alignment.WrapText = true;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Font.FontSize = 16;
|
||||||
|
row++;
|
||||||
|
rowno++;
|
||||||
|
}
|
||||||
|
//row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
var content = stream.ToArray();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
|
return File(
|
||||||
|
content,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
date + ".xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
174
Controllers/kpi_performance_result.Controller.cs
Normal file
174
Controllers/kpi_performance_result.Controller.cs
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using ClosedXML.Excel;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using rmutr_report.Models;
|
||||||
|
using rmutr_report.Models.Hr;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
||||||
|
namespace rmutr_report.Controllers
|
||||||
|
{
|
||||||
|
[SwaggerTag("สำหรับรายงานผลการปฏิบัติงานตัวชี้วัดแผนกลยุทธ์มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์")]
|
||||||
|
public class kpi_performance_result : Controller
|
||||||
|
{
|
||||||
|
readonly Setting _setting;
|
||||||
|
|
||||||
|
public kpi_performance_result(Setting setting)
|
||||||
|
{
|
||||||
|
_setting = setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, Route("reports/kpi_performance_result/{type}")]
|
||||||
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
|
public IActionResult GetDetailKpiReport([FromRoute] string type, [FromBody] kpi_performance_results _kpi)
|
||||||
|
{
|
||||||
|
var workbook = new XLWorkbook();
|
||||||
|
var ws = workbook.Worksheets.Add("kpi");
|
||||||
|
ws.Range("A1:J1").Merge().Value = "ผลการปฏิบัติงานตัวชี้วัดแผนกลยุทธ์มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year;
|
||||||
|
ws.Cell("A1").Style.Font.Bold = true;
|
||||||
|
ws.Cell("A1").Style.Alignment.WrapText = true;
|
||||||
|
ws.Range("A1:J1").Style.Fill.BackgroundColor = XLColor.Yellow;
|
||||||
|
ws.Cell("A2").Value = "ลำดับตัวชี้วัด";
|
||||||
|
ws.Cell("A2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("B2").Value = "ตัวชี้วัด";
|
||||||
|
ws.Cell("B2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("B2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("C2").Value = "หน่วยนับ";
|
||||||
|
ws.Cell("C2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("C2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("D2").Value = "ผู้กำกับ";
|
||||||
|
ws.Cell("D2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("D2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("E2").Value = "ผู้รับผิดชอบ";
|
||||||
|
ws.Cell("E2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("E2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("F2").Value = "ผู้รวบรวมและรายงาน";
|
||||||
|
ws.Cell("F2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("F2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("G2").Value = "แผนปี" + _kpi.plan_year.Substring(2,2);
|
||||||
|
ws.Cell("G2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("G2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("H2").Value = "ผลลัพธ์";
|
||||||
|
ws.Cell("H2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("H2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("I2").Value = "บรรลุ √ ไม่บรรลุ X";
|
||||||
|
ws.Cell("I2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("I2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("J2").Value = "หมายเหตุ";
|
||||||
|
ws.Cell("J2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("J2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A2:J2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A2:J2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A2:J2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A1:J1").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("A1:J1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A1:J1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Column(1).Width = 12;
|
||||||
|
ws.Column(2).Width = 40;
|
||||||
|
ws.Column(3).Width = 20;
|
||||||
|
ws.Column(4).Width = 30;
|
||||||
|
ws.Column(5).Width = 30;
|
||||||
|
ws.Column(6).Width = 30;
|
||||||
|
ws.Column(7).Width = 10;
|
||||||
|
ws.Column(8).Width = 10;
|
||||||
|
ws.Column(9).Width = 20;
|
||||||
|
ws.Column(10).Width = 30;
|
||||||
|
ws.Column(1).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(1).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(2).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(2).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(3).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(3).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(4).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(4).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(5).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(5).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(6).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(6).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(7).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(7).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(8).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(8).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(9).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(9).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(10).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(10).Style.Font.FontSize = 16;
|
||||||
|
int col = 1;
|
||||||
|
int row = 3;
|
||||||
|
int no = 1;
|
||||||
|
int rowno = 1;
|
||||||
|
// foreach (var kpis in _kpi)
|
||||||
|
// {
|
||||||
|
if (_kpi != null)
|
||||||
|
{
|
||||||
|
foreach (var header in _kpi.header_data)
|
||||||
|
{
|
||||||
|
string kpiname = "ประเด็นยุทธ์ศาสตร์ที่ " + no +" " + header.strategic_issues;
|
||||||
|
no++;
|
||||||
|
ws.Cell(row, 1).SetValue(kpiname).Style.Font.Bold = true;
|
||||||
|
// ws.Cell(row, 2).Value = header.header_1;
|
||||||
|
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.PurpleX11;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder =
|
||||||
|
XLBorderStyleValues.None;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Merge().Style.Fill.BackgroundColor = XLColor.PurpleX11;
|
||||||
|
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
|
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row,10).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
row++;
|
||||||
|
foreach (var data1 in header.data)
|
||||||
|
{
|
||||||
|
// if ( rowno > 1 )
|
||||||
|
// {
|
||||||
|
// ws.Range(ws.Cell(row, 1), ws.Cell(row,1)).Merge()
|
||||||
|
// }
|
||||||
|
ws.Cell(row, 1).Value = rowno;
|
||||||
|
ws.Cell(row, 2).Value = data1.name;
|
||||||
|
ws.Cell(row, 3).Value = data1.unit;
|
||||||
|
ws.Cell(row, 4).Value = data1.director;
|
||||||
|
ws.Cell(row, 5).Value = data1.responsible_person;
|
||||||
|
ws.Cell(row, 6).Value = data1.compiler_reporter;
|
||||||
|
ws.Cell(row, 7).Value = data1.value;
|
||||||
|
ws.Cell(row, 8).Value = data1.result;
|
||||||
|
ws.Cell(row, 9).Value = data1.achieve;
|
||||||
|
ws.Cell(row, 10).Value = data1.note;
|
||||||
|
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 1).Style.Border.RightBorder = 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.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Alignment.WrapText = true;
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Range(ws.Cell(row, 1),ws.Cell(row,10)).Style.Font.FontSize = 16;
|
||||||
|
row++;
|
||||||
|
rowno++;
|
||||||
|
}
|
||||||
|
//row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
var content = stream.ToArray();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
|
return File(
|
||||||
|
content,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
date + ".xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
61
Models/budget/detail_kpi.cs
Normal file
61
Models/budget/detail_kpi.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace rmutr_report.Models
|
||||||
|
{
|
||||||
|
public class detail_kpi
|
||||||
|
{
|
||||||
|
|
||||||
|
public string budget_year { get; set; }
|
||||||
|
public string plan_year { get; set; }
|
||||||
|
public List<detail_kpi_data> header_data { get; set; }
|
||||||
|
public string text1 { get; set; }
|
||||||
|
public string text2 { get; set; }
|
||||||
|
public string text3 { get; set; }
|
||||||
|
public string text4 { get; set; }
|
||||||
|
public string text5 { get; set; }
|
||||||
|
public string text6 { get; set; }
|
||||||
|
public string text7 { get; set; }
|
||||||
|
public string text8 { get; set; }
|
||||||
|
public string text9 { get; set; }
|
||||||
|
public string text10 { get; set; }
|
||||||
|
public string text11 { get; set; }
|
||||||
|
public string text12 { get; set; }
|
||||||
|
public string text13 { get; set; }
|
||||||
|
public string text14 { get; set; }
|
||||||
|
public string text15 { get; set; }
|
||||||
|
public string text16 { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class detail_kpi_data
|
||||||
|
{
|
||||||
|
public string year_range { get; set; }
|
||||||
|
public string strategic_issues { get; set;}
|
||||||
|
public List<detail_kpi_datas> data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class detail_kpi_datas
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string unit { get; set; }
|
||||||
|
public decimal? target { get; set; }
|
||||||
|
public string director { get; set; }
|
||||||
|
public string responsible_person { get; set; }
|
||||||
|
public string compiler_reporter { get; set; }
|
||||||
|
public string value1 { get; set; }
|
||||||
|
public string value2 { get; set; }
|
||||||
|
public string value3 { get; set; }
|
||||||
|
public string value4 { get; set; }
|
||||||
|
public string value5 { get; set; }
|
||||||
|
public string value6 { get; set; }
|
||||||
|
public string value7 { get; set; }
|
||||||
|
public string value8 { get; set; }
|
||||||
|
public string value9 { get; set; }
|
||||||
|
public string value10 { get; set; }
|
||||||
|
public string value11 { get; set; }
|
||||||
|
public string value12 { get; set; }
|
||||||
|
public string value13 { get; set; }
|
||||||
|
public string value14 { get; set; }
|
||||||
|
public string value15 { get; set; }
|
||||||
|
public string value16 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ namespace rmutr_report.Models
|
|||||||
{
|
{
|
||||||
public string header_1 { get; set; }
|
public string header_1 { get; set; }
|
||||||
public string header_2 { get; set; }
|
public string header_2 { get; set; }
|
||||||
//public string header_3 { get; set; }
|
public string indicator_type_name_th { get; set; }
|
||||||
public List<kpi_data_details> data { get; set; }
|
public List<kpi_data_details> data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
Models/budget/kpi_not_achieves.cs
Normal file
27
Models/budget/kpi_not_achieves.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace rmutr_report.Models
|
||||||
|
{
|
||||||
|
public class kpi_not_achieves
|
||||||
|
{
|
||||||
|
public string year_range { get; set; }
|
||||||
|
public string budget_year { get; set; }
|
||||||
|
public string budget_month { get; set; }
|
||||||
|
public string plan_year { get; set; }
|
||||||
|
public List<kpi_not_achieve_data> header_data { get; set; }
|
||||||
|
}
|
||||||
|
public class kpi_not_achieve_data
|
||||||
|
{
|
||||||
|
public string strategic_issues { get; set;}
|
||||||
|
public List<detail_kpi_not_achieve_data> data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class detail_kpi_not_achieve_data
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public decimal? value { get; set; }
|
||||||
|
public decimal? result { get; set; }
|
||||||
|
public string note { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
Models/budget/kpi_performance_finance.cs
Normal file
31
Models/budget/kpi_performance_finance.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace rmutr_report.Models
|
||||||
|
{
|
||||||
|
public class kpi_performance_finance
|
||||||
|
{
|
||||||
|
public string year_range { get; set; }
|
||||||
|
public string budget_year { get; set; }
|
||||||
|
public string budget_month { get; set; }
|
||||||
|
public string plan_year { get; set; }
|
||||||
|
public List<kpi_performance_finance_data> header_data { get; set; }
|
||||||
|
}
|
||||||
|
public class kpi_performance_finance_data
|
||||||
|
{
|
||||||
|
public string strategic_issues { get; set;}
|
||||||
|
public List<detail_kpi_performance_data> data { get; set; }
|
||||||
|
}
|
||||||
|
public class detail_kpi_performance_data
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string unit { get; set; }
|
||||||
|
public string director { get; set; }
|
||||||
|
public string responsible_person { get; set; }
|
||||||
|
public string compiler_reporter { get; set; }
|
||||||
|
public decimal? value { get; set; }
|
||||||
|
public decimal? result { get; set; }
|
||||||
|
public string achieve { get; set; }
|
||||||
|
public string note { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
33
Models/budget/kpi_performance_results.cs
Normal file
33
Models/budget/kpi_performance_results.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace rmutr_report.Models
|
||||||
|
{
|
||||||
|
public class kpi_performance_results
|
||||||
|
{
|
||||||
|
public string budget_year { get; set; }
|
||||||
|
public string plan_year { get; set; }
|
||||||
|
|
||||||
|
public List<kpi_performance_result_data> header_data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class kpi_performance_result_data
|
||||||
|
{
|
||||||
|
public string strategic_issues { get; set; }
|
||||||
|
|
||||||
|
public List<detail_kpi_performance_result> data { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class detail_kpi_performance_result
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string unit { get; set; }
|
||||||
|
public string director { get; set; }
|
||||||
|
public string responsible_person { get; set; }
|
||||||
|
public string compiler_reporter { get; set; }
|
||||||
|
public decimal? value { get; set; }
|
||||||
|
public decimal? result { get; set; }
|
||||||
|
public string achieve { get; set; }
|
||||||
|
public string note { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user