diff --git a/Controllers/Budget.Controller.cs b/Controllers/Budget.Controller.cs index beabcc5..7d178a8 100644 --- a/Controllers/Budget.Controller.cs +++ b/Controllers/Budget.Controller.cs @@ -2114,162 +2114,178 @@ namespace rmutr_report.Controllers int r1 = 1; int r2 = 2; var result = new List(); - var res = result.SelectMany(j => j.revenue_estimates_details).Where(t=>t.topic_type==2).ToList(); - var sum1 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.revenue_estimates); - var sum2 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.less_revenue_estimates); - var sum3 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.balance_revenue_estimates); - var sum4 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.less_accumulated_income); - var sum5 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.balance_before_allocating_according); - var sum6 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.contribution_utility_bills); - var sum7 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.contribution_central_budget); - var sum8 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.contribution_central_expenditure); - var sum9 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==3).Sum(d => d.expenditure_limit); - - var _sum1 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.revenue_estimates); - var _sum2 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.less_revenue_estimates); - var _sum3 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.balance_revenue_estimates); - var _sum4 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.less_accumulated_income); - var _sum5 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.balance_before_allocating_according); - var _sum6 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.contribution_utility_bills); - var _sum7 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.contribution_central_budget); - var _sum8 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.contribution_central_expenditure); - var _sum9 = revenue_estimate.revenue_estimates_details.Where(j=>j.topic_type==2).Sum(d => d.expenditure_limit); + var res = result.SelectMany(j => j.revenue_estimates_details).Where(t => t.topic_type == 2).ToList(); + var sum1 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.revenue_estimates); + var sum2 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.less_revenue_estimates); + var sum3 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.balance_revenue_estimates); + var sum4 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.less_accumulated_income); + var sum5 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.balance_before_allocating_according); + var sum6 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.contribution_utility_bills); + var sum7 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.contribution_central_budget); + var sum8 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.contribution_central_expenditure); + var sum9 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 3) + .Sum(d => d.expenditure_limit); + + var _sum1 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.revenue_estimates); + var _sum2 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.less_revenue_estimates); + var _sum3 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.balance_revenue_estimates); + var _sum4 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.less_accumulated_income); + var _sum5 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.balance_before_allocating_according); + var _sum6 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.contribution_utility_bills); + var _sum7 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.contribution_central_budget); + var _sum8 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.contribution_central_expenditure); + var _sum9 = revenue_estimate.revenue_estimates_details.Where(j => j.topic_type == 2) + .Sum(d => d.expenditure_limit); foreach (var detail in revenue_estimate.revenue_estimates_details) { if (detail.topic_type == 1) { - ws.Cell(row, 1).Value = detail.topic; - ws.Cell(row, 2).Value = _sum1;//detail.revenue_estimates; - ws.Cell(row, 3).Value = "บาท"; - ws.Cell(row, 4).Value = _sum2;//detail.less_revenue_estimates; - ws.Cell(row, 5).Value = "บาท"; - ws.Cell(row, 6).Value = _sum3;//detail.balance_revenue_estimates; - ws.Cell(row, 7).Value = "บาท"; - ws.Cell(row, 8).Value = _sum4;//detail.less_accumulated_income; - ws.Cell(row, 9).Value = "บาท"; - ws.Cell(row, 10).Value = _sum5;//detail.balance_before_allocating_according; - ws.Cell(row, 11).Value = "บาท"; - ws.Cell(row, 12).Value = _sum6;//detail.contribution_utility_bills; - ws.Cell(row, 13).Value = "บาท"; - ws.Cell(row, 14).Value = _sum7;//detail.contribution_central_budget; - ws.Cell(row, 15).Value = "บาท"; - ws.Cell(row, 16).Value = _sum8;//detail.contribution_central_expenditure; - ws.Cell(row, 17).Value = "บาท"; - ws.Cell(row, 18).Value = _sum9;//detail.expenditure_limit; - ws.Cell(row, 19).Value = "บาท"; + ws.Cell(row, 1).Value = detail.topic; + ws.Cell(row, 2).Value = _sum1; //detail.revenue_estimates; + ws.Cell(row, 3).Value = "บาท"; + ws.Cell(row, 4).Value = _sum2; //detail.less_revenue_estimates; + ws.Cell(row, 5).Value = "บาท"; + ws.Cell(row, 6).Value = _sum3; //detail.balance_revenue_estimates; + ws.Cell(row, 7).Value = "บาท"; + ws.Cell(row, 8).Value = _sum4; //detail.less_accumulated_income; + ws.Cell(row, 9).Value = "บาท"; + ws.Cell(row, 10).Value = _sum5; //detail.balance_before_allocating_according; + ws.Cell(row, 11).Value = "บาท"; + ws.Cell(row, 12).Value = _sum6; //detail.contribution_utility_bills; + ws.Cell(row, 13).Value = "บาท"; + ws.Cell(row, 14).Value = _sum7; //detail.contribution_central_budget; + ws.Cell(row, 15).Value = "บาท"; + ws.Cell(row, 16).Value = _sum8; //detail.contribution_central_expenditure; + ws.Cell(row, 17).Value = "บาท"; + ws.Cell(row, 18).Value = _sum9; //detail.expenditure_limit; + ws.Cell(row, 19).Value = "บาท"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = - "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = - XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = - XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal = - XLAlignmentHorizontalValues.Right; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = - XLColor.FromArgb(252, 228, 214); + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Right; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = + XLColor.FromArgb(252, 228, 214); - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - row++; - + row++; } if (detail.topic_type == 2) { - ws.Cell(row, 1).Value = detail.topic; - ws.Cell(row, 2).Value = sum1;//detail.revenue_estimates; - ws.Cell(row, 3).Value = "บาท"; - ws.Cell(row, 4).Value = sum2;//detail.less_revenue_estimates; - ws.Cell(row, 5).Value = "บาท"; - ws.Cell(row, 6).Value = sum3;//detail.balance_revenue_estimates; - ws.Cell(row, 7).Value = "บาท"; - ws.Cell(row, 8).Value = sum4;//detail.less_accumulated_income; - ws.Cell(row, 9).Value = "บาท"; - ws.Cell(row, 10).Value = sum5;//detail.balance_before_allocating_according; - ws.Cell(row, 11).Value = "บาท"; - ws.Cell(row, 12).Value = sum6;//detail.contribution_utility_bills; - ws.Cell(row, 13).Value = "บาท"; - ws.Cell(row, 14).Value = sum7;//detail.contribution_central_budget; - ws.Cell(row, 15).Value = "บาท"; - ws.Cell(row, 16).Value = sum8;//detail.contribution_central_expenditure; - ws.Cell(row, 17).Value = "บาท"; - ws.Cell(row, 18).Value = sum9;//detail.expenditure_limit; - ws.Cell(row, 19).Value = "บาท"; + ws.Cell(row, 1).Value = detail.topic; + ws.Cell(row, 2).Value = sum1; //detail.revenue_estimates; + ws.Cell(row, 3).Value = "บาท"; + ws.Cell(row, 4).Value = sum2; //detail.less_revenue_estimates; + ws.Cell(row, 5).Value = "บาท"; + ws.Cell(row, 6).Value = sum3; //detail.balance_revenue_estimates; + ws.Cell(row, 7).Value = "บาท"; + ws.Cell(row, 8).Value = sum4; //detail.less_accumulated_income; + ws.Cell(row, 9).Value = "บาท"; + ws.Cell(row, 10).Value = sum5; //detail.balance_before_allocating_according; + ws.Cell(row, 11).Value = "บาท"; + ws.Cell(row, 12).Value = sum6; //detail.contribution_utility_bills; + ws.Cell(row, 13).Value = "บาท"; + ws.Cell(row, 14).Value = sum7; //detail.contribution_central_budget; + ws.Cell(row, 15).Value = "บาท"; + ws.Cell(row, 16).Value = sum8; //detail.contribution_central_expenditure; + ws.Cell(row, 17).Value = "บาท"; + ws.Cell(row, 18).Value = sum9; //detail.expenditure_limit; + ws.Cell(row, 19).Value = "บาท"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = - "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 14; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = - XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = - XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal = - XLAlignmentHorizontalValues.Right; - //ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(252, 228, 214); + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 14; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Right; + //ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(252, 228, 214); - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - row++; - + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + row++; } if (detail.topic_type == 3) @@ -2357,70 +2373,70 @@ namespace rmutr_report.Controllers } if (detail.topic_type == 4) - { - ws.Cell(row, 1).Value = "รวม"; - ws.Cell(row, 2).Value = _sum1;//detail.revenue_estimates; - ws.Cell(row, 3).Value = "บาท"; - ws.Cell(row, 4).Value = _sum2;//detail.less_revenue_estimates; - ws.Cell(row, 5).Value = "บาท"; - ws.Cell(row, 6).Value = _sum3;//detail.balance_revenue_estimates; - ws.Cell(row, 7).Value = "บาท"; - ws.Cell(row, 8).Value = _sum4;//detail.less_accumulated_income; - ws.Cell(row, 9).Value = "บาท"; - ws.Cell(row, 10).Value = _sum5;//detail.balance_before_allocating_according; - ws.Cell(row, 11).Value = "บาท"; - ws.Cell(row, 12).Value = _sum6;//detail.contribution_utility_bills; - ws.Cell(row, 13).Value = "บาท"; - ws.Cell(row, 14).Value = _sum7;//detail.contribution_central_budget; - ws.Cell(row, 15).Value = "บาท"; - ws.Cell(row, 16).Value = _sum8;//detail.contribution_central_expenditure; - ws.Cell(row, 17).Value = "บาท"; - ws.Cell(row, 18).Value = _sum9;//detail.expenditure_limit; - ws.Cell(row, 19).Value = "บาท"; + { + ws.Cell(row, 1).Value = "รวม"; + ws.Cell(row, 2).Value = _sum1; //detail.revenue_estimates; + ws.Cell(row, 3).Value = "บาท"; + ws.Cell(row, 4).Value = _sum2; //detail.less_revenue_estimates; + ws.Cell(row, 5).Value = "บาท"; + ws.Cell(row, 6).Value = _sum3; //detail.balance_revenue_estimates; + ws.Cell(row, 7).Value = "บาท"; + ws.Cell(row, 8).Value = _sum4; //detail.less_accumulated_income; + ws.Cell(row, 9).Value = "บาท"; + ws.Cell(row, 10).Value = _sum5; //detail.balance_before_allocating_according; + ws.Cell(row, 11).Value = "บาท"; + ws.Cell(row, 12).Value = _sum6; //detail.contribution_utility_bills; + ws.Cell(row, 13).Value = "บาท"; + ws.Cell(row, 14).Value = _sum7; //detail.contribution_central_budget; + ws.Cell(row, 15).Value = "บาท"; + ws.Cell(row, 16).Value = _sum8; //detail.contribution_central_expenditure; + ws.Cell(row, 17).Value = "บาท"; + ws.Cell(row, 18).Value = _sum9; //detail.expenditure_limit; + ws.Cell(row, 19).Value = "บาท"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = - "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = - XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = - XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal = - XLAlignmentHorizontalValues.Right; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = - XLColor.FromArgb(252, 228, 214); + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Right; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = + XLColor.FromArgb(252, 228, 214); - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - row++; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 4).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 6).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 8).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + row++; //} } @@ -2535,7 +2551,7 @@ namespace rmutr_report.Controllers [FromBody] budget_expenditure_report_from_revenue budget) { int no = 1; - + var b = budget.budgets.ToArray(); foreach (var bb in b) { @@ -2548,43 +2564,43 @@ namespace rmutr_report.Controllers { detail2.text1 = "อัตรา"; } - + var cperson = detail.budget_personnel_lists.Count(); - + if (cperson == 1) { detail.budget_personnel_lists[0].topic = "งบบุคลากร"; } - + foreach (var detail3 in detail2.budget_personnel_lists_2) { if (detail3.rate != null) { detail3.text1 = "อัตรา"; } - + int no2 = 1; - + if (detail3.topic != null) { detail3.row_no = no; no++; } - + foreach (var detail4 in detail3.budget_rates) { if (detail4.rate != null) { detail4.text1 = "อัตรา"; } - + int no3 = 1; if (detail4.topic != null) { detail4.row_no = no2; no2++; } - + foreach (var detail5 in detail4.details) { int no4 = 1; @@ -2592,13 +2608,13 @@ namespace rmutr_report.Controllers { detail5.text1 = "อัตรา"; } - + if (detail5.position_level != null) { detail5.row_no = no3; no3++; } - + if (detail5.details2 != null) { foreach (var detail6 in detail5.details2) @@ -2611,10 +2627,10 @@ namespace rmutr_report.Controllers } } } - + if (detail5.details2.Any()) { - if (detail5.details2==null) + if (detail5.details2 == null) { foreach (var detail6 in detail5.details2) { @@ -2635,8 +2651,8 @@ namespace rmutr_report.Controllers } } } - - + + if (cperson == 2) { detail.budget_personnel_lists[0].topic = "งบบุคลากร"; @@ -2654,15 +2670,15 @@ namespace rmutr_report.Controllers } } } - - + + var budgetExpenditure = new List() { budget }; - + Report report = new Report(); report.Load(_setting.report_path + "budget_expenditure_report_from_revenue.frx"); report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue"); report.Prepare(); - + MemoryStream stream = new MemoryStream(); switch (type) { @@ -2671,7 +2687,7 @@ namespace rmutr_report.Controllers report.Export(pdf, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "application/pdf"); - + case "xls": case "xlsx": Excel2007Export excel = new Excel2007Export(); @@ -2684,10 +2700,11 @@ namespace rmutr_report.Controllers "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "budgetExpenditure_" + date + ".xlsx"); } - + return Ok(); } - [SwaggerOperation("แบบฟอร์มสรุปรายจ่าย v2")] + + [SwaggerOperation("แบบฟอร์มสรุปรายจ่าย v2")] [HttpPost, Route("reports/budget_expenditure_report_from_revenue_v2/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetBudgetExpenditureRevenueReport([FromRoute] string type, @@ -2712,32 +2729,30 @@ namespace rmutr_report.Controllers bool startNumbering5 = false; foreach (var indetail in budget.details) { - - if (indetail.topic_type==1) + if (indetail.topic_type == 1) { indetail.topic1 = indetail.topic; indetail.amount1 = indetail.value1; indetail.text1 = "บาท"; - } - if (indetail.topic_type==2) + + if (indetail.topic_type == 2) { indetail.topic2 = indetail.topic; indetail.amount2 = indetail.value2; indetail.text2 = "บาท"; - } - if (indetail.topic_type==3) + + if (indetail.topic_type == 3) { indetail.topic3 = indetail.topic; indetail.amount3 = indetail.value1; indetail.amount4 = indetail.value2; indetail.text3 = "อัตรา"; indetail.text4 = "บาท"; - } - - if (indetail.topic_type==4) + + if (indetail.topic_type == 4) { indetail.topic4 = indetail.topic; indetail.amount5 = indetail.value1; @@ -2746,11 +2761,11 @@ namespace rmutr_report.Controllers indetail.text6 = "บาท"; indetail.row_no1 = no1; no1++; - startNumbering = true; + startNumbering = true; no2 = 1; } - - if (startNumbering && indetail.topic_type==5) + + if (startNumbering && indetail.topic_type == 5) { indetail.topic5 = indetail.topic; indetail.amount7 = indetail.value1; @@ -2758,12 +2773,12 @@ namespace rmutr_report.Controllers indetail.text7 = "อัตรา"; indetail.text8 = "บาท"; indetail.row_no2 = no2; - no2++; - startNumbering2 = true; + no2++; + startNumbering2 = true; no3 = 1; } - if (startNumbering2 &&indetail.topic_type==6) + if (startNumbering2 && indetail.topic_type == 6) { indetail.topic9 = indetail.topic; indetail.topic10 = indetail.qualification; @@ -2774,7 +2789,8 @@ namespace rmutr_report.Controllers indetail.row_no3 = no3; no3++; } - if (indetail.topic_type==8) + + if (indetail.topic_type == 8) { indetail.topic12 = indetail.topic; indetail.amount12 = indetail.value1; @@ -2782,18 +2798,19 @@ namespace rmutr_report.Controllers indetail.row_no5 = no5; no5++; } - if (indetail.topic_type==9) + + if (indetail.topic_type == 9) { - indetail.text13 = "รายการ"; indetail.text14 = "จำนวน"; indetail.text15 = "หน่วยนับ"; indetail.text16 = "ราคาต่อหน่วย"; indetail.text17 = "รวมเงิน"; - numberingtype10 = true; + numberingtype10 = true; no6 = 1; } - if (numberingtype10&&indetail.topic_type==10)// + + if (numberingtype10 && indetail.topic_type == 10) // { indetail.topic13 = indetail.topic; indetail.amount13 = indetail.value1; @@ -2803,17 +2820,18 @@ namespace rmutr_report.Controllers indetail.text19 = "."; indetail.row_no6 = no6; no6++; - } - if (indetail.topic_type==11) + + if (indetail.topic_type == 11) { indetail.topic14 = indetail.topic; indetail.amount16 = indetail.value2; indetail.text20 = "บาท"; - numberingtype13 = true; + numberingtype13 = true; no10 = 1; } - if (indetail.topic_type==12) + + if (indetail.topic_type == 12) { indetail.topic15 = indetail.topic; indetail.amount17 = indetail.value1; @@ -2821,43 +2839,48 @@ namespace rmutr_report.Controllers indetail.text22 = "."; indetail.row_no7 = no7; no7++; - } - if (indetail.topic_type==13)// + + if (indetail.topic_type == 13) // { indetail.topic16 = indetail.topic; indetail.amount18 = indetail.value2; indetail.text23 = "บาท"; - startNumbering3 = true; + startNumbering3 = true; no8 = 1; } - //if (numberingtype13&&indetail.topic_type==13&&indetail.topic=="เงินอุดหนุน ค่าใช้จ่ายโครงการ"||indetail.topic=="ค่าครุภัณฑ์"||indetail.topic=="ค่าที่ดินและสิ่งก่อสร้าง") - if (numberingtype13&&indetail.topic_type==13&&indetail.topic!="ค่าตอบแทน ค่าใช้สอยและค่าวัสดุ"&&indetail.topic!="ค่าใช้จ่ายดำเนินงาน") - { - indetail.row_no10 = no10; - no10++; + + //if (numberingtype13&&indetail.topic_type==13&&indetail.topic=="เงินอุดหนุน ค่าใช้จ่ายโครงการ"||indetail.topic=="ค่าครุภัณฑ์"||indetail.topic=="ค่าที่ดินและสิ่งก่อสร้าง") + if (numberingtype13 && indetail.topic_type == 13 && + indetail.topic != "ค่าตอบแทน ค่าใช้สอยและค่าวัสดุ" && indetail.topic != "ค่าใช้จ่ายดำเนินงาน") + { + indetail.row_no10 = no10; + no10++; } - if (startNumbering3&&indetail.topic_type==14)// + + if (startNumbering3 && indetail.topic_type == 14) // { indetail.topic17 = indetail.topic; indetail.amount19 = indetail.value2; indetail.text24 = "บาท"; - indetail.row_no8 = no8; - no8++; - startNumbering4 = true; - no4 = 1; + indetail.row_no8 = no8; + no8++; + startNumbering4 = true; + no4 = 1; } - if (startNumbering4 &&indetail.topic_type==7&&indetail.is_other==null)// + + if (startNumbering4 && indetail.topic_type == 7 && indetail.is_other == null) // { indetail.topic11 = indetail.topic; indetail.amount11 = indetail.value1; indetail.text11 = "บาท"; indetail.row_no4 = no4; no4++; - startNumbering5 = true; + startNumbering5 = true; no9 = 1; } - if (startNumbering5&&indetail.topic_type==7&&indetail.is_other==true) + + if (startNumbering5 && indetail.topic_type == 7 && indetail.is_other == true) { indetail.topic18 = indetail.topic; indetail.amount20 = indetail.value1; @@ -2869,47 +2892,48 @@ namespace rmutr_report.Controllers } int academic_year_name_th = Convert.ToInt32(budget.academic_year_name_th); - budget.academic_year_1 = (academic_year_name_th-1).ToString(); + budget.academic_year_1 = (academic_year_name_th - 1).ToString(); budget.academic_year_2 = academic_year_name_th.ToString(); - var sum1 = budget.details.Where(f=>f.topic_type==1).Sum(d => d.value1); - var sum2 = budget.details.Where(f=>f.topic_type==2&&f.topic == "รายการบุคลากร").Sum(d => d.value2); - budget.total = sum1+sum2; - + var sum1 = budget.details.Where(f => f.topic_type == 1).Sum(d => d.value1); + var sum2 = budget.details.Where(f => f.topic_type == 2 && f.topic == "รายการบุคลากร").Sum(d => d.value2); + budget.total = sum1 + sum2; + var budgetExpenditure = new List() { budget }; Report report = new Report(); - + MemoryStream stream = new MemoryStream(); - - if (type=="pdf") + + if (type == "pdf") { - report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_v2.frx"); - report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2"); - report.Prepare(); + report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_v2.frx"); + report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2"); + report.Prepare(); PDFExport pdf = new PDFExport(); report.Export(pdf, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "application/pdf"); } - if (type=="xls"||type=="xlsx") - { - report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_excel2_color.frx"); - report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2"); - report.Prepare(); - Excel2007Export excel = new Excel2007Export(); - report.Export(excel, stream); - stream.Seek(0, SeekOrigin.Begin); - string date = DateTime.Now.ToString("yyyyMMddHHmmss"); - return File( - stream, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "budgetExpenditureV2_" + date + ".xlsx"); + if (type == "xls" || type == "xlsx") + { + report.Load(_setting.report_path + "budget_expenditure_report_from_revenue_excel2_color.frx"); + report.RegisterData(budgetExpenditure, "budget_expenditure_report_from_revenue_v2"); + report.Prepare(); + + Excel2007Export excel = new Excel2007Export(); + report.Export(excel, stream); + stream.Seek(0, SeekOrigin.Begin); + string date = DateTime.Now.ToString("yyyyMMddHHmmss"); + return File( + stream, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "budgetExpenditureV2_" + date + ".xlsx"); } - + return Ok(); } - + [SwaggerOperation("สรุปงบประมาณแผนปฏิบัติราชการประจำปี")] [HttpPost, Route("reports/summary_government_budget_plan/{type}")] @@ -3508,13 +3532,13 @@ namespace rmutr_report.Controllers return Ok(); } + [SwaggerOperation("สรุปงบประมาณรายจ่าย")] [HttpPost, Route("reports/summary_budget_expense/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetBudgetSummaryExpenseReport([FromRoute] string type, [FromBody] summary_budget_expense budget) { - var summaryBudget = new List() { budget }; Report report = new Report(); @@ -3544,13 +3568,14 @@ namespace rmutr_report.Controllers return Ok(); } + [SwaggerOperation("ประมาณการรายรับ รายจ่าย")] [HttpPost, Route("reports/estimate_income_expenses/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetBudgetEstimateReport([FromRoute] string type, [FromBody] estimate_income_expenses budget) { - var summaryBudget = new List() { budget }; + var summaryBudget = new List() { budget }; Report report = new Report(); report.Load(_setting.report_path + "estimate_income_expenses.frx"); @@ -3579,13 +3604,13 @@ namespace rmutr_report.Controllers return Ok(); } + [SwaggerOperation("สรุปรายรับ และการจัดสรร")] [HttpPost, Route("reports/summary_income_allocation/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetBudgetAllocationReport([FromRoute] string type, [FromBody] estimate_income_expenses budget) { - var summaryBudget = new List() { budget }; Report report = new Report(); @@ -3615,10 +3640,12 @@ namespace rmutr_report.Controllers return Ok(); } - [SwaggerOperation("รวมทุกแผน")] + + [SwaggerOperation("รวมทุกแผน")] [HttpPost, Route("reports/request_summary_all_plans/{type}")] [ApiExplorerSettings(GroupName = "reports")] - public IActionResult GetRequestSummaryAllReport([FromRoute] string type, [FromBody] request_summary requestSummary) + public IActionResult GetRequestSummaryAllReport([FromRoute] string type, + [FromBody] request_summary requestSummary) { var workbook = new XLWorkbook(); var ws = workbook.Worksheets.Add("Sheet1"); @@ -3634,455 +3661,501 @@ namespace rmutr_report.Controllers ws.Column(10).Width = 20; ws.Column(11).Width = 20; ws.Column(12).Width = 20; - - - ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. "+requestSummary.budget_year+" (คำขอ)"; + + + ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + requestSummary.budget_year + " (คำขอ)"; ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; ws.Cell("A1").Style.Font.FontSize = 10; ws.Cell("A2").Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์"; ws.Cell("A2").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; ws.Cell("A2").Style.Font.FontSize = 10; - + int col = 2; int cols = 2; int rowheads = 3; int rowhead = 4; int rowvalue = 5; int row = 6; - + int rowno = 1; - - if (requestSummary != null) + + if (requestSummary != null) + { + var countbudgetplan = requestSummary.plans.Count; + if (countbudgetplan == 1) { - var countbudgetplan = requestSummary.plans.Count; - if (countbudgetplan==1) + foreach (var i in requestSummary.plans) { - foreach (var i in requestSummary.plans) - { - ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; - ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; - ws.Cell(4, 2).Value = i.budget_plan_name; - ws.Cell(5, 2).Value = i.value??0; - ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin; - ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(4, 2).Style.Font.FontSize = 10; - ws.Cell(4, 2).Style.Alignment.WrapText = true; - ws.Cell("A3").Style.Alignment.WrapText = true; - ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell("A3").Style.Font.FontSize = 10; - ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(3, 2).Style.Font.FontSize = 10; - ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(3, 2).Style.Alignment.WrapText = true; - ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(4, 2).Style.Font.FontSize = 10; - ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - - ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(5, 2).Style.Font.FontSize = 10; - ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(5, 2).Style.Alignment.WrapText = true; - } + ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; + ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; + ws.Cell(4, 2).Value = i.budget_plan_name; + ws.Cell(5, 2).Value = i.value ?? 0; + ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(4, 2).Style.Font.FontSize = 10; + ws.Cell(4, 2).Style.Alignment.WrapText = true; + ws.Cell("A3").Style.Alignment.WrapText = true; + ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell("A3").Style.Font.FontSize = 10; + ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(3, 2).Style.Font.FontSize = 10; + ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(3, 2).Style.Alignment.WrapText = true; + ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(4, 2).Style.Font.FontSize = 10; + ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - foreach (var detail in requestSummary.data_1) - { - - ws.Cell(row, 1).Value = detail.rowno + detail.list; - foreach (var budgetPlan in detail.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = - XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = - XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = - "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = - XLColor.FromArgb(204, 153, 255); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - - foreach (var detail2 in detail.data_2) - { - if (detail2.color=="1" && detail2.is_bold==true) - { - ws.Cell(row, 1).Value = detail2.list; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - } - if (detail2.color=="2" && detail2.is_bold==null) - { - ws.Cell(row, 1).Value = detail2.list; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor =XLColor.FromArgb(255, 204, 153); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - } - if (detail2.color=="3" && detail2.is_bold==null) - { - ws.Cell(row, 1).Value = detail2.rowno + detail2.list; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - } - if (detail2.color==null && detail2.is_bold==null) - { - ws.Cell(row, 1).Value = detail2.rowno + detail2.list; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - // ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - } - foreach (var detail3 in detail2.data_3) - { - if (detail3.is_bold==true) - { - ws.Cell(row, 1).Value = detail3.rowno+detail3.list; - foreach (var budgetPlan in detail3.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - } - - } - } - - } - - + ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(5, 2).Style.Font.FontSize = 10; + ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(5, 2).Style.Alignment.WrapText = true; } - - if (countbudgetplan>1) - { - foreach (var i in requestSummary.plans) - { - - ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Merge().Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; - ws.Cell(rowhead, col).Value = i.budget_plan_name; - ws.Cell(rowvalue, col).Value = i.value??0; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style - .Border - .OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.WrapText = true; - ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin; - ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(rowhead, col).Style.Font.FontSize = 10; - ws.Cell(rowhead, col).Style.Alignment.WrapText = true; - ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell("A3").Style.Alignment.WrapText = true; - ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell("A3").Style.Font.FontSize = 10; - ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(rowvalue, col).Style.Font.FontSize = 10; - ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(rowvalue, col).Style.Alignment.WrapText = true; - ws.Cell(rowheads, col).Style.Alignment.WrapText = true; - col++; - } - - foreach (var detail in requestSummary.data_1) + foreach (var detail in requestSummary.data_1) + { + ws.Cell(row, 1).Value = detail.rowno + detail.list; + foreach (var budgetPlan in detail.plans) { - int col2 = 2; - ws.Cell(row, 1).Value = detail.rowno + detail.list; - // int col2 = 2; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = - XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = - XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = - "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = - XLColor.FromArgb(204, 153, 255); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - foreach (var budgetPlan in detail.plans) + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; + } + + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(204, 153, 255); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; + + foreach (var detail2 in detail.data_2) + { + if (detail2.color == "1" && detail2.is_bold == true) { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255); - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, cols).Style.Alignment.WrapText = true; - - col2++; + ws.Cell(row, 1).Value = detail2.list; + foreach (var budgetPlan in detail2.plans) + { + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; + } + + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(153, 204, 255); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; } - row++; - - foreach (var detail2 in detail.data_2) + + if (detail2.color == "2" && detail2.is_bold == null) { - if (detail2.color=="1" && detail2.is_bold==true)//ฟ้า + ws.Cell(row, 1).Value = detail2.list; + foreach (var budgetPlan in detail2.plans) { - ws.Cell(row, 1).Value = detail2.list; - - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.WrapText = true; - - col2 = 2; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255); - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - } - // col2++; - row++; - + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; } - if (detail2.color=="2" && detail2.is_bold==null)//ส้ม + + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(255, 204, 153); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; + } + + if (detail2.color == "3" && detail2.is_bold == null) + { + ws.Cell(row, 1).Value = detail2.rowno + detail2.list; + foreach (var budgetPlan in detail2.plans) { - ws.Cell(row, 1).Value = detail2.list; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor =XLColor.FromArgb(255, 204, 153); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.WrapText = true; - col2 = 2; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153); - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - - } - //col2++; - row++; - + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; } - if (detail2.color=="3" && detail2.is_bold==null)//เหลือง + + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(255, 255, 204); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; + } + + if (detail2.color == null && detail2.is_bold == null) + { + ws.Cell(row, 1).Value = detail2.rowno + detail2.list; + foreach (var budgetPlan in detail2.plans) { - ws.Cell(row, 1).Value = detail2.rowno + detail2.list; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.WrapText =true; - col2 = 2; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204); - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - - } - // col2++; - row++; - + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; } - if (detail2.color==null && detail2.is_bold==null) + + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Left; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + // ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; + } + + foreach (var detail3 in detail2.data_3) + { + if (detail3.is_bold == true) { - ws.Cell(row, 1).Value = detail2.rowno + detail2.list; - + ws.Cell(row, 1).Value = detail3.rowno + detail3.list; + foreach (var budgetPlan in detail3.plans) + { + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; + } + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontSize = 10; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); ws.Cell(row, 1).Style.Alignment.WrapText = true; - col2 = 2; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - - } - //col2++; + ws.Cell(row, 2).Style.Alignment.WrapText = true; row++; - - } - foreach (var detail3 in detail2.data_3) - { - // if (detail3.is_bold==true) - // { - ws.Cell(row, 1).Value = detail3.rowno+detail3.list; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.WrapText = true; - col2 = 2; - foreach (var budgetPlan in detail3.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - } - // col2++; - row++; - - //} - } } - + } + } + } + + if (countbudgetplan > 1) + { + foreach (var i in requestSummary.plans) + { + ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Merge().Value = + "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; + ws.Cell(rowhead, col).Value = i.budget_plan_name; + ws.Cell(rowvalue, col).Value = i.value ?? 0; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style + .Border + .OutsideBorder = XLBorderStyleValues.Thin; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Alignment + .Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Alignment + .Vertical = XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Font + .FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Font + .FontSize = 10; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Fill + .BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Alignment + .WrapText = true; + + ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(rowhead, col).Style.Font.FontSize = 10; + ws.Cell(rowhead, col).Style.Alignment.WrapText = true; + ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("A3").Style.Alignment.WrapText = true; + ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell("A3").Style.Font.FontSize = 10; + ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(rowvalue, col).Style.Font.FontSize = 10; + ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(rowvalue, col).Style.Alignment.WrapText = true; + ws.Cell(rowheads, col).Style.Alignment.WrapText = true; + col++; + } + + foreach (var detail in requestSummary.data_1) + { + int col2 = 2; + ws.Cell(row, 1).Value = detail.rowno + detail.list; + // int col2 = 2; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(204, 153, 255); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + foreach (var budgetPlan in detail.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255); + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, cols).Style.Alignment.WrapText = true; + + col2++; } - + row++; + + foreach (var detail2 in detail.data_2) + { + if (detail2.color == "1" && detail2.is_bold == true) //ฟ้า + { + ws.Cell(row, 1).Value = detail2.list; + + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(153, 204, 255); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + + col2 = 2; + foreach (var budgetPlan in detail2.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(153, 204, 255); + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + // col2++; + row++; + } + + if (detail2.color == "2" && detail2.is_bold == null) //ส้ม + { + ws.Cell(row, 1).Value = detail2.list; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Left; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(255, 204, 153); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + col2 = 2; + foreach (var budgetPlan in detail2.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 153); + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + //col2++; + row++; + } + + if (detail2.color == "3" && detail2.is_bold == null) //เหลือง + { + ws.Cell(row, 1).Value = detail2.rowno + detail2.list; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Left; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(255, 255, 204); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + col2 = 2; + foreach (var budgetPlan in detail2.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 204); + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + // col2++; + row++; + } + + if (detail2.color == null && detail2.is_bold == null) + { + ws.Cell(row, 1).Value = detail2.rowno + detail2.list; + + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontSize = 10; + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + col2 = 2; + foreach (var budgetPlan in detail2.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + //col2++; + row++; + } + + foreach (var detail3 in detail2.data_3) + { + // if (detail3.is_bold==true) + // { + ws.Cell(row, 1).Value = detail3.rowno + detail3.list; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + col2 = 2; + foreach (var budgetPlan in detail3.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + // col2++; + row++; + + //} + } + } } - } + } + } + using (var stream = new MemoryStream()) { workbook.SaveAs(stream); @@ -4093,6 +4166,7 @@ namespace rmutr_report.Controllers "all_plans" + ".xlsx"); } } + // [SwaggerOperation("รวมทุกแผน")] // [HttpPost, Route("reports/request_summary_all_plans/{type}")] // [ApiExplorerSettings(GroupName = "reports")] @@ -4574,7 +4648,8 @@ namespace rmutr_report.Controllers [SwaggerOperation("แผนบูรณาการแผนยุทธศาสตร์")] [HttpPost, Route("reports/request_summary_integrated_strategic/{type}")] [ApiExplorerSettings(GroupName = "reports")] - public IActionResult GetRequestSummary2Report([FromRoute] string type, [FromBody] request_summary requestSummary) + public IActionResult GetRequestSummary2Report([FromRoute] string type, + [FromBody] request_summary requestSummary) { var workbook = new XLWorkbook(); var ws = workbook.Worksheets.Add("Sheet1"); @@ -4590,7 +4665,7 @@ namespace rmutr_report.Controllers ws.Column(10).Width = 20; ws.Column(11).Width = 20; ws.Column(12).Width = 20; - ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. "+requestSummary.budget_year+" (คำขอ)"; + ws.Cell("A1").Value = "งบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + requestSummary.budget_year + " (คำขอ)"; ws.Cell("A1").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; ws.Cell("A1").Style.Font.FontSize = 10; ws.Cell("A2").Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์"; @@ -4602,66 +4677,91 @@ namespace rmutr_report.Controllers int rowhead = 4; int rowvalue = 5; int row = 6; - + int rowno = 1; - - if (requestSummary != null) + + if (requestSummary != null) + { + var countbudgetplan = requestSummary.plans.Count; + if (countbudgetplan == 1) { - var countbudgetplan = requestSummary.plans.Count; - if (countbudgetplan==1) + foreach (var i in requestSummary.plans) { - foreach (var i in requestSummary.plans) + ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; + ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; + ws.Cell(4, 2).Value = i.budget_plan_name; + ws.Cell(5, 2).Value = i.value ?? 0; + ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(4, 2).Style.Font.FontSize = 10; + ws.Cell(4, 2).Style.Alignment.WrapText = true; + ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("A3").Style.Alignment.WrapText = true; + ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell("A3").Style.Font.FontSize = 10; + ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(3, 2).Style.Font.FontSize = 10; + ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(3, 2).Style.Alignment.WrapText = true; + ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(4, 2).Style.Font.FontSize = 10; + ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(5, 2).Style.Font.FontSize = 10; + ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(5, 2).Style.Alignment.WrapText = true; + } + + foreach (var detail in requestSummary.data_1) + { + ws.Cell(row, 1).Value = detail.rowno + detail.list; + foreach (var budgetPlan in detail.plans) { - ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; - ws.Cell(3, 2).Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; - ws.Cell(4, 2).Value = i.budget_plan_name; - ws.Cell(5, 2).Value = i.value??0; - ws.Cell(4, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(4, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin; - ws.Cell(4, 2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(4, 2).Style.Font.FontSize = 10; - ws.Cell(4, 2).Style.Alignment.WrapText = true; - ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell("A3").Style.Alignment.WrapText = true; - ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell("A3").Style.Font.FontSize = 10; - ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(3, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(3, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(3, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(3, 2).Style.Font.FontSize = 10; - ws.Cell(3, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(3, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(3, 2).Style.Alignment.WrapText = true; - ws.Cell(4, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(4, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(4, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(4, 2).Style.Font.FontSize = 10; - ws.Cell(4, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(5, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(5, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(5, 2).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(5, 2).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(5, 2).Style.Font.FontSize = 10; - ws.Cell(5, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(5, 2).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; } - foreach (var detail in requestSummary.data_1) - { + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(204, 153, 255); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; - ws.Cell(row, 1).Value = detail.rowno + detail.list; - foreach (var budgetPlan in detail.plans) + foreach (var detail2 in detail.data_2) + { + ws.Cell(row, 1).Value = detail2.rowno + detail2.list; + foreach (var budgetPlan in detail2.plans) { - ws.Cell(row, 2).Value = budgetPlan.value??0; + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; } - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(5, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = + XLAlignmentHorizontalValues.Left; ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = @@ -4669,133 +4769,144 @@ namespace rmutr_report.Controllers ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = - XLColor.FromArgb(204, 153, 255); ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); ws.Cell(row, 1).Style.Alignment.WrapText = true; ws.Cell(row, 2).Style.Alignment.WrapText = true; row++; - - foreach (var detail2 in detail.data_2) + + foreach (var detail3 in detail2.data_3) { - ws.Cell(row, 1).Value = detail2.rowno + detail2.list; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - - foreach (var detail3 in detail2.data_3) + ws.Cell(row, 1).Value = detail3.rowno + detail3.list; + foreach (var budgetPlan in detail3.plans) { - - ws.Cell(row, 1).Value = detail3.rowno+detail3.list; - foreach (var budgetPlan in detail3.plans) - { - ws.Cell(row, 2).Value = budgetPlan.value??0; - } - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 2).Style.Alignment.WrapText = true; - row++; - - + ws.Cell(row, 2).Value = budgetPlan.value ?? 0; } + + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, 1).Style.Alignment.WrapText = true; + ws.Cell(row, 2).Style.Alignment.WrapText = true; + row++; } - } - - } - - if (countbudgetplan>1) - { - foreach (var i in requestSummary.plans) - { - - ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Merge().Value = "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; - ws.Cell(rowhead, col).Value = i.budget_plan_name; - ws.Cell(rowvalue, col).Value = i.value??0; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style - .Border - .OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads , cols+ countbudgetplan - 1)).Style.Alignment.WrapText = true; + } - ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin; - ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(rowhead, col).Style.Font.FontSize = 10; - ws.Cell(rowhead, col).Style.Alignment.WrapText = true; - ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell("A3").Style.Alignment.WrapText = true; - ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell("A3").Style.Font.FontSize = 10; - ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); - ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Cell(rowvalue, col).Style.Font.FontSize = 10; - ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(rowvalue, col).Style.Alignment.WrapText = true; - col++; - } - - foreach (var detail in requestSummary.data_1) + if (countbudgetplan > 1) + { + foreach (var i in requestSummary.plans) + { + ws.Range("A3:A5").Merge().Value = "งบรายจ่าย"; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Merge().Value = + "งบประมาณ " + requestSummary.budget_year + " (คำขอ)"; + ws.Cell(rowhead, col).Value = i.budget_plan_name; + ws.Cell(rowvalue, col).Value = i.value ?? 0; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style + .Border + .OutsideBorder = XLBorderStyleValues.Thin; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Alignment + .Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Alignment + .Vertical = XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Font + .FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Font + .FontSize = 10; + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Fill + .BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Range(ws.Cell(rowheads, cols), ws.Cell(rowheads, cols + countbudgetplan - 1)).Style.Alignment + .WrapText = true; + + ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(rowhead, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin; + ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(rowhead, col).Style.Font.FontSize = 10; + ws.Cell(rowhead, col).Style.Alignment.WrapText = true; + ws.Cell(rowhead, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell("A3").Style.Alignment.WrapText = true; + ws.Cell("A3").Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell("A3").Style.Font.FontSize = 10; + ws.Range("A3:A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range("A3:A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(rowvalue, col).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(rowvalue, col).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); + ws.Cell(rowvalue, col).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; + ws.Cell(rowvalue, col).Style.Font.FontSize = 10; + ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(rowvalue, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(rowvalue, col).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(rowvalue, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(rowvalue, col).Style.Alignment.WrapText = true; + col++; + } + + foreach (var detail in requestSummary.data_1) + { + int col2 = 2; + ws.Cell(row, 1).Value = detail.rowno + detail.list; + // int col2 = 2; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = + "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = + XLColor.FromArgb(204, 153, 255); + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + foreach (var budgetPlan in detail.plans) { - int col2 = 2; - ws.Cell(row, 1).Value = detail.rowno + detail.list; - // int col2 = 2; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = - XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255); + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + row++; + + foreach (var detail2 in detail.data_2) + { + ws.Cell(row, 1).Value = detail2.rowno + detail2.list; + + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Fill.BackgroundColor = - XLColor.FromArgb(204, 153, 255); - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Alignment.WrapText = true; - foreach (var budgetPlan in detail.plans) + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + col2 = 2; + foreach (var budgetPlan in detail2.plans) { - ws.Cell(row, col2).Value = budgetPlan.value??0; + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 153, 255); ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; @@ -4804,73 +4915,44 @@ namespace rmutr_report.Controllers ws.Cell(row, col2).Style.Alignment.WrapText = true; col2++; } - row++; - - foreach (var detail2 in detail.data_2) - { - ws.Cell(row, 1).Value =detail2.rowno + detail2.list; - - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.SetBold().Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Cell(row, 1).Style.Alignment.WrapText = true; - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - col2 = 2; - foreach (var budgetPlan in detail2.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.SetBold().Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - } - - row++; - - - - foreach (var detail3 in detail2.data_3) - { - - ws.Cell(row, 1).Value = detail3.rowno+detail3.list; - ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; - ws.Cell(row,2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontName = "TH SarabunPSK"; - ws.Range(ws.Cell(row, 1),ws.Cell(row,2)).Style.Font.FontSize = 10; - ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, 1).Style.Alignment.WrapText = true; - col2 = 2; - foreach (var budgetPlan in detail3.plans) - { - ws.Cell(row, col2).Value = budgetPlan.value??0; - ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; - ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; - ws.Cell(row, col2).Style.Font.FontSize = 10; - ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; - ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); - ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; - ws.Cell(row, col2).Style.Alignment.WrapText = true; - col2++; - - } - row++; - } - } - - } - + row++; + + + foreach (var detail3 in detail2.data_3) + { + ws.Cell(row, 1).Value = detail3.rowno + detail3.list; + ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; + ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Vertical = + XLAlignmentVerticalValues.Center; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Border.OutsideBorder = + XLBorderStyleValues.Thin; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontName = "TH SarabunPSK"; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Font.FontSize = 10; + ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, 1).Style.Alignment.WrapText = true; + col2 = 2; + foreach (var budgetPlan in detail3.plans) + { + ws.Cell(row, col2).Value = budgetPlan.value ?? 0; + ws.Cell(row, col2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; + ws.Cell(row, col2).Style.Font.FontName = "TH SarabunPSK"; + ws.Cell(row, col2).Style.Font.FontSize = 10; + ws.Cell(row, col2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; + ws.Cell(row, col2).Style.NumberFormat.SetFormat("#,#0"); + ws.Cell(row, col2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; + ws.Cell(row, col2).Style.Alignment.WrapText = true; + col2++; + } + + row++; + } + } } - } + } + using (var stream = new MemoryStream()) { workbook.SaveAs(stream); @@ -4881,14 +4963,18 @@ 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) + 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.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; @@ -4900,17 +4986,18 @@ namespace rmutr_report.Controllers ws.Range("N2:Q2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; var range = ws.Range("A3:A4"); range.Merge(); - range.Value = "ยุทธศาสตร์ชาติ - แผนแม่บทภายใต้ยุทธศาสตร์ชาติ - แผนย่อยของแผนแม่บทฯ ยุทธศาสตร์จัดสรร - แผนงาน - เป้าประสงค์เชิงยุทธศาสตร์ เป้าหมายการให้บริการกระทรวง - เป้าหมายการให้บริการหน่วยงาน ผลผลิต/โครงการ - กิจกรรม"; + range.Value = + "ยุทธศาสตร์ชาติ - แผนแม่บทภายใต้ยุทธศาสตร์ชาติ - แผนย่อยของแผนแม่บทฯ ยุทธศาสตร์จัดสรร - แผนงาน - เป้าประสงค์เชิงยุทธศาสตร์ เป้าหมายการให้บริการกระทรวง - เป้าหมายการให้บริการหน่วยงาน ผลผลิต/โครงการ - กิจกรรม"; range.Style.Alignment.WrapText = true; ws.Row(3).Height = 50; - ws.Row(4).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("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; @@ -4918,7 +5005,7 @@ namespace rmutr_report.Controllers 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("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; @@ -4926,7 +5013,7 @@ namespace rmutr_report.Controllers 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("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; @@ -4934,7 +5021,7 @@ namespace rmutr_report.Controllers 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("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; @@ -4942,7 +5029,7 @@ namespace rmutr_report.Controllers 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("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; @@ -4950,7 +5037,7 @@ namespace rmutr_report.Controllers 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("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; @@ -4958,7 +5045,7 @@ namespace rmutr_report.Controllers 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.Range("O3:Q3").Merge().Style.Fill.BackgroundColor = XLColor.FromArgb(217, 217, 217); ws.Cell("C4").Value = "แผน(ขั้น พ.ร.บ.)"; ws.Cell("D4").Value = "แผน(ขั้น บริหาร)"; ws.Cell("E4").Value = "ผล"; @@ -4981,12 +5068,12 @@ namespace rmutr_report.Controllers 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("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; @@ -5004,409 +5091,471 @@ namespace rmutr_report.Controllers 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()) - { - 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()) - { - foreach (var strategyDetail in outputProject.StrategyDetails ?? new List()) //ยุทธศาสตร์ชาติ - { - 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); + int row = 6; - row++; - } - foreach (var strategyDetail in outputProject.AllocationStrategyDetails ?? new List())//ยุทธศาสตร์จัดสรร - { - 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; + 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()) + { + 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.Center; + 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.Center; + 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()) + { + int ActivitiesNo = 1; + int SubActivitiesNo = 1; + foreach (var strategyDetail in + outputProject.StrategyDetails ?? new List()) //ยุทธศาสตร์ชาติ + { + 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(218, 238, 243); + 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.Center; + 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 Detail in outputProject.OutputProjectDetails?? new List()) - { - 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())//ตัวชี้วัด + - { - 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())//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()) //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++; + } + + foreach (var strategyDetail in outputProject.AllocationStrategyDetails ?? + new List()) //ยุทธศาสตร์จัดสรร + { + 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.Center; + 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()) + { + 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.Center; + 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 + outputProject.Indicators_list ?? new 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.Center; 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++; + } + + if ((outputProject.IndicatorPlans != null && outputProject.IndicatorPlans.Any()) || + (outputProject.BudgetActivities != null && outputProject.BudgetActivities.Any())) + { + 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 + outputProject.IndicatorPlans ?? new List()) //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.Center; + 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++; + } + + if (outputProject.BudgetActivities != null && outputProject.BudgetActivities.Any()) + { + 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 + outputProject.BudgetActivities ?? new List()) //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.Center; + 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++; + } + + if (outputProject.BudgetSpendingPlans != null && outputProject.BudgetSpendingPlans.Any()) + { + 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 outputProject.BudgetSpendingPlans ?? + new List()) + { + 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.Center; + 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()) + { + 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.Center; + 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++; + } + } + } + } - 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()) - { - - - 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()) - { - 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); @@ -5417,6 +5566,5 @@ namespace rmutr_report.Controllers "สงป301" + ".xlsx"); } } - } } \ No newline at end of file diff --git a/Models/budget/manage_plan_budget.cs b/Models/budget/manage_plan_budget.cs index b412b9f..7ff96e9 100644 --- a/Models/budget/manage_plan_budget.cs +++ b/Models/budget/manage_plan_budget.cs @@ -70,12 +70,16 @@ public class manage_plan_budget public List StrategyDetails { get; set; } public List AllocationStrategyDetails { get; set; } public List OutputProjectDetails { get; set; } - + public List Indicators_list { get; set; }//ตัวชี้วัด + public List IndicatorPlans { get; set; } //1.แผนการปฎิบัติงาน 1.1 ตัวชี้วัด + public List BudgetActivities { get; set; } //1.2. กิจกรรมหลัก + public List BudgetSpendingPlans { get; set; } //2.แผนการใช้จ่ายงบประมาณ } public class strategy_detail { public string strategy_name { get; set; } public int? type { get; set; } + public int? order { get; set; } public string budget_unit_name { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } @@ -107,6 +111,7 @@ public class manage_plan_budget { public string allocation_strategy_name { get; set; } public int? type { get; set; } + public int? order { get; set; } public string budget_unit_name { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } @@ -138,6 +143,7 @@ public class manage_plan_budget { public string output_project_name { get; set; } public string budget_unit_name { get; set; } + public int? order { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } public decimal? total_3 { get; set; } @@ -162,17 +168,14 @@ public class manage_plan_budget public decimal? quarter_4_1 { get; set; } public decimal? quarter_4_2 { get; set; } public decimal? quarter_4_3 { get; set; } - public List Indicators_list { get; set; }//ตัวชี้วัด - public List IndicatorPlans { get; set; } //1.แผนการปฎิบัติงาน 1.1 ตัวชี้วัด - public List BudgetActivities { get; set; } //1.2. กิจกรรมหลัก - public List BudgetSpendingPlans { get; set; } //2.แผนการใช้จ่ายงบประมาณ + } public class indicators_list { public string indicators_list_name { get; set; } public int? indicators_type { get; set; } //1. ตัวชี้วัดเชิงคุณภาพ 2. ตัวชี้วัดเชิงปริมาณ 3. ตัวชี้วัดเชิงเวลา - + public int? order { get; set; } public string budget_unit_name { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } @@ -203,6 +206,7 @@ public class manage_plan_budget { public string indicator_plan_name { get; set; } public int? indicators_type { get; set; } //1. ตัวชี้วัดเชิงคุณภาพ 2. ตัวชี้วัดเชิงปริมาณ 3. ตัวชี้วัดเชิงเวลา + public int? order { get; set; } public string budget_unit_name { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } @@ -234,6 +238,7 @@ public class manage_plan_budget { public string budget_activitie_name { get; set; } public string budget_unit_name { get; set; } + public int? order { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } public decimal? total_3 { get; set; } @@ -266,6 +271,7 @@ public class manage_plan_budget { public string budget_spending_plan_name { get; set; } public string budget_unit_name { get; set; } + public int? order { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } public decimal? total_3 { get; set; } @@ -299,6 +305,7 @@ public class manage_plan_budget public string sub_budget_spending_plan_name { get; set; } public string budget_unit_name { get; set; } + public int? order { get; set; } public decimal? total_1 { get; set; } public decimal? total_2 { get; set; } public decimal? total_3 { get; set; } diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.dll b/bin/Debug/netcoreapp3.1/rmutr_report.dll index d05b1c5..a5f5874 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.dll and b/bin/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.pdb b/bin/Debug/netcoreapp3.1/rmutr_report.pdb index 0009869..afae505 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.pdb and b/bin/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs b/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs index 0b44c6b..b980e45 100644 --- a/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs +++ b/obj/Debug/net5.0/rmutr_report.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+12da4e1939919124e2fa33e3f0042250bd26b203")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+731803e190ea53557a64d88396c00747647072c2")] [assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache b/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache index b3ae789..d397546 100644 --- a/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache +++ b/obj/Debug/net5.0/rmutr_report.AssemblyInfoInputs.cache @@ -1 +1 @@ -05ec1291166972c4e81d91c397f63ed5180e8549f12a9f1b81a6e37736a2b6c2 +bd75c1302a8f97c93b2b9e2834d328fc2a22862a414e94dadde3a2c3fd6624b6 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs index 0b44c6b..b980e45 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs +++ b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+12da4e1939919124e2fa33e3f0042250bd26b203")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+731803e190ea53557a64d88396c00747647072c2")] [assembly: System.Reflection.AssemblyProductAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyTitleAttribute("rmutr_report")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache index b3ae789..d397546 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.AssemblyInfoInputs.cache @@ -1 +1 @@ -05ec1291166972c4e81d91c397f63ed5180e8549f12a9f1b81a6e37736a2b6c2 +bd75c1302a8f97c93b2b9e2834d328fc2a22862a414e94dadde3a2c3fd6624b6 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache b/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache index 35b630d..5ff3c51 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.RazorTargetAssemblyInfo.cache @@ -1 +1 @@ -3282571f3aaad087370b963afc8333e1479c897b11aab5684c6fc3015052c2b9 +3a591009b2d71b3c8825c407d6b9be74bdd44d77c0c015d55d961232a3f0f9a4 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index d05b1c5..a5f5874 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.dll and b/obj/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.pdb b/obj/Debug/netcoreapp3.1/rmutr_report.pdb index 0009869..afae505 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.pdb and b/obj/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/rider.project.model.nuget.info b/obj/rider.project.model.nuget.info index 907f170..e3cd1f2 100644 --- a/obj/rider.project.model.nuget.info +++ b/obj/rider.project.model.nuget.info @@ -1 +1 @@ -17399449009804555 \ No newline at end of file +17401183874467534 \ No newline at end of file diff --git a/obj/rider.project.restore.info b/obj/rider.project.restore.info index e4aeed2..90ece7c 100644 --- a/obj/rider.project.restore.info +++ b/obj/rider.project.restore.info @@ -1 +1 @@ -17400274795180319 \ No newline at end of file +17401239669095019 \ No newline at end of file