diff --git a/Controllers/DetailKpi.Controller.cs b/Controllers/DetailKpi.Controller.cs index 66d5d91..02fa70a 100644 --- a/Controllers/DetailKpi.Controller.cs +++ b/Controllers/DetailKpi.Controller.cs @@ -33,235 +33,235 @@ namespace rmutr_report.Controllers _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"); - } - } + // [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"); + // } + // } } } \ No newline at end of file diff --git a/Controllers/Detail_Kpi.Controller.cs b/Controllers/Detail_Kpi.Controller.cs new file mode 100644 index 0000000..88b7a7c --- /dev/null +++ b/Controllers/Detail_Kpi.Controller.cs @@ -0,0 +1,784 @@ +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 Detail_Kpi : Controller + { + readonly Setting _setting; + + public Detail_Kpi(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; + int rowh = 2; + int col1 = 8; + //ws.Cell(rowh, col1).Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + //ws.Range(ws.Cell(rowh, col1), ws.Cell(rowh, col1)).Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + // ws.Range(ws.Cell(rowh, col1), ws.Cell(rowh, col1)).Merge().Style.Fill.BackgroundColor = + // XLColor.White; + // if (col1==1) + // { + // ws.Range("H3").Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + // } + // ws.Range(ws.Cell(rowh, col1), ws.Cell(rowh, col1)).Merge().Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + // ws.Range(ws.Cell(rowh, col1), ws.Cell(rowh, col1)).Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + // ws.Range(ws.Cell(rowh, col1), ws.Cell(rowh, col1)).Merge().Style.Font.FontName = "TH Sarabun New"; + // ws.Range(ws.Cell(rowh, col1), ws.Cell(rowh, col1)).Merge().Style.Font.SetBold().Font.FontSize = 16; + // col1++; + // 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 = 8; + int rowhead = 3; + int row = 5; + int no = 1; + int rowno = 1; + //var dataagency2 = _kpi.agencys.ToArray(); + //rowhead++; + if (_kpi != null) + { + + foreach (var i in _kpi.agencys) + { + ws.Cell(rowhead, col).Value = i.agency_name; + ws.Cell(rowhead, col).Style.Alignment.SetTextRotation(90); + 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 Sarabun New"; + ws.Cell(rowhead,col).Style.Font.FontSize = 16; + col++; + var a = _kpi.agencys.Count; + + if (a==1) + { + ws.Range("H2").Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("H2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("H2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Cell("H2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:H1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:H1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==2) + { + ws.Range("H2:I2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("I2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("I2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:I2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:I1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:I1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==3) + { + ws.Range("H2:J2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("J2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("J2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:J2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:J1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:J1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==4) + { + ws.Range("H2:K2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("K2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("K2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:K2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:K1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:K1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==5) + { + ws.Range("H2:L2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("L2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("L2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:L2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:L1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:L1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==6) + { + ws.Range("H2:M2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("M2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("M2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:M2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:M1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:M1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==7) + { + ws.Range("H2:N2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("N2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("N2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:N2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:N1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:N1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==8) + { + ws.Range("H2:O2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("O2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("O2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:O2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:O1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:O1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==9) + { + ws.Range("H2:P2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("P2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("P2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:P2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:P1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:P1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==10) + { + ws.Range("H2:Q2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("Q2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("Q2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:Q2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:Q1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:Q1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + + if (a==10) + { + ws.Range("H2:R2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("R2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("R2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:R2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:R1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:R1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==11) + { + ws.Range("H2:S2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("S2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("S2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:S2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:S1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:S1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==12) + { + ws.Range("H2:T2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("T2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("T2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:T2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:T1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:T1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==13) + { + ws.Range("H2:U2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("U2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("U2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:U2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:U1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:U1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==14) + { + ws.Range("H2:V2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("V2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("V2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:V2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:V1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:V1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + if (a==15) + { + ws.Range("H2:W2").Merge().Value = "แผนปี "+_kpi.plan_year.Substring(2, 2)+" หน่วยงาน"; + ws.Cell("H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell("H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell("H2").Style.Font.FontName = "TH Sarabun New"; + ws.Cell("H2").Style.Font.SetBold().Font.FontSize = 16; + ws.Cell("W2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("W2").Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Range("H2:W2").Style.Border.TopBorder = XLBorderStyleValues.Thin; + ws.Range("A1:W1").Merge().Value = "แจ้งรายละเอียดตัวชี้วัดแผนกลยุทธ์ ประจำปีงบประมาณ พ.ศ. " + _kpi.budget_year; + ws.Cell("A1").Style.Font.SetBold().Font.FontSize = 16; + ws.Range("A1:W1").Style.Fill.BackgroundColor = XLColor.Yellow; + } + + } + + foreach (var header in _kpi.header_data) + { + var a = _kpi.agencys.Count; + if (a==1) + { + ws.Range("A4:H4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:H4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:H4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("H4:H5").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, 8)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==2) + { + ws.Range("A4:I4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:I4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("I4:I5").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, 9)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==3) + { + ws.Range("A4:J4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:J4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:J4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("J4:J5").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, 10)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==4) + { + ws.Range("A4:K4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:K4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:K4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("K4:K5").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, 11)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==5) + { + ws.Range("A4:L4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:L4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:L4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("L4:L5").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, 12)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==6) + { + ws.Range("A4:M4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:M4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:M4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("M4:M5").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, 13)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==7) + { + ws.Range("A4:N4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:N4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:N4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("N4:N5").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, 14)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==8) + { + ws.Range("A4:O4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:O4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:O4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("O4:O5").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, 15)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==9) + { + ws.Range("A4:P4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:P4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:P4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("P4:P5").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, 15)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==10) + { + ws.Range("A4:Q4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:Q4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:Q4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("Q4:Q5").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, 16)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==11) + { + ws.Range("A4:R4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:R4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:R4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("R4:R5").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, 17)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==12) + { + ws.Range("A4:S4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:S4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:S4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("S4:S5").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, 18)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==13) + { + ws.Range("A4:T4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:T4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:T4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("T4:T5").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, 19)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==14) + { + ws.Range("A4:U4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:U4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:U4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("U4:U5").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, 20)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==15) + { + ws.Range("A4:V4").Merge().Value = "ตัวชี้วัดแผนกลยุทธ์ พ.ศ. " + header.year_range; + ws.Cell("A4").Style.Font.Bold = true; + ws.Cell("A4").Style.Alignment.WrapText = true; + ws.Range("A4:V4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A4:V4").Style.Fill.BackgroundColor = XLColor.PurpleX11; + ws.Range("V4:V5").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, 21)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + if (a==16) + { + 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.Range("W4:W5").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, 22)).Merge().Style.Fill.BackgroundColor = + XLColor.BlizzardBlue; + } + // 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++; + //var dataagency2 = _kpi.agencys.Where(d => d.agency_name==d.agency_name).ToList(); + foreach (var data1 in header.data) + { + 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; + int col2 = 8; + foreach (var i in data1.agencys) + { + ws.Cell(row, col2).Value = i.value; + ws.Cell(row, col2).Style.Alignment.SetTextRotation(90); + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Cell(row,col2).Style.Font.FontName = "TH Sarabun New"; + ws.Cell(row,col2).Style.Font.FontSize = 16; + col2++; + } + //ws.Cell(row, 8).Value = dataagency; + // 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, 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++; + col++; + //col2++; + } + } + } + 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"); + } + } + + } +} \ No newline at end of file diff --git a/Models/budget/detail_kpi.cs b/Models/budget/detail_kpi.cs index ddcc92c..bcca124 100644 --- a/Models/budget/detail_kpi.cs +++ b/Models/budget/detail_kpi.cs @@ -8,28 +8,30 @@ namespace rmutr_report.Models public string budget_year { get; set; } public string plan_year { get; set; } public List 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 List agencys { 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 string agency_name { get; set; } public List data { get; set; } } @@ -41,21 +43,33 @@ namespace rmutr_report.Models 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; } + public Listagencys { get; set; } + public decimal? value1 { get; set; } + public decimal? 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; } } + + public class agency + { + public string agency_name { get; set; } + public decimal? value { get; set; } + + } + public class agency_data + { + public string agency_name { get; set; } + } } \ No newline at end of file diff --git a/obj/project.assets.json b/obj/project.assets.json index f852ded..5801ce9 100644 --- a/obj/project.assets.json +++ b/obj/project.assets.json @@ -2662,6 +2662,11 @@ "packagesPath": "C:\\Users\\Mercedes Benz\\.nuget\\packages\\", "outputPath": "C:\\Users\\Mercedes Benz\\Documents\\rmutr_report\\obj\\", "projectStyle": "PackageReference", + "configFilePaths": [ + "C:\\Users\\Mercedes Benz\\Documents\\rmutr_report\\NuGet.Config", + "C:\\Users\\Mercedes Benz\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], "originalTargetFrameworks": [ "net5.0" ], diff --git a/obj/rider.project.restore.info b/obj/rider.project.restore.info index d4f0776..069bdc3 100644 --- a/obj/rider.project.restore.info +++ b/obj/rider.project.restore.info @@ -1 +1 @@ -16760814342366599 \ No newline at end of file +16762520045325433 \ No newline at end of file diff --git a/obj/rmutr-report.csproj.nuget.dgspec.json b/obj/rmutr-report.csproj.nuget.dgspec.json index c6d45e2..275e28a 100644 --- a/obj/rmutr-report.csproj.nuget.dgspec.json +++ b/obj/rmutr-report.csproj.nuget.dgspec.json @@ -13,6 +13,11 @@ "packagesPath": "C:\\Users\\Mercedes Benz\\.nuget\\packages\\", "outputPath": "C:\\Users\\Mercedes Benz\\Documents\\rmutr_report\\obj\\", "projectStyle": "PackageReference", + "configFilePaths": [ + "C:\\Users\\Mercedes Benz\\Documents\\rmutr_report\\NuGet.Config", + "C:\\Users\\Mercedes Benz\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], "originalTargetFrameworks": [ "net5.0" ],