using System; using System.Collections.Generic; using System.IO; using ClosedXML.Excel; using FastReport; using FastReport.Export.OoXML; using FastReport.Export.Pdf; using Microsoft.AspNetCore.Mvc; using rmutr_report.Models; using Swashbuckle.AspNetCore.Annotations; namespace rmutr_report.Controllers { [SwaggerTag("สำหรับรายงานงบแผ่นดิน")] public class governmentBudget : Controller { readonly Setting _setting; public governmentBudget(Setting setting) { this._setting = setting; } [HttpPost, Route("reports/receive_government/{type}")] //รับเงินแผ่นดิน [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetGovernmentBudgetReport([FromRoute] string type, [FromBody] receive_government receiveGovernments) { var governments = new List() { receiveGovernments }; Report report = new Report(); report.Load(_setting.report_path + "receive_government.frx"); report.RegisterData(governments, "receive_government"); report.Prepare(); MemoryStream stream = new MemoryStream(); switch (type) { case "pdf": PDFExport pdf = new PDFExport(); report.Export(pdf, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "application/pdf"); case "xls": case "xlsx": Excel2007Export excel = new Excel2007Export(); report.Export(excel, stream); stream.Seek(0, SeekOrigin.Begin); //return File(stream, "application/vnd.ms-excel"); string date = DateTime.Now.ToString("yyyyMMddHHmmss"); return File( stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "receive_government_" + date + ".xlsx"); case "doc": case "docx": Word2007Export word = new Word2007Export(); report.Export(word, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); } return Ok(); } [HttpPost, Route("reports/budget_government_allocate/{type}")] // (พื้นฐาน+ยุทธศาตร์) [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetInStrAllocateReport([FromRoute] string type, [FromBody] budget_government_allocate allocate) { var workbook = new XLWorkbook(); var ws = workbook.Worksheets.Add("การจัดสรรงบประมาณแผ่นดิน"); ws.Range("A1:S1").Merge().Value = "การจัดสรรงบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + allocate.budget_year + " (" + allocate.report_name + ")";//" (แผนงาน พื้นฐาน และ แผนงาน ยุทธศาสตร์ฯ)"; ws.Range("A1:S1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A1:S1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A1:S1").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A1:S1").Style.Font.FontSize = 16; ws.Range("A1:S1").Style.Font.Bold = true; ws.Range("A2:S2").Merge().Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์"; ws.Range("A2:S2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A2:S2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A2:S2").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A2:S2").Style.Font.FontSize = 16; ws.Range("A2:S2").Style.Font.Bold = true; ws.Column(1).Width = 40; ws.Column(2).Width = 15; ws.Column(3).Width = 15; ws.Column(4).Width = 15; ws.Column(5).Width = 15; ws.Column(6).Width = 15; ws.Column(7).Width = 15; ws.Column(8).Width = 15; ws.Column(9).Width = 15; ws.Column(10).Width = 15; ws.Column(11).Width = 15; ws.Column(12).Width = 15; ws.Column(13).Width = 15; ws.Column(14).Width = 15; ws.Column(15).Width = 15; ws.Column(16).Width = 15; ws.Column(17).Width = 15; ws.Column(18).Width = 15; ws.Column(19).Width = 15; int row = 8; //int no = 1; ws.Cell("A3").Value = "แผนงาน / ผลผลิต / กิจกรรม"; ws.Cell("A3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("A3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("A3").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("A3").Style.Font.SetBold().Font.FontSize = 16; //ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("A5").Value = "หน่วยงาน"; ws.Cell("A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("A5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("A5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("A5").Style.Alignment.WrapText = true; ws.Range("B3:E4").Merge().Value = "งบบุคลากร"; ws.Range("B3:E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("B3:E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("B3:E4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("B3:E4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("B3:E4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("B5").Value = "เงินเดือน"; ws.Cell("B5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("B5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("B5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("B5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("B5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("C5").Value = "ค่าจ้างประจำ"; ws.Cell("C5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("C5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("C5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("C5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("C5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("D5").Value = "ค่าจ้างชั่วคราว"; ws.Cell("D5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("D5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("D5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("D5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("D5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("E5").Value = "พนักงานราชการ"; ws.Cell("E5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("E5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("E5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("E5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("E5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("F3:I4").Merge().Value = "งบดำเนินงาน"; ws.Range("F3:I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("F3:I4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("F3:I4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("F3:I4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("F3:I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("F5").Value = "ค่าตอบแทน"; ws.Cell("F5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("F5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("F5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("F5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("F5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("G5").Value = "ค่าใช้สอย"; ws.Cell("G5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("G5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("G5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("G5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("G5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("H5").Value = "ค่าวัสดุ"; ws.Cell("H5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("H5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("H5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("H5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("H5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("I5").Value = "ค่าสาธารณูปโภค"; ws.Cell("I5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("I5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("I5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("I5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("I5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("J3:K4").Merge().Value = "งบลงทุน"; ws.Range("J3:K4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("J3:K4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("J3:K4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("J3:K4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("J3:K4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("J5").Value = "ค่าครุภัณฑ์"; ws.Cell("J5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("J5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("J5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("J5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("J5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("K5").Value = "ที่ดิน สิ่งก่อสร้าง"; ws.Cell("K5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("K5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("K5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("K5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("K5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("L3:R3").Merge().Value = "งบเงินอุดหนุน"; ws.Range("L3:R3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("L3:R3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("L3:R3").Style.Font.FontName = "TH SarabunPSK"; ws.Range("L3:R3").Style.Font.SetBold().Font.FontSize = 16; ws.Range("L3:R3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("L4:L5").Merge().Value = "เงินอุดหนุนค่าใช้จ่ายบุคลากร"; ws.Range("L4:L5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("L4:L5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("L4:L5").Style.Font.FontName = "TH SarabunPSK"; ws.Range("L4:L5").Style.Font.SetBold().Font.FontSize = 16; ws.Range("L4:L5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("M4:M5").Merge().Value = "เงินอุดหนุนค่าใช้จ่ายโครงการ"; ws.Range("M4:M5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("M4:M5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("M4:M5").Style.Font.FontName = "TH SarabunPSK"; ws.Range("M4:M5").Style.Font.SetBold().Font.FontSize = 16; ws.Range("M4:M5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("N4:R4").Merge().Value = "ค่าใช้จ่ายดำเนินงาน"; ws.Range("N4:R4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("N4:R4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("N4:R4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("N4:R4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("N4:R4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("N5").Value = "ค่าตอบแทน"; ws.Cell("N5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("N5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("N5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("N5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("N5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("O5").Value = "ค่าใช้สอย"; ws.Cell("O5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("O5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("O5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("O5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("O5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("P5").Value = "ค่าวัสดุ"; ws.Cell("P5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("P5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("P5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("P5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("P5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("Q5").Value = "ค่าสาธารณูปโภค"; ws.Cell("Q5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("Q5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("Q5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("Q5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("Q5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("R5").Value = "ค่าใช้จ่ายดำเนินงานอื่นๆ"; ws.Cell("R5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("R5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("R5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("R5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("R5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("S3").Value = "รวมทั้งสิ้น"; ws.Cell("S3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("S3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("S3").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("S3").Style.Font.SetBold().Font.FontSize = 16; ws.Range("S3:S5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("A6:A7").Merge().Value = "รวมทั้งสิ้น"; ws.Range("A6:A7").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A6:A7").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A6:A7").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A6:A7").Style.Font.SetBold().Font.FontSize = 16; ws.Range("A6:A7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("B6:E6").Merge().Value = allocate.total_budget_personnel; ws.Range("F6:I6").Merge().Value = allocate.total_budget_operating; ws.Range("J6:K6").Merge().Value = allocate.total_budget_investment; ws.Cell("L6").Value = allocate.total_personnel_expense; ws.Cell("M6").Value = allocate.total_project_expense; ws.Range("N6:Q6").Merge().Value = allocate.total_operating_expenses; ws.Cell("R6").Value = allocate.total_other_operating_expenses; ws.Cell("S6").Value = allocate.total_budget; ws.Range("B6:E6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("F6:I6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("J6:K6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("N6:Q6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("L6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("M6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("R6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("S6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 255); ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Font.SetBold().Font.FontSize = 16; //ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontColor = XLColor.Blue; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.NumberFormat.SetFormat("#,#"); ws.Cell("B7").Value = allocate.salary_person; ws.Cell("C7").Value = allocate.regular_wages_person; ws.Cell("D7").Value = allocate.temporary_wages_person; ws.Cell("E7").Value = allocate.government_employee; ws.Cell("F7").Value = allocate.compensation_operating_budget; ws.Cell("G7").Value = allocate.cost_operating_budget; ws.Cell("H7").Value = allocate.material_cost_operating_budget; ws.Cell("I7").Value = allocate.utility_bill_operating_budget; ws.Cell("J7").Value = allocate.cost_equipment; ws.Cell("K7").Value = allocate.land_building; ws.Cell("N7").Value = allocate.compensation_operating_expenses; ws.Cell("O7").Value = allocate.cost_operating_expenses; ws.Cell("P7").Value = allocate.material_cost_operating_expenses; ws.Cell("Q7").Value = allocate.utility_bill_operating_expenses; ws.Cell("B7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("C7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("D7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("E7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("F7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("G7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("H7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("I7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("J7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("K7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("N7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("O7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("P7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("Q7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("S7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(3, 1), ws.Cell(5, 19)).Style.Alignment.WrapText = true; foreach (var detail in allocate.data_1) { if (detail.color == 1) // แผนงาน สีเหลือง { ws.Range(ws.Cell(row, 1), ws.Cell(row + 1, 1)).Merge().Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 183); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 2) // โครงการ สีฟ้าอ่อน { ws.Cell(row, 1).Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(218, 238, 243); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 3) // ชื่อคณะ สีแดงอ่อน { ws.Range(ws.Cell(row, 1), ws.Cell(row + 1, 1)).Merge().Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 204); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 5) // ชื่อคณะ สีขาว { ws.Cell(row, 1).Value = "'- " + detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 4) // ชื่อย่อยคณะ สีเทาอ่อน { ws.Range(ws.Cell(row, 1), ws.Cell(row + 1, 1)).Merge().Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(237, 235, 249); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 6) // ชื่อย่อยคณะ+พื้นที่ สีขาว { ws.Cell(row, 1).Value = "'- " + detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } foreach (var detail2 in detail.data_2) { if (detail2.color == 1) //สีเหลือง { ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 183); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 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; row++; } if (detail2.color == 2) // ชื่อกิจกรรม สีฟ้าอ่อน { ws.Cell(row, 1).Value = detail2.list; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(218, 238, 243); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Font.FontColor = XLColor.Red; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 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; row++; } if (detail2.color == 3) // ชื่อคณะ สีแดงอ่อน { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 204); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 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; row++; } if (detail2.color == 5) // ชื่อคณะ สีขาว detail { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.TopBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 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; row++; } if (detail2.color == 4) // ชื่อย่อยคณะ สีเทาอ่อน { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(237, 235, 249); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 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; row++; } if (detail2.color == 6) // ชื่อย่อยคณะ+พื้นที่ สีขาว detail { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; 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, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.TopBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 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; row++; } } } using (var stream1 = new MemoryStream()) { workbook.SaveAs(stream1); var content = stream1.ToArray(); return File( content, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "budget_government_allocate" + ".xlsx"); } } } }