Add สงป 301
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kamonwan taengsuk
2025-02-20 11:59:31 +07:00
parent 12da4e1939
commit 731803e190
22 changed files with 872 additions and 10 deletions

View File

@@ -4881,6 +4881,542 @@ namespace rmutr_report.Controllers
"integrated_strategic" + ".xlsx");
}
}
[SwaggerOperation("สปง301")]
[HttpPost, Route("reports/manage_plan_budget_1/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetBudgetManagePlanReport([FromRoute] string type, [FromBody] manage_plan_budget budgetManagePlan)
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("Sheet1");
ws.Range("A1:Q1").Merge().Value = "แบบจัดทำแผน/รายงานผลการปฏิบัติงานและการใช้จ่ายงบประมาณ ประจำปีงบประมาณ "+budgetManagePlan.budget_year;
ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 16;
ws.Range("A1:Q1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A1:Q1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("N2:Q2").Merge().Value = "หน่วย : ล้านบาท (ทศนิยม 4 ตำแหน่ง )";
ws.Cell("N2").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("N2").Style.Font.FontSize = 16;
ws.Range("N2:Q2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("N2:Q2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
var range = ws.Range("A3:A4");
range.Merge();
range.Value = "ยุทธศาสตร์ชาติ - แผนแม่บทภายใต้ยุทธศาสตร์ชาติ - แผนย่อยของแผนแม่บทฯ ยุทธศาสตร์จัดสรร - แผนงาน - เป้าประสงค์เชิงยุทธศาสตร์ เป้าหมายการให้บริการกระทรวง - เป้าหมายการให้บริการหน่วยงาน ผลผลิต/โครงการ - กิจกรรม";
range.Style.Alignment.WrapText = true;
ws.Row(3).Height = 50;
ws.Row(4).Height = 50;
ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("A3").Style.Font.FontSize = 15;
ws.Range("A3:A4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("A3:A4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A3:A4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("A3:A4").Style.Alignment.WrapText = true;
ws.Range("A3:A4").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("B3:B4").Merge().Value = "หน่วยนับ";
ws.Cell("B3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("B3").Style.Font.FontSize = 15;
ws.Range("B3:B4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("B3:B4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("B3:B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B3:B4").Style.Alignment.WrapText = true;
ws.Range("B3:B4").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("C3:E3").Merge().Value = "รวมทั้งสิ้น";
ws.Cell("C3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("C3").Style.Font.FontSize = 15;
ws.Range("C3:E3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("C3:E3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("C3:E3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("C3:E3").Style.Alignment.WrapText = true;
ws.Range("C3:E3").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("F3:H3").Merge().Value = "ไตรมาส 1 ( ต.ค.- ธ.ค.)";
ws.Cell("F3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("F3").Style.Font.FontSize = 15;
ws.Range("F3:H3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("F3:H3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("F3:H3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("F3:H3").Style.Alignment.WrapText = true;
ws.Range("F3:H3").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("I3:K3").Merge().Value = "ไตรมาส 2 ( ม.ค.- มี.ค.)";
ws.Cell("I3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("I3").Style.Font.FontSize = 15;
ws.Range("I3:K3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("I3:K3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("I3:K3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("I3:K3").Style.Alignment.WrapText = true;
ws.Range("I3:K3").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("L3:N3").Merge().Value = "ไตรมาส 3 ( เม.ย.- มิ.ย.)";
ws.Cell("L3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("L3").Style.Font.FontSize = 15;
ws.Range("L3:N3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("L3:N3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("L3:N3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("L3:N3").Style.Alignment.WrapText = true;
ws.Range("L3:N3").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("O3:Q3").Merge().Value = "ไตรมาส 4 ( ก.ค.- ก.ย.)";
ws.Cell("O3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Cell("O3").Style.Font.FontSize = 15;
ws.Range("O3:Q3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("O3:Q3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("O3:Q3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("O3:Q3").Style.Alignment.WrapText = true;
ws.Range("O3:Q3").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Cell("C4").Value = "แผน(ขั้น พ.ร.บ.)";
ws.Cell("D4").Value = "แผน(ขั้น บริหาร)";
ws.Cell("E4").Value = "ผล";
ws.Cell("F4").Value = "แผน(ขั้น พ.ร.บ.)";
ws.Cell("G4").Value = "แผน(ขั้น บริหาร)";
ws.Cell("H4").Value = "ผล";
ws.Cell("I4").Value = "แผน(ขั้น พ.ร.บ.)";
ws.Cell("J4").Value = "แผน(ขั้น บริหาร)";
ws.Cell("K4").Value = "ผล";
ws.Cell("L4").Value = "แผน(ขั้น พ.ร.บ.)";
ws.Cell("M4").Value = "แผน(ขั้น บริหาร)";
ws.Cell("N4").Value = "ผล";
ws.Cell("O4").Value = "แผน(ขั้น พ.ร.บ.)";
ws.Cell("P4").Value = "แผน(ขั้น บริหาร)";
ws.Cell("Q4").Value = "ผล";
ws.Range("C4:Q4").Style.Font.SetBold().Font.FontName = "TH SarabunPSK";
ws.Range("C4:Q4").Style.Font.FontSize = 15;
ws.Range("C4:Q4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range("C4:Q4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("C4:Q4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("C4:Q4").Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range("C4:Q4").Style.Alignment.WrapText = true;
ws.Range("C4:Q4").Style.Fill.BackgroundColor = XLColor.FromArgb(217,217,217);
ws.Range("A3:A4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("B3:B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range("C3:E3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Column(1).Width = 45;
ws.Column(2).Width = 25;
ws.Column(3).Width = 20;
ws.Column(4).Width = 20;
ws.Column(5).Width = 20;
ws.Column(6).Width = 20;
ws.Column(7).Width = 20;
ws.Column(8).Width = 20;
ws.Column(9).Width = 20;
ws.Column(10).Width = 20;
ws.Column(11).Width = 20;
ws.Column(12).Width = 20;
ws.Column(13).Width = 20;
ws.Column(14).Width = 20;
ws.Column(15).Width = 20;
ws.Column(16).Width = 20;
ws.Column(17).Width = 20;
int row = 6;
if (budgetManagePlan != null)
{
ws.Cell(5, 1).Value ="ผลสัมฤทธิ์และประโยชน์ที่คาดว่าจะได้รับ";
ws.Cell(5, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(5, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(5, 1).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(5, 1).Style.Font.FontSize = 14;
ws.Cell(5, 1).Style.Alignment.WrapText = true;
ws.Cell(5, 1).Style.Font.SetUnderline(XLFontUnderlineValues.Single);
ws.Range(ws.Cell(5,1),ws.Cell(5,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(5,1),ws.Cell(5,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
foreach (var overallIndicatorsDetail in budgetManagePlan.OverallIndicatorsDetails ?? new List<overall_indicators_detail>())
{
ws.Cell(row, 1).Value = "ผลสัมฤทธิ์: " + overallIndicatorsDetail.indicators_name;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell(row,1).Style.Font.FontName = "TH SarabunPSK";
ws.Cell(row,1).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
row++;
ws.Cell(row, 1).Value = "ตัวชี้วัดภาพรวม: " + overallIndicatorsDetail.indicators_name;
ws.Cell(row, 2).Value = overallIndicatorsDetail.budget_unit_name;
ws.Cell(row, 3).Value = overallIndicatorsDetail.total_1 ?? 0;
ws.Cell(row, 4).Value = overallIndicatorsDetail.total_2 ?? 0;
ws.Cell(row, 5).Value = overallIndicatorsDetail.total_3 ?? 0;
ws.Cell(row, 6).Value = overallIndicatorsDetail.quarter_1_1 ?? 0;
ws.Cell(row, 7).Value = overallIndicatorsDetail.quarter_1_2 ?? 0;
ws.Cell(row, 8).Value = overallIndicatorsDetail.quarter_1_3 ?? 0;
ws.Cell(row, 9).Value = overallIndicatorsDetail.quarter_2_1 ?? 0;
ws.Cell(row, 10).Value = overallIndicatorsDetail.quarter_2_2 ?? 0;
ws.Cell(row, 11).Value = overallIndicatorsDetail.quarter_2_3 ?? 0;
ws.Cell(row, 12).Value = overallIndicatorsDetail.quarter_3_1 ?? 0;
ws.Cell(row, 13).Value = overallIndicatorsDetail.quarter_3_2 ?? 0;
ws.Cell(row, 14).Value = overallIndicatorsDetail.quarter_3_3 ?? 0;
ws.Cell(row, 15).Value = overallIndicatorsDetail.quarter_4_1 ?? 0;
ws.Cell(row, 16).Value = overallIndicatorsDetail.quarter_4_2 ?? 0;
ws.Cell(row, 17).Value = overallIndicatorsDetail.quarter_4_3 ?? 0;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
}
ws.Cell(row, 1).Value = "รวมเงินงบประมาณทั้งสิ้น";
ws.Cell(row, 1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(166, 166, 166);
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
ws.Cell(row, 3).Value = budgetManagePlan.total_all_1 ?? 0;
ws.Cell(row, 4).Value = budgetManagePlan.total_all_2 ?? 0;
ws.Cell(row, 5).Value = budgetManagePlan.total_all_3 ?? 0;
ws.Cell(row, 6).Value = budgetManagePlan.quarter_all_1_1 ?? 0;
ws.Cell(row, 7).Value = budgetManagePlan.quarter_all_1_2 ?? 0;
ws.Cell(row, 8).Value = budgetManagePlan.quarter_all_1_3 ?? 0;
ws.Cell(row, 9).Value = budgetManagePlan.quarter_all_2_1 ?? 0;
ws.Cell(row, 10).Value = budgetManagePlan.quarter_all_2_2 ?? 0;
ws.Cell(row, 11).Value = budgetManagePlan.quarter_all_2_3 ?? 0;
ws.Cell(row, 12).Value = budgetManagePlan.quarter_all_3_1 ?? 0;
ws.Cell(row, 13).Value = budgetManagePlan.quarter_all_3_2 ?? 0;
ws.Cell(row, 14).Value = budgetManagePlan.quarter_all_3_3 ?? 0;
ws.Cell(row, 15).Value = budgetManagePlan.quarter_all_4_1 ?? 0;
ws.Cell(row, 16).Value = budgetManagePlan.quarter_all_4_2 ?? 0;
ws.Cell(row, 17).Value = budgetManagePlan.quarter_all_4_3 ?? 0;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.SetBold().Font.FontName= "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
foreach (var outputProject in budgetManagePlan.OutputProjectLists ?? new List<output_project_list>())
{
foreach (var strategyDetail in outputProject.StrategyDetails ?? new List<strategy_detail>()) //ยุทธศาสตร์ชาติ
{
ws.Cell(row, 1).Value = strategyDetail.strategy_name;
ws.Cell(row, 2).Value = strategyDetail.budget_unit_name;
ws.Cell(row, 3).Value = strategyDetail.total_1?? 0;
ws.Cell(row, 4).Value = strategyDetail.total_2?? 0;
ws.Cell(row, 5).Value = strategyDetail.total_3?? 0;
ws.Cell(row, 6).Value = strategyDetail.quarter_1_1?? 0;
ws.Cell(row, 7).Value = strategyDetail.quarter_1_2?? 0;
ws.Cell(row, 8).Value = strategyDetail.quarter_1_3?? 0;
ws.Cell(row, 9).Value = strategyDetail.quarter_2_1?? 0;
ws.Cell(row, 10).Value = strategyDetail.quarter_2_2?? 0;
ws.Cell(row, 11).Value = strategyDetail.quarter_2_3?? 0;
ws.Cell(row, 12).Value = strategyDetail.quarter_3_1?? 0;
ws.Cell(row, 13).Value = strategyDetail.quarter_3_2?? 0;
ws.Cell(row, 14).Value = strategyDetail.quarter_3_3?? 0;
ws.Cell(row, 15).Value = strategyDetail.quarter_4_1?? 0;
ws.Cell(row, 16).Value = strategyDetail.quarter_4_2?? 0;
ws.Cell(row, 17).Value = strategyDetail.quarter_4_3?? 0;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(220, 230, 241);
row++;
}
foreach (var strategyDetail in outputProject.AllocationStrategyDetails ?? new List<allocation_strategy_detail>())//ยุทธศาสตร์จัดสรร
{
ws.Cell(row, 1).Value = strategyDetail.allocation_strategy_name;
ws.Cell(row, 2).Value = strategyDetail.budget_unit_name;
ws.Cell(row, 3).Value = strategyDetail.total_1?? 0;
ws.Cell(row, 4).Value = strategyDetail.total_2?? 0;
ws.Cell(row, 5).Value = strategyDetail.total_3?? 0;
ws.Cell(row, 6).Value = strategyDetail.quarter_1_1?? 0;
ws.Cell(row, 7).Value = strategyDetail.quarter_1_2?? 0;
ws.Cell(row, 8).Value = strategyDetail.quarter_1_3?? 0;
ws.Cell(row, 9).Value = strategyDetail.quarter_2_1?? 0;
ws.Cell(row, 10).Value = strategyDetail.quarter_2_2?? 0;
ws.Cell(row, 11).Value = strategyDetail.quarter_2_3?? 0;
ws.Cell(row, 12).Value = strategyDetail.quarter_3_1?? 0;
ws.Cell(row, 13).Value = strategyDetail.quarter_3_2?? 0;
ws.Cell(row, 14).Value = strategyDetail.quarter_3_3?? 0;
ws.Cell(row, 15).Value = strategyDetail.quarter_4_1?? 0;
ws.Cell(row, 16).Value = strategyDetail.quarter_4_2?? 0;
ws.Cell(row, 17).Value = strategyDetail.quarter_4_3?? 0;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(218, 238, 243);
row++;
}
foreach (var Detail in outputProject.OutputProjectDetails?? new List<output_project_detail>())
{
int ActivitiesNo = 1;
int SubActivitiesNo = 1;
ws.Cell(row, 1).Value = Detail.output_project_name;
ws.Cell(row, 2).Value = Detail.budget_unit_name;
ws.Cell(row, 3).Value = Detail.total_1?? 0;
ws.Cell(row, 4).Value = Detail.total_2?? 0;
ws.Cell(row, 5).Value = Detail.total_3?? 0;
ws.Cell(row, 6).Value = Detail.quarter_1_1?? 0;
ws.Cell(row, 7).Value = Detail.quarter_1_2?? 0;
ws.Cell(row, 8).Value = Detail.quarter_1_3?? 0;
ws.Cell(row, 9).Value = Detail.quarter_2_1?? 0;
ws.Cell(row, 10).Value = Detail.quarter_2_2?? 0;
ws.Cell(row, 11).Value = Detail.quarter_2_3?? 0;
ws.Cell(row, 12).Value = Detail.quarter_3_1?? 0;
ws.Cell(row, 13).Value = Detail.quarter_3_2?? 0;
ws.Cell(row, 14).Value = Detail.quarter_3_3?? 0;
ws.Cell(row, 15).Value = Detail.quarter_4_1?? 0;
ws.Cell(row, 16).Value = Detail.quarter_4_2?? 0;
ws.Cell(row, 17).Value = Detail.quarter_4_3?? 0;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
foreach (var indicatorsList in Detail.Indicators_list?? new List<indicators_list>())//ตัวชี้วัด +
{
ws.Cell(row, 1).Value = indicatorsList.indicators_list_name;
ws.Cell(row, 2).Value = indicatorsList.budget_unit_name;
ws.Cell(row, 3).Value = indicatorsList.total_1;
ws.Cell(row, 4).Value = indicatorsList.total_2;
ws.Cell(row, 5).Value = indicatorsList.total_3;
ws.Cell(row, 6).Value = indicatorsList.quarter_1_1;
ws.Cell(row, 7).Value = indicatorsList.quarter_1_2;
ws.Cell(row, 8).Value = indicatorsList.quarter_1_3;
ws.Cell(row, 9).Value = indicatorsList.quarter_2_1;
ws.Cell(row, 10).Value = indicatorsList.quarter_2_2;
ws.Cell(row, 11).Value = indicatorsList.quarter_2_3;
ws.Cell(row, 12).Value = indicatorsList.quarter_3_1;
ws.Cell(row, 13).Value = indicatorsList.quarter_3_2;
ws.Cell(row, 14).Value = indicatorsList.quarter_3_3;
ws.Cell(row, 15).Value = indicatorsList.quarter_4_1;
ws.Cell(row, 16).Value = indicatorsList.quarter_4_2;
ws.Cell(row, 17).Value = indicatorsList.quarter_4_3;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
}
ws.Cell(row, 1).Value = "1.แผนการปฎิบัติงาน";
ws.Cell(row, 1).Style.Font.Bold = true;
ws.Cell(row, 1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(171, 204, 239);
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
row++;
ws.Cell(row, 1).Value = "1.1 ตัวชี้วัด :";
ws.Cell(row, 1).Style.Font.Bold = true;
ws.Cell(row, 1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.Gainsboro;
row++;
foreach (var indicatorPlan in Detail.IndicatorPlans?? new List<indicator_plan>())//1.1 ตัวชี้วัด +
{
ws.Cell(row, 1).Value = indicatorPlan.indicator_plan_name;
ws.Cell(row, 2).Value = indicatorPlan.budget_unit_name;
ws.Cell(row, 3).Value = indicatorPlan.total_1;
ws.Cell(row, 4).Value = indicatorPlan.total_2;
ws.Cell(row, 5).Value = indicatorPlan.total_3;
ws.Cell(row, 6).Value = indicatorPlan.quarter_1_1;
ws.Cell(row, 7).Value = indicatorPlan.quarter_1_2;
ws.Cell(row, 8).Value = indicatorPlan.quarter_1_3;
ws.Cell(row, 9).Value = indicatorPlan.quarter_2_1;
ws.Cell(row, 10).Value = indicatorPlan.quarter_2_2;
ws.Cell(row, 11).Value = indicatorPlan.quarter_2_3;
ws.Cell(row, 12).Value = indicatorPlan.quarter_3_1;
ws.Cell(row, 13).Value = indicatorPlan.quarter_3_2;
ws.Cell(row, 14).Value = indicatorPlan.quarter_3_3;
ws.Cell(row, 15).Value = indicatorPlan.quarter_4_1;
ws.Cell(row, 16).Value = indicatorPlan.quarter_4_2;
ws.Cell(row, 17).Value = indicatorPlan.quarter_4_3;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
}
ws.Cell(row, 1).Value = "1.2. กิจกรรมหลัก :";
ws.Cell(row, 1).Style.Font.Bold = true;
ws.Cell(row, 1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.Gainsboro;
row++;
foreach (var budget in Detail.BudgetActivities?? new List<budget_activitie>()) //1.2. กิจกรรมหลัก +
{
ws.Cell(row, 1).Value = $"กิจกรรม {ActivitiesNo}: {budget.budget_activitie_name}";
ws.Cell(row, 1).Style.Font.Bold = true;
ActivitiesNo++;
ws.Cell(row, 2).Value = budget.budget_unit_name;
ws.Cell(row, 3).Value = budget.total_1;
ws.Cell(row, 4).Value = budget.total_2;
ws.Cell(row, 5).Value = budget.total_3;
ws.Cell(row, 6).Value = budget.quarter_1_1;
ws.Cell(row, 7).Value = budget.quarter_1_2;
ws.Cell(row, 8).Value = budget.quarter_1_3;
ws.Cell(row, 9).Value = budget.quarter_2_1;
ws.Cell(row, 10).Value = budget.quarter_2_2;
ws.Cell(row, 11).Value = budget.quarter_2_3;
ws.Cell(row, 12).Value = budget.quarter_3_1;
ws.Cell(row, 13).Value = budget.quarter_3_2;
ws.Cell(row, 14).Value = budget.quarter_3_3;
ws.Cell(row, 15).Value = budget.quarter_4_1;
ws.Cell(row, 16).Value = budget.quarter_4_2;
ws.Cell(row, 17).Value = budget.quarter_4_3;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
}
ws.Cell(row, 1).Value = "2.แผนการใช้จ่ายงบประมาณ";
ws.Cell(row, 1).Style.Font.Bold = true;
ws.Cell(row, 1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(171, 204, 239);
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
row++;
ws.Cell(row, 1).Value = "2.1 งบประมาณ :";
ws.Cell(row, 1).Style.Font.Bold = true;
ws.Cell(row, 1).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center);
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Fill.BackgroundColor = XLColor.Gainsboro;
row++;
foreach (var budgetSpendingPlan in Detail.BudgetSpendingPlans?? new List<budget_spending_plan>())
{
ws.Cell(row, 1).Value = $"{SubActivitiesNo}. {budgetSpendingPlan.budget_spending_plan_name}";
SubActivitiesNo++;
ws.Cell(row, 2).Value = budgetSpendingPlan.budget_unit_name;
ws.Cell(row, 3).Value = budgetSpendingPlan.total_1;
ws.Cell(row, 4).Value = budgetSpendingPlan.total_2;
ws.Cell(row, 5).Value = budgetSpendingPlan.total_3;
ws.Cell(row, 6).Value = budgetSpendingPlan.quarter_1_1;
ws.Cell(row, 7).Value = budgetSpendingPlan.quarter_1_2;
ws.Cell(row, 8).Value = budgetSpendingPlan.quarter_1_3;
ws.Cell(row, 9).Value = budgetSpendingPlan.quarter_2_1;
ws.Cell(row, 10).Value = budgetSpendingPlan.quarter_2_2;
ws.Cell(row, 11).Value = budgetSpendingPlan.quarter_2_3;
ws.Cell(row, 12).Value = budgetSpendingPlan.quarter_3_1;
ws.Cell(row, 13).Value = budgetSpendingPlan.quarter_3_2;
ws.Cell(row, 14).Value = budgetSpendingPlan.quarter_3_3;
ws.Cell(row, 15).Value = budgetSpendingPlan.quarter_4_1;
ws.Cell(row, 16).Value = budgetSpendingPlan.quarter_4_2;
ws.Cell(row, 17).Value = budgetSpendingPlan.quarter_4_3;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
foreach (var sub in budgetSpendingPlan.SubBudgetSpending?? new List<sub_budget_spending_plan>())
{
ws.Cell(row, 1).Value = sub.sub_budget_spending_plan_name;
ws.Cell(row, 2).Value = sub.budget_unit_name;
ws.Cell(row, 3).Value = sub.total_1;
ws.Cell(row, 4).Value = sub.total_2;
ws.Cell(row, 5).Value = sub.total_3;
ws.Cell(row, 6).Value = sub.quarter_1_1;
ws.Cell(row, 7).Value = sub.quarter_1_2;
ws.Cell(row, 8).Value = sub.quarter_1_3;
ws.Cell(row, 9).Value = sub.quarter_2_1;
ws.Cell(row, 10).Value = sub.quarter_2_2;
ws.Cell(row, 11).Value = sub.quarter_2_3;
ws.Cell(row, 12).Value = sub.quarter_3_1;
ws.Cell(row, 13).Value = sub.quarter_3_2;
ws.Cell(row, 14).Value = sub.quarter_3_3;
ws.Cell(row, 15).Value = sub.quarter_4_1;
ws.Cell(row, 16).Value = sub.quarter_4_2;
ws.Cell(row, 17).Value = sub.quarter_4_3;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Font.FontSize = 14;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Range(ws.Cell(row, 3),ws.Cell(row,17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
ws.Range(ws.Cell(row, 2),ws.Cell(row,17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row,1),ws.Cell(row,17)).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.NumberFormat.Format = "#,##0";
row++;
}
}
}
}
}
using (var stream = new MemoryStream())
{
workbook.SaveAs(stream);
var content = stream.ToArray();
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"สงป301" + ".xlsx");
}
}
}
}