using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using ClosedXML.Excel; using FastReport; using FastReport.Export.Csv; using FastReport.Export.Mht; using FastReport.Export.OoXML; using FastReport.Export.Pdf; using Microsoft.AspNetCore.Mvc; using rmutr_report.Models; using rmutr_report.Models.RoThree; using Swashbuckle.AspNetCore.Annotations; namespace rmutr_report.Controllers { [SwaggerTag("สำหรับรายงาน ร.(คำของบประมาณรายจ่ายจากเงินรายได้)")] public class Ro : Controller { readonly Setting _setting; public Ro(Setting setting) { this._setting = setting; } [SwaggerOperation("ร5. คำชี้แจงงบลงทุน ค่าที่ดินและสิ่งก่อสร้าง")] [HttpPost, Route("reports/ro_five/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetRoFiveReport([FromRoute] string type, [FromBody] ro_five building_fours) { foreach (var a in building_fours.building_type) { if (a.usage_per_target != null) { var a1 = a.usage_per_target.Where(d => d.used_year == d.used_year) .Sum(o => o.used_year); building_fours.sum_year1 = a1; var a2 = a.usage_per_target.Where(d => d.year1 == d.year1) .Sum(o => o.year1); building_fours.sum_year2 = a2; var a3 = a.usage_per_target.Where(d => d.year2 == d.year2) .Sum(o => o.year2); building_fours.sum_year3 = a3; var a4 = a.usage_per_target.Where(d => d.year3 == d.year3) .Sum(o => o.year3); building_fours.sum_year4 = a4; var a5 = a.usage_per_target.Where(d => d.year4 == d.year4) .Sum(o => o.year4); building_fours.sum_year5 = a5; var a6 = a.usage_per_target.Where(d => d.year5 == d.year5) .Sum(o => o.year5); building_fours.sum_year6 = a6; } } // foreach (var bb in building_fours.material_construction_labor1) // { // if (bb != null) // { // bb.total_amount = bb.material_cost + bb.labor_unit; // var f = building_fours.material_construction_labor1.Where(d => d.total_amount == d.total_amount) // .Sum(o => o.total_amount); // building_fours.material_total_amount1 = f; // } // } // foreach (var bb in building_fours.material_construction_labor2) // { // if (bb != null) // { // bb.total_amount = bb.material_cost + bb.labor_unit; // var f = building_fours.material_construction_labor2.Where(d => d.total_amount == d.total_amount) // .Sum(o => o.total_amount); // building_fours.material_total_amount2 = f; // } // } // foreach (var bb in building_fours.material_construction_labor3) // { // if (bb != null) // { // bb.total_amount = bb.material_cost + bb.labor_unit; // var f = building_fours.material_construction_labor3.Where(d => d.total_amount == d.total_amount) // .Sum(o => o.total_amount); // building_fours.material_total_amount3 = f; // } // } foreach (var cc in building_fours.budget_limit) { if (cc != null) { var a = building_fours.budget_limit.Where(d => d.amount == d.amount) .Sum(o => o.amount); building_fours.amount = a; if (cc.outside_amount != null) { var b = building_fours.budget_limit.Where(d => d.outside_amount == d.outside_amount) .Sum(o => o.outside_amount); building_fours.outside_amount = b; } if (cc.outside_amount == null) { building_fours.outside_amount = null; } if (cc.amount != null && cc.outside_amount != null) { cc.total_amount = cc.amount + cc.outside_amount; } var c = building_fours.budget_limit.Where(d => d.total_amount == d.total_amount) .Sum(o => o.total_amount); building_fours.total_amount = c; } } foreach (var boqPrice in building_fours.basic_information) { if (boqPrice.list != null) { string str = boqPrice.list; string num = String.Concat(str.Where(c => c >= '0' && c <= '9')); if (num.Length == 4) { for (int i = 1; i <= num.Length - 1; i += 4) { boqPrice.list = num.Insert(i, ","); } } else if (num.Length == 5) { for (int i = 2; i <= num.Length - 1; i += 5) { boqPrice.list = num.Insert(i, ","); } } else if (num.Length == 6) { for (int i = 3; i <= num.Length - 1; i += 6) { boqPrice.list = num.Insert(i, ","); } } else if (num.Length == 7) { for (int i = 1, j = 5; i <= num.Length - 1; i += 7, j += 7) { boqPrice.list = num.Insert(i, ",").Insert(j, ","); } } else if (num.Length == 8) { for (int i = 2, j = 6; i <= num.Length - 1; i += 8, j += 8) { boqPrice.list = num.Insert(i, ",").Insert(j, ","); } } if (boqPrice.list == "20000000.0000") { boqPrice.list = "20,000,000"; } } } foreach (var boqPrice in building_fours.boq) { if (boqPrice.is_data == "1") { string str = boqPrice.have; if (str.Length == 4) { for (int i = 1; i <= str.Length - 1; i += 4) { boqPrice.have = str.Insert(i, ","); } } else if (str.Length == 5) { for (int i = 2; i <= str.Length - 1; i += 5) { boqPrice.have = str.Insert(i, ","); } } else if (str.Length == 6) { for (int i = 3; i <= str.Length - 1; i += 6) { boqPrice.have = str.Insert(i, ","); } } else if (str.Length == 7) { for (int i = 1, j = 5; i <= str.Length - 1; i += 7, j += 7) { boqPrice.have = str.Insert(i, ",").Insert(j, ","); } } else if (str.Length == 8) { for (int i = 2, j = 6; i <= str.Length - 1; i += 8, j += 8) { boqPrice.have = str.Insert(i, ",").Insert(j, ","); } } // if (boqPrice.have == "10000000") // { // boqPrice.have = "10,000,000"; // } boqPrice.text1 = "- มี วงเงิน " + boqPrice.have + " บาท"; boqPrice.text2 = "- ดำเนินการจัดทำ BOQ เดือน " + boqPrice.pending_boq_month; boqPrice.text3 = "- BOQ แล้วเสร็จเดือน " + boqPrice.done_boq_month; boqPrice.text4 = "- ขออนุมัติ BOQ เดือน " + boqPrice.approval_month; boqPrice.text5 = "- ทำสัญญาก่อสร้าง เดือน " + boqPrice.construction_contract_month; } if (boqPrice.is_data == "2") { boqPrice.text1 = "- ไม่มี"; boqPrice.text2 = "- กรณีไม่มีคาดว่าจะแล้วเสร็จ เดือน " + boqPrice.months + " ปี " + boqPrice.years; boqPrice.text3 = "- ขณะนี้อยูในขั้นตอน " + boqPrice.step; } } var _budget_summary_report = new List() { building_fours }; Report report = new Report(); report.Load(_setting.report_path + "ro_five.frx"); report.RegisterData(_budget_summary_report, "ro_five"); 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", date + ".xlsx"); break; case "doc": case "docx": Word2007Export word = new Word2007Export(); report.Export(word, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); break; } return Ok(); } [SwaggerOperation("ร8. ประมาณการรายรับจากงานวิจัยภายนอก")] [HttpPost, Route("reports/external_research/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetExReport([FromRoute] string type, [FromBody] external_research external) { var s1 = external.data.Sum(g => g.budget_1); var s2 = external.data.Sum(g => g.budget_2); var s3 = external.data.Sum(g => g.budget_3); var s4 = external.data.Sum(g => g.budget_4); var s5 = external.data.Sum(g => g.budget_5); var s6 = external.data.Sum(g => g.budget_received); var s7 = external.data.Sum(g => g.total_budget); var s8 = external.data.Sum(g => g.expenses); if (s1 != null && s2 != null && s3 != null && s4 != null && s5 != null) { external.project_amount = s6; external.total_1 = s6; //external.total_8 = s7; external.total_2 = s8; external.total_3 = s1; external.total_4 = s2; external.total_5 = s3; external.total_6 = s4; external.total_7 = s5; } CultureInfo culture = new CultureInfo("th-TH"); if (external.data_date != null) { external.data_day = external.data_date.Value.ToString("dd", culture); external.data_month = external.data_date.Value.ToString("MMMM", culture); external.data_year = external.data_date.Value.ToString("yyyy", culture); } if (external.data_date == null) { external.data_day = ""; external.data_month = ""; external.data_year = ""; } if (external.data != null) { foreach (var data in external.data) { data.total_budget = data.budget_1 + data.budget_2 + data.budget_3 + data.budget_4 + data.budget_5; var ss = external.data.Sum(y => y.total_budget); external.institutional_subsidy_fee = ss; external.total_8 = external.institutional_subsidy_fee; } } var _budget_summary_report = new List() { external }; Report report = new Report(); report.Load(_setting.report_path + "external_research.frx"); report.RegisterData(_budget_summary_report, "external_research"); 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"); break; 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", date + ".xlsx"); break; } return Ok(); } [SwaggerOperation("ร9. ประมาณการรายรับจากงานบริการวิชาการ")] [HttpPost, Route("reports/ro_nine/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetNineReport([FromRoute] string type, [FromBody] ro_nine external) { var s1 = external.data.Sum(g => g.budget_1); var s2 = external.data.Sum(g => g.budget_2); var s3 = external.data.Sum(g => g.budget_3); var s4 = external.data.Sum(g => g.budget_4); var s5 = external.data.Sum(g => g.budget_5); var s6 = external.data.Sum(g => g.budget_received); var s7 = external.data.Sum(g => g.total_budget); var s8 = external.data.Sum(g => g.expenses); if (s1 != null && s2 != null && s3 != null && s4 != null && s5 != null) { external.total_1 = s6; //external.total_8 = s7; external.total_2 = s8; external.total_3 = s1; external.total_4 = s2; external.total_5 = s3; external.total_6 = s4; external.total_7 = s5; } CultureInfo culture = new CultureInfo("th-TH"); if (external.data_date != null) { external.data_day = external.data_date.Value.ToString("dd", culture); external.data_month = external.data_date.Value.ToString("MMMM", culture); external.data_year = external.data_date.Value.ToString("yyyy", culture); } if (external.data_date == null) { external.data_day = ""; external.data_month = ""; external.data_year = ""; } if (external.data != null) { foreach (var data in external.data) { data.total_budget = data.budget_1 + data.budget_2 + data.budget_3 + data.budget_4 + data.budget_5; var ss = external.data.Sum(y => y.total_budget); external.total_8 = ss; } } var _budget_summary_report = new List() { external }; Report report = new Report(); report.Load(_setting.report_path + "ro_nine.frx"); report.RegisterData(_budget_summary_report, "ro_nine"); 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"); break; 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", date + ".xlsx"); break; } return Ok(); } [SwaggerOperation("ร10. ประมาณการรายรับจากการบริหารสินทรัพย์ที่ก่อให้เกิดรายได้")] [HttpPost, Route("reports/ro_ten/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetTenReport([FromRoute] string type, [FromBody] ro_ten ten) { var t_ten = ten.data.ToArray(); if (t_ten != null) { // var t1 = ten.data.Sum(g => g.amount_1); // var t2 = ten.data.Sum(g => g.amount_2); // var t3 = ten.data.Sum(g => g.amount_3); // var t2 = t_ten.Sum(g => g.amount_2); // var t3 = t_ten.Sum(g => g.amount_3); foreach (var detail in t_ten) { var s1 = detail.data_detail.Sum(g => g.amount_1); var s2 = detail.data_detail.Sum(g => g.amount_2); var s3 = detail.data_detail.Sum(g => g.amount_3); // var s4 = t_ten.Sum(g => g.amount_1); // var s5 = t_ten.Sum(g => g.amount_2); // var s6 = t_ten.Sum(g => g.amount_3); detail.amount_1 = s1; detail.amount_2 = s2; detail.amount_3 = s3; } } var _budget_summary_report = new List() { ten }; Report report = new Report(); report.Load(_setting.report_path + "ro_ten.frx"); report.RegisterData(_budget_summary_report, "ro_ten"); 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", date + ".xlsx"); break; } return Ok(); } [SwaggerOperation("ร11. ประมาณการรายรับจากรายได้ประเภทอื่น ๆ")] [HttpPost, Route("reports/ro_eleven/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetEleReport([FromRoute] string type, [FromBody] ro_eleven eleven) { var t_eleven = eleven.data.ToArray(); if (t_eleven != null) { var t1 = eleven.data.Sum(g => g.amount_1); var t2 = eleven.data.Sum(g => g.amount_2); var t3 = eleven.data.Sum(g => g.amount_3); eleven.total_amount_1 = t1; eleven.total_amount_2 = t2; eleven.total_amount_3 = t3; } var ele = new List() { eleven }; Report report = new Report(); report.Load(_setting.report_path + "ro_eleven.frx"); report.RegisterData(ele, "ro_eleven"); 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", date + ".xlsx"); break; } return Ok(); } [SwaggerOperation("ร12. ประมาณการรายรับภาคปกติของคณะศิลปศาสตร์จาก ค่าหน่วยกิตที่ลงทะเบียน")] [HttpPost, Route("reports/revenue_estimate_register_credits/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetRegisterCreditsReport([FromRoute] string type, [FromBody] revenue_estimate_register_credits revenueEstimate) { var workbook = new XLWorkbook(); var ws = workbook.Worksheets.Add("ร.12"); ws.Range("A1:R1").Merge().Value = "งบประมาณรายจ่ายจากเงินรายได้ ประจำปีงบประมาณ พ.ศ. " + revenueEstimate.budget_year; ws.Range("A1:R1").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A1:R1").Style.Font.SetBold().Font.FontSize = 22; ws.Range("A1:R1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A2:R2").Merge().Value = "ประมาณการรายรับภาคปกติ ของคณะศิลปศาสตร์ จาก ค่าหน่วยกิตที่ลงทะเบียน ( พื้นที่ " + revenueEstimate.area + " ) " + "จากการจัดการศึกษาให้แก่" + revenueEstimate.faculty + " ภาคเรียนที่ " + revenueEstimate.semester + "/" + revenueEstimate.year; ws.Range("A2:R2").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A2:R2").Style.Font.SetBold().Font.FontSize = 22; ws.Range("A2:R2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A3:C3").Merge().Value = "ประมาณการรายรับจากการจัดการศึกษาด้าน "; ws.Range("A3:C3").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A3:C3").Style.Font.SetBold().Font.FontSize = 22; ws.Range("A3:C3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("D3").Value = "þ"; ws.Cell("D3").Style.Font.Bold = true; ws.Cell("D3").Style.Font.FontName = "Wingdings"; ws.Cell("D3").Style.Font.SetBold().Font.FontSize = 22; ws.Cell("D3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("D3").Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range("E3:M3").Merge().Value = revenueEstimate.budget_project_name_th; ws.Range("E3:M3").Style.Font.FontName = "TH SarabunPSK"; ws.Range("E3:M3").Style.Font.SetBold().Font.FontSize = 22; ws.Range("E3:M3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; ws.Range("E3:M3").Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range("A4:A6").Merge().Value = "ลำดับที่"; ws.Range("A4:A6").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A4:A6").Style.Font.SetBold().Font.FontSize = 16; ws.Range("A4:A6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A4:A6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A4:A6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("B4:B6").Merge().Value = "รหัสวิชา"; ws.Range("B4:B6").Style.Font.SetBold().Font.FontSize = 16; ws.Range("B4:B6").Style.Font.FontName = "TH SarabunPSK"; ws.Range("B4:B6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("B4:B6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("B4:B6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("C4:C6").Merge().Value = "ชื่อรายวิชา"; ws.Range("C4:C6").Style.Font.SetBold().Font.FontSize = 16; ws.Range("C4:C6").Style.Font.FontName = "TH SarabunPSK"; ws.Range("C4:C6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("C4:C6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("C4:C6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Column(1).Width = 10; ws.Column(2).Width = 15; ws.Column(3).Width = 30; // ws.Column(4).Width = 10; // ws.Column(5).Width = 10; // ws.Column(6).Width = 10; // ws.Column(7).Width = 10; // ws.Column(8).Width = 10; // ws.Column(9).Width = 10; // ws.Column(10).Width = 10; // ws.Column(11).Width = 10; // ws.Column(12).Width = 10; // ws.Column(13).Width = 10; // ws.Column(15).Width = 10; // ws.Column(16).Width = 10; // ws.Column(17).Width = 10; // ws.Column(18).Width = 10; // ws.Column(19).Width = 10; // ws.Column(20).Width = 10; // ws.Column(21).Width = 10; // ws.Column(22).Width = 10; // ws.Column(23).Width = 10; // ws.Column(24).Width = 10; // ws.Column(25).Width = 10; // ws.Column(26).Width = 10; // ws.Column(27).Width = 10; // ws.Column(28).Width = 10; // ws.Column(29).Width = 10; // ws.Column(30).Width = 10; ws.Columns("D", "AE").AdjustToContents(); int col = 4; int rowhead = 5; int row = 7; int no = 1; if (revenueEstimate != null) { foreach (var i in revenueEstimate.majors) { //ws.Cell(rowhead, col).Value = i.major_name; ws.Range(ws.Cell(rowhead, col), ws.Cell(rowhead + 1, col)).Merge().Value = i.major_name; ws.Cell(rowhead, col).Style.Alignment.SetTextRotation(90); ws.Cell(rowhead, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(rowhead, col).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell(rowhead, col).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(rowhead, col).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(rowhead, col).Style.Font.FontSize = 16; ws.Range(ws.Cell(rowhead, col), ws.Cell(rowhead + 1, col)).Style.Alignment.WrapText = true; col++; var a = revenueEstimate.majors.Count; if (a == 1) { ws.Range("D4:E4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("E5").Value = "รวม"; ws.Cell("E6").Value = "( 1 )"; ws.Cell("F5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("F6").Value = "( 2 )"; ws.Cell("G5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("G6").Value = "( 3 )"; ws.Cell("H5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("H6").Value = "(4)=(1)x(2)x150"; ws.Cell("I5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("I6").Value = "(5)=(1)x(3)x200"; ws.Cell("J5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("J6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("F5").Style.Alignment.SetTextRotation(90); ws.Cell("G5").Style.Alignment.SetTextRotation(90); ws.Range("F4:J4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 10)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 10)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 10)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 10)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 10)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 10)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:E4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("F4:J4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 10)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 10)).Style.Border.RightBorder = XLBorderStyleValues.Thin; // ws.Cell("D4").Style.Border.RightBorder = XLBorderStyleValues.Thin; // ws.Cell("D4").Style.Border.TopBorder = XLBorderStyleValues.Thin; } if (a == 2) { ws.Range("D4:F4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("F5").Value = "รวม"; ws.Cell("F6").Value = "( 1 )"; ws.Cell("G5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("G6").Value = "( 2 )"; ws.Cell("H5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("H6").Value = "( 3 )"; ws.Cell("I5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("I6").Value = "(4)=(1)x(2)x150"; ws.Cell("J5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("J6").Value = "(5)=(1)x(3)x200"; ws.Cell("K5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("K6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("G5").Style.Alignment.SetTextRotation(90); ws.Cell("H5").Style.Alignment.SetTextRotation(90); ws.Range("G4:K4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 11)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 11)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 11)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 11)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 11)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("G4:K4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 11)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 3) { ws.Range("D4:G4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("G5").Value = "รวม"; ws.Cell("G6").Value = "( 1 )"; ws.Cell("H5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("H6").Value = "( 2 )"; ws.Cell("I5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("I6").Value = "( 3 )"; ws.Cell("J5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("J6").Value = "(4)=(1)x(2)x150"; ws.Cell("K5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("K6").Value = "(5)=(1)x(3)x200"; ws.Cell("L5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("L6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("H5").Style.Alignment.SetTextRotation(90); ws.Cell("I5").Style.Alignment.SetTextRotation(90); ws.Range("H4:L4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 12)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 12)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 12)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 12)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 12)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:G4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("H4:L4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 12)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 12)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 4) { ws.Range("D4:H4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("H5").Value = "รวม"; ws.Cell("H6").Value = "( 1 )"; ws.Cell("I5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("I6").Value = "( 2 )"; ws.Cell("J5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("J6").Value = "( 3 )"; ws.Cell("K5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("K6").Value = "(4)=(1)x(2)x150"; ws.Cell("L5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("L6").Value = "(5)=(1)x(3)x200"; ws.Cell("M5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("M6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("I5").Style.Alignment.SetTextRotation(90); ws.Cell("J5").Style.Alignment.SetTextRotation(90); ws.Range("I4:M4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 13)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 13)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 13)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 13)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 13)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:H4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("I4:M4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 13)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 13)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 5) { ws.Range("D4:I4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("I5").Value = "รวม"; ws.Cell("I6").Value = "( 1 )"; ws.Cell("J5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("J6").Value = "( 2 )"; ws.Cell("K5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("K6").Value = "( 3 )"; ws.Cell("L5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("L6").Value = "(4)=(1)x(2)x150"; ws.Cell("M5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("M6").Value = "(5)=(1)x(3)x200"; ws.Cell("N5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("N6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("J5").Style.Alignment.SetTextRotation(90); ws.Cell("K5").Style.Alignment.SetTextRotation(90); ws.Range("J4:N4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 14)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 14)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 14)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 14)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 14)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("J4:N4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 14)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 14)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 6) { ws.Range("D4:J4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("J5").Value = "รวม"; ws.Cell("J6").Value = "( 1 )"; ws.Cell("K5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("K6").Value = "( 2 )"; ws.Cell("L5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("L6").Value = "( 3 )"; ws.Cell("M5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("M6").Value = "(4)=(1)x(2)x150"; ws.Cell("N5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("N6").Value = "(5)=(1)x(3)x200"; ws.Cell("O5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("O6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("K5").Style.Alignment.SetTextRotation(90); ws.Cell("L5").Style.Alignment.SetTextRotation(90); ws.Range("K4:O4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 15)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 15)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 15)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 15)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 15)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:J4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("K4:O4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 15)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 15)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 7) { ws.Range("D4:K4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("K5").Value = "รวม"; ws.Cell("K6").Value = "( 1 )"; ws.Cell("L5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("L6").Value = "( 2 )"; ws.Cell("M5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("M6").Value = "( 3 )"; ws.Cell("N5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("N6").Value = "(4)=(1)x(2)x150"; ws.Cell("O5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("O6").Value = "(5)=(1)x(3)x200"; ws.Cell("P5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("P6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("L5").Style.Alignment.SetTextRotation(90); ws.Cell("M5").Style.Alignment.SetTextRotation(90); ws.Range("L4:P4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 16)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 16)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 16)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 16)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 16)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:K4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("L4:P4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 16)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 16)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 8) { ws.Range("D4:L4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("L5").Value = "รวม"; ws.Cell("L6").Value = "( 1 )"; ws.Cell("M5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("M6").Value = "( 2 )"; ws.Cell("N5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("N6").Value = "( 3 )"; ws.Cell("O5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("O6").Value = "(4)=(1)x(2)x150"; ws.Cell("P5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("P6").Value = "(5)=(1)x(3)x200"; ws.Cell("Q5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("Q6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("M5").Style.Alignment.SetTextRotation(90); ws.Cell("Q5").Style.Alignment.SetTextRotation(90); ws.Range("M4:Q4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 17)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 17)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 17)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 17)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:L4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("M4:Q4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 17)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 9) { ws.Range("D4:M4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("M5").Value = "รวม"; ws.Cell("M6").Value = "( 1 )"; ws.Cell("N5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("N6").Value = "( 2 )"; ws.Cell("O5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("O6").Value = "( 3 )"; ws.Cell("P5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("P6").Value = "(4)=(1)x(2)x150"; ws.Cell("Q5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("Q6").Value = "(5)=(1)x(3)x200"; ws.Cell("R5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("R6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("N5").Style.Alignment.SetTextRotation(90); ws.Cell("O5").Style.Alignment.SetTextRotation(90); ws.Range("N4:R4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 18)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 18)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 18)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 18)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 18)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:M4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("N4:R4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 18)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 18)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 10) { ws.Range("D4:N4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("N5").Value = "รวม"; ws.Cell("N6").Value = "( 1 )"; ws.Cell("O5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("O6").Value = "( 2 )"; ws.Cell("P5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("P6").Value = "( 3 )"; ws.Cell("Q5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("Q6").Value = "(4)=(1)x(2)x150"; ws.Cell("R5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("R6").Value = "(5)=(1)x(3)x200"; ws.Cell("S5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("S6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("O5").Style.Alignment.SetTextRotation(90); ws.Cell("P5").Style.Alignment.SetTextRotation(90); ws.Range("O4:S4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:N4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("O4:S4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 19)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 11) { ws.Range("D4:O4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("O5").Value = "รวม"; ws.Cell("O6").Value = "( 1 )"; ws.Cell("P5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("P6").Value = "( 2 )"; ws.Cell("Q5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("Q6").Value = "( 3 )"; ws.Cell("R5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("R6").Value = "(4)=(1)x(2)x150"; ws.Cell("S5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("S6").Value = "(5)=(1)x(3)x200"; ws.Cell("T5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("T6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("P5").Style.Alignment.SetTextRotation(90); ws.Cell("Q5").Style.Alignment.SetTextRotation(90); ws.Range("P4:T4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 20)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 20)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 20)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 20)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 20)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:O4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("P4:T4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 20)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 20)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 12) { ws.Range("D4:P4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("P5").Value = "รวม"; ws.Cell("P6").Value = "( 1 )"; ws.Cell("Q5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("Q6").Value = "( 2 )"; ws.Cell("R5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("R6").Value = "( 3 )"; ws.Cell("S5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("S6").Value = "(4)=(1)x(2)x150"; ws.Cell("T5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("T6").Value = "(5)=(1)x(3)x200"; ws.Cell("U5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("U6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("Q5").Style.Alignment.SetTextRotation(90); ws.Cell("R5").Style.Alignment.SetTextRotation(90); ws.Range("Q4:U4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 21)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 21)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 21)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 21)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 21)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:P4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("Q4:U4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 21)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 21)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 13) { ws.Range("D4:Q4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("Q5").Value = "รวม"; ws.Cell("Q6").Value = "( 1 )"; ws.Cell("R5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("R6").Value = "( 2 )"; ws.Cell("S5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("S6").Value = "( 3 )"; ws.Cell("T5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("T6").Value = "(4)=(1)x(2)x150"; ws.Cell("U5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("U6").Value = "(5)=(1)x(3)x200"; ws.Cell("V5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("V6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("Q5").Style.Alignment.SetTextRotation(90); ws.Cell("R5").Style.Alignment.SetTextRotation(90); ws.Range("R4:V4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 22)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 22)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 22)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 22)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 22)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:Q4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("R4:V4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 22)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 22)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 14) { ws.Range("D4:R4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("R5").Value = "รวม"; ws.Cell("R6").Value = "( 1 )"; ws.Cell("S5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("S6").Value = "( 2 )"; ws.Cell("T5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("T6").Value = "( 3 )"; ws.Cell("U5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("U6").Value = "(4)=(1)x(2)x150"; ws.Cell("V5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("V6").Value = "(5)=(1)x(3)x200"; ws.Cell("W5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("W6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("S5").Style.Alignment.SetTextRotation(90); ws.Cell("T5").Style.Alignment.SetTextRotation(90); ws.Range("S4:W4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 23)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 23)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 23)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 23)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 23)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:R4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("S4:W4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 23)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 23)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 15) { ws.Range("D4:S4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("S5").Value = "รวม"; ws.Cell("S6").Value = "( 1 )"; ws.Cell("T5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("T6").Value = "( 2 )"; ws.Cell("U5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("U6").Value = "( 3 )"; ws.Cell("V5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("V6").Value = "(4)=(1)x(2)x150"; ws.Cell("W5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("W6").Value = "(5)=(1)x(3)x200"; ws.Cell("X5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("X6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("T5").Style.Alignment.SetTextRotation(90); ws.Cell("U5").Style.Alignment.SetTextRotation(90); ws.Range("T4:X4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 24)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 24)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 24)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 24)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 24)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:S4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("T4:X4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 24)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 24)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 16) { ws.Range("D4:T4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("T5").Value = "รวม"; ws.Cell("T6").Value = "( 1 )"; ws.Cell("U5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("U6").Value = "( 2 )"; ws.Cell("V5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("V6").Value = "( 3 )"; ws.Cell("W5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("W6").Value = "(4)=(1)x(2)x150"; ws.Cell("X5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("X6").Value = "(5)=(1)x(3)x200"; ws.Cell("Y5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("Y6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("U5").Style.Alignment.SetTextRotation(90); ws.Cell("V5").Style.Alignment.SetTextRotation(90); ws.Range("U4:Y4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 25)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 25)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 25)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 25)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 25)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:T4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("U4:Y4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 25)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 25)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 17) { ws.Range("D4:U4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("U5").Value = "รวม"; ws.Cell("U6").Value = "( 1 )"; ws.Cell("V5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("V6").Value = "( 2 )"; ws.Cell("W5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("W6").Value = "( 3 )"; ws.Cell("X5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("X6").Value = "(4)=(1)x(2)x150"; ws.Cell("Y5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("Y6").Value = "(5)=(1)x(3)x200"; ws.Cell("Z5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("Z6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("U5").Style.Alignment.SetTextRotation(90); ws.Cell("V5").Style.Alignment.SetTextRotation(90); ws.Range("V4:Z4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 26)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 26)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 26)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 26)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 26)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:U4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("V4:Z4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 26)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 26)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 18) { ws.Range("D4:V4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("V5").Value = "รวม"; ws.Cell("V6").Value = "( 1 )"; ws.Cell("W5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("W6").Value = "( 2 )"; ws.Cell("X5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("X6").Value = "( 3 )"; ws.Cell("Y5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("Y6").Value = "(4)=(1)x(2)x150"; ws.Cell("Z5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("Z6").Value = "(5)=(1)x(3)x200"; ws.Cell("AA5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("AA6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("W5").Style.Alignment.SetTextRotation(90); ws.Cell("X5").Style.Alignment.SetTextRotation(90); ws.Range("W4:AA4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 27)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 27)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 27)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 27)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 27)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:V4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("W4:AA4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 27)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 27)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 19) { ws.Range("D4:W4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("W5").Value = "รวม"; ws.Cell("W6").Value = "( 1 )"; ws.Cell("X5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("X6").Value = "( 2 )"; ws.Cell("Y5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("Y6").Value = "( 3 )"; ws.Cell("Z5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("Z6").Value = "(4)=(1)x(2)x150"; ws.Cell("AA5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("AA6").Value = "(5)=(1)x(3)x200"; ws.Cell("AB5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("AB6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("X5").Style.Alignment.SetTextRotation(90); ws.Cell("Y5").Style.Alignment.SetTextRotation(90); ws.Range("X4:AB4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 28)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 28)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 28)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 28)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 28)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:W4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("X4:AB4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 28)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 28)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } if (a == 20) { ws.Range("D4:X4").Merge().Value = "จำนวนนักศึกษาที่ลงทะเบียน"; ws.Cell("X5").Value = "รวม"; ws.Cell("X6").Value = "( 1 )"; ws.Cell("Y5").Value = "จำนวนหน่วยกิตบรรยาย"; ws.Cell("Y6").Value = "( 2 )"; ws.Cell("Z5").Value = "จำนวนหน่วยกิตปฏิบัติ"; ws.Cell("Z6").Value = "( 3 )"; ws.Cell("AA5").Value = "รวมค่าหน่วยกิตบรรยาย"; ws.Cell("AA6").Value = "(4)=(1)x(2)x150"; ws.Cell("AB5").Value = "รวมค่าหน่วยกิตปฏิบัติ"; ws.Cell("AB6").Value = "(5)=(1)x(3)x200"; ws.Cell("AC5").Value = "รวมเงินค่าลงทะเบียนเรียน"; ws.Cell("AC6").Value = "( 6 )=( 4 )+( 5 )"; ws.Cell("Y5").Style.Alignment.SetTextRotation(90); ws.Cell("Z5").Style.Alignment.SetTextRotation(90); ws.Range("Y4:AC4").Merge().Merge().Value = "ค่าลงทะเบียนเรียนภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year; ws.Range(ws.Cell(4, 4), ws.Cell(8, 29)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 29)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(4, 4), ws.Cell(8, 29)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(4, 4), ws.Cell(8, 29)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(4, 5), ws.Cell(8, 29)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(5, 5), ws.Cell(6, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("D4:X4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("Y4:AC4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(4, 4), ws.Cell(4, 29)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(5, 5), ws.Cell(6, 29)).Style.Border.RightBorder = XLBorderStyleValues.Thin; } } } foreach (var header in revenueEstimate.data) { var a = revenueEstimate.majors.Count; int rowhead2 = 4; if (a == 1) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 1).Value = header.total_credits; ws.Cell(row, rowhead2 + 2).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 3).Value = header.practical_credits; ws.Cell(row, rowhead2 + 4).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 5).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 6).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 6)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 6)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; //rowhead2++; } ws.Cell(row, rowhead2 + 1).Value = header.total_credits; ws.Cell(row, rowhead2 + 2).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 3).Value = header.practical_credits; ws.Cell(row, rowhead2 + 4).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 5).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 6).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 6)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, rowhead2 + 6).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Cell(row, rowhead2 + 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, rowhead2 + 6).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2 + 6).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 9)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 10).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 9)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 10).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 2) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 11)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 2).Value = header.total_credits; ws.Cell(row, rowhead2 + 3).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 4).Value = header.practical_credits; ws.Cell(row, rowhead2 + 5).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 6).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 7).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 7)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 7)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 7)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 7)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 7)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 7)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 7)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 7)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 7)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 6).Value = header.total_credits; ws.Cell(row, 7).Value = header.lecture_credits; ws.Cell(row, 8).Value = header.practical_credits; ws.Cell(row, 9).Value = header.total_lecture_credits; ws.Cell(row, 10).Value = header.total_practical_credits; ws.Cell(row, 11).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, rowhead2 + 7).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, rowhead2 + 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, rowhead2 + 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 11).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 11).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 3) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 12)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 3).Value = header.total_credits; ws.Cell(row, rowhead2 + 4).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 5).Value = header.practical_credits; ws.Cell(row, rowhead2 + 6).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 7).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 8).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 8)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 8)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 8)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 8)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 8)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 8)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 8)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 8)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 8)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 7).Value = header.total_credits; ws.Cell(row, 8).Value = header.lecture_credits; ws.Cell(row, 9).Value = header.practical_credits; ws.Cell(row, 10).Value = header.total_lecture_credits; ws.Cell(row, 11).Value = header.total_practical_credits; ws.Cell(row, 12).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 12)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, rowhead2 + 8).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 12)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, rowhead2 + 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 8)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 12).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 12).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 4) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 13)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 4).Value = header.total_credits; ws.Cell(row, rowhead2 + 5).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 6).Value = header.practical_credits; ws.Cell(row, rowhead2 + 7).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 8).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 9).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 9)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 9)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 9)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 9)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 9)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 8)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 9)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 8).Value = header.total_credits; ws.Cell(row, 9).Value = header.lecture_credits; ws.Cell(row, 10).Value = header.practical_credits; ws.Cell(row, 11).Value = header.total_lecture_credits; ws.Cell(row, 12).Value = header.total_practical_credits; ws.Cell(row, 13).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 13)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 13).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 13)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 12)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 13).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 13).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 5) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 14)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 5).Value = header.total_credits; ws.Cell(row, rowhead2 + 6).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 7).Value = header.practical_credits; ws.Cell(row, rowhead2 + 8).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 9).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 10).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 10)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 10)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 10)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 10)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 10)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 10)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 10)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 10)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 10)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 9).Value = header.total_credits; ws.Cell(row, 10).Value = header.lecture_credits; ws.Cell(row, 11).Value = header.practical_credits; ws.Cell(row, 12).Value = header.total_lecture_credits; ws.Cell(row, 13).Value = header.total_practical_credits; ws.Cell(row, 14).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 14)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 14).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 14)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 13)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 14).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 14).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 6) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 15)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 6).Value = header.total_credits; ws.Cell(row, rowhead2 + 7).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 8).Value = header.practical_credits; ws.Cell(row, rowhead2 + 9).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 10).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 11).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 11)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 11)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 11)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 11)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 11)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 11)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 11)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 10).Value = header.total_credits; ws.Cell(row, 11).Value = header.lecture_credits; ws.Cell(row, 12).Value = header.practical_credits; ws.Cell(row, 13).Value = header.total_lecture_credits; ws.Cell(row, 14).Value = header.total_practical_credits; ws.Cell(row, 15).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 15).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 14)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 15).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 15).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 7) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 16)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 7).Value = header.total_credits; ws.Cell(row, rowhead2 + 8).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 9).Value = header.practical_credits; ws.Cell(row, rowhead2 + 10).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 11).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 12).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 12)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 12)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 12)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 12)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 12)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 12)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 12)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 12)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 11).Value = header.total_credits; ws.Cell(row, 12).Value = header.lecture_credits; ws.Cell(row, 13).Value = header.practical_credits; ws.Cell(row, 14).Value = header.total_lecture_credits; ws.Cell(row, 15).Value = header.total_practical_credits; ws.Cell(row, 16).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 16)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 16).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 16)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 16).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 16).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 16).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 16).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 8) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Merge().Value = header.education_level; 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.SetBold().Font.FontSize = 16; 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.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 8).Value = header.total_credits; ws.Cell(row, rowhead2 + 9).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 10).Value = header.practical_credits; ws.Cell(row, rowhead2 + 11).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 12).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 13).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 13)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 13)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 13)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 13)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 13)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 13)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 13)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 13)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 12).Value = header.total_credits; ws.Cell(row, 13).Value = header.lecture_credits; ws.Cell(row, 14).Value = header.practical_credits; ws.Cell(row, 15).Value = header.total_lecture_credits; ws.Cell(row, 16).Value = header.total_practical_credits; ws.Cell(row, 17).Value = header.total_register_amount; 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.SetBold().Font.FontSize = 16; 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, 4), ws.Cell(row, 17)).Style.NumberFormat.SetFormat("#,#"); 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++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 17).Value = header.total_register_amount; 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.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).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.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 17)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 17).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 17).Value = revenueEstimate.total_income; 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.SetBold().Font.FontSize = 16; 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.Cell(row, 17).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 17).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 17).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 9) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 18)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 9).Value = header.total_credits; ws.Cell(row, rowhead2 + 10).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 11).Value = header.practical_credits; ws.Cell(row, rowhead2 + 12).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 13).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 14).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 14)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 14)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 14)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 14)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 14)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 14)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 14)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 14)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 13).Value = header.total_credits; ws.Cell(row, 14).Value = header.lecture_credits; ws.Cell(row, 15).Value = header.practical_credits; ws.Cell(row, 16).Value = header.total_lecture_credits; ws.Cell(row, 17).Value = header.total_practical_credits; ws.Cell(row, 18).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 18)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 18).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 18)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 18).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 17)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 18).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 18).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 18).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 10) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 19)).Merge().Value = header.education_level; 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.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 10).Value = header.total_credits; ws.Cell(row, rowhead2 + 11).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 12).Value = header.practical_credits; ws.Cell(row, rowhead2 + 13).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 14).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 15).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 15)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 15)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 15)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 15)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 15)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 15)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 15)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 15)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 14).Value = header.total_credits; ws.Cell(row, 15).Value = header.lecture_credits; ws.Cell(row, 16).Value = header.practical_credits; ws.Cell(row, 17).Value = header.total_lecture_credits; ws.Cell(row, 18).Value = header.total_practical_credits; ws.Cell(row, 19).Value = header.total_register_amount; 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.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), 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, 1), ws.Cell(row, 19)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 19).Value = header.total_register_amount; 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, 3)).Style.Alignment.WrapText = true; 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.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 19).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 18)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 19).Value = revenueEstimate.total_income; 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.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 19).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 19).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 11) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 20)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 11).Value = header.total_credits; ws.Cell(row, rowhead2 + 12).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 13).Value = header.practical_credits; ws.Cell(row, rowhead2 + 14).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 15).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 16).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 16)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 16)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 16)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 16)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 16)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 16)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 16)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 16)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 15).Value = header.total_credits; ws.Cell(row, 16).Value = header.lecture_credits; ws.Cell(row, 17).Value = header.practical_credits; ws.Cell(row, 18).Value = header.total_lecture_credits; ws.Cell(row, 19).Value = header.total_practical_credits; ws.Cell(row, 20).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 20)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 20).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 20)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 20).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 20).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 20).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 20).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 20).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 20).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 12) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 21)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 12).Value = header.total_credits; ws.Cell(row, rowhead2 + 13).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 14).Value = header.practical_credits; ws.Cell(row, rowhead2 + 15).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 16).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 17).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 17)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 17)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 17)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 17)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 17)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 17)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 17)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 16).Value = header.total_credits; ws.Cell(row, 17).Value = header.lecture_credits; ws.Cell(row, 18).Value = header.practical_credits; ws.Cell(row, 19).Value = header.total_lecture_credits; ws.Cell(row, 20).Value = header.total_practical_credits; ws.Cell(row, 21).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 21)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 21).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 21)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 21).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 21).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 21).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 21).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 21).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 21).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 21).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 13) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 22)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 13).Value = header.total_credits; ws.Cell(row, rowhead2 + 14).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 15).Value = header.practical_credits; ws.Cell(row, rowhead2 + 16).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 17).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 18).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 18)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 18)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 18)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 18)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 18)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 18)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 18)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 18)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 17).Value = header.total_credits; ws.Cell(row, 18).Value = header.lecture_credits; ws.Cell(row, 19).Value = header.practical_credits; ws.Cell(row, 20).Value = header.total_lecture_credits; ws.Cell(row, 21).Value = header.total_practical_credits; ws.Cell(row, 22).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 22)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 22).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 22)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 22).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 22).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 21)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 22).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 22).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 22).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 22).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 22).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 14) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 23)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 14).Value = header.total_credits; ws.Cell(row, rowhead2 + 15).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 16).Value = header.practical_credits; ws.Cell(row, rowhead2 + 17).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 18).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 19).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 19)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 19)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 18).Value = header.total_credits; ws.Cell(row, 19).Value = header.lecture_credits; ws.Cell(row, 20).Value = header.practical_credits; ws.Cell(row, 21).Value = header.total_lecture_credits; ws.Cell(row, 22).Value = header.total_practical_credits; ws.Cell(row, 23).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 23)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 23).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 23)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 23).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 23).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 22)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 23).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 23).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 23).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 23).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 23).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 15) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 24)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 15).Value = header.total_credits; ws.Cell(row, rowhead2 + 16).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 17).Value = header.practical_credits; ws.Cell(row, rowhead2 + 18).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 19).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 20).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 20)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 20)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 20)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 19).Value = header.total_credits; ws.Cell(row, 20).Value = header.lecture_credits; ws.Cell(row, 21).Value = header.practical_credits; ws.Cell(row, 22).Value = header.total_lecture_credits; ws.Cell(row, 23).Value = header.total_practical_credits; ws.Cell(row, 24).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 24)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 24).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 24)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 24).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 24).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 23)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 24).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 24).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 24).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 24).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 24).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 16) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 25)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 16).Value = header.total_credits; ws.Cell(row, rowhead2 + 17).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 18).Value = header.practical_credits; ws.Cell(row, rowhead2 + 19).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 20).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 21).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 21)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 21)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 21)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 21)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 21)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 21)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 21)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 20)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 20).Value = header.total_credits; ws.Cell(row, 21).Value = header.lecture_credits; ws.Cell(row, 22).Value = header.practical_credits; ws.Cell(row, 23).Value = header.total_lecture_credits; ws.Cell(row, 24).Value = header.total_practical_credits; ws.Cell(row, 25).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 25)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 25).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 25)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 25).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 25).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 24)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 25).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 25).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 25).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 25).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 25).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 17) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 26)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 17).Value = header.total_credits; ws.Cell(row, rowhead2 + 18).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 19).Value = header.practical_credits; ws.Cell(row, rowhead2 + 20).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 21).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 22).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 22)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 22)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 22)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 22)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 22)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 22)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 22)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 22)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 21).Value = header.total_credits; ws.Cell(row, 22).Value = header.lecture_credits; ws.Cell(row, 23).Value = header.practical_credits; ws.Cell(row, 24).Value = header.total_lecture_credits; ws.Cell(row, 25).Value = header.total_practical_credits; ws.Cell(row, 26).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 26)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 26).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 26)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 26).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 26).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 25)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 26).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 26).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 26).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 26).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 26).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 18) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 27)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 18).Value = header.total_credits; ws.Cell(row, rowhead2 + 19).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 20).Value = header.practical_credits; ws.Cell(row, rowhead2 + 21).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 22).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 23).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 23)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 23)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 23)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 23)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 23)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 23)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 23)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 23)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 22).Value = header.total_credits; ws.Cell(row, 23).Value = header.lecture_credits; ws.Cell(row, 24).Value = header.practical_credits; ws.Cell(row, 25).Value = header.total_lecture_credits; ws.Cell(row, 26).Value = header.total_practical_credits; ws.Cell(row, 27).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 27)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 27).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 27)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 27).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 27).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 26)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 27).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 27).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 27).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 27).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 27).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 19) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 28)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 19).Value = header.total_credits; ws.Cell(row, rowhead2 + 20).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 21).Value = header.practical_credits; ws.Cell(row, rowhead2 + 22).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 23).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 24).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 24)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 24)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 24)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 24)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 24)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 24)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 24)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 24)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 23).Value = header.total_credits; ws.Cell(row, 24).Value = header.lecture_credits; ws.Cell(row, 25).Value = header.practical_credits; ws.Cell(row, 26).Value = header.total_lecture_credits; ws.Cell(row, 27).Value = header.total_practical_credits; ws.Cell(row, 28).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 28)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 28).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 28)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 28).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 28).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 27)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 28).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 27).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 28).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 28).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 28).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } if (a == 20) { if (header.topic_type == 1) { ws.Range(ws.Cell(row, 3), ws.Cell(row, 29)).Merge().Value = header.education_level; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 2) { ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Merge().Value = header.year_class; ws.Cell(row, 3).Value = "นักศึกษา รหัส" + header.code; ws.Cell(row, rowhead2 + 20).Value = header.total_credits; ws.Cell(row, rowhead2 + 21).Value = header.lecture_credits; ws.Cell(row, rowhead2 + 22).Value = header.practical_credits; ws.Cell(row, rowhead2 + 23).Value = header.total_lecture_credits; ws.Cell(row, rowhead2 + 24).Value = header.total_practical_credits; ws.Cell(row, rowhead2 + 25).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 25)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 25)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 25)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 25)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 153); ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 25)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 2)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 4), ws.Cell(row, rowhead2 + 25)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, rowhead2 + 25)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, rowhead2 + 25)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 3) { ws.Cell(row, 1).Value = no; no++; ws.Cell(row, 2).Value = header.topic_code; ws.Cell(row, 3).Value = header.topic; foreach (var i in header.majors) { ws.Cell(row, rowhead2).Value = i.credits; ws.Cell(row, rowhead2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, rowhead2).Style.Font.FontName = "TH SarabunPSK"; ws.Cell(row, rowhead2).Style.Font.FontSize = 16; ws.Cell(row, rowhead2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; rowhead2++; } ws.Cell(row, 24).Value = header.total_credits; ws.Cell(row, 25).Value = header.lecture_credits; ws.Cell(row, 26).Value = header.practical_credits; ws.Cell(row, 27).Value = header.total_lecture_credits; ws.Cell(row, 28).Value = header.total_practical_credits; ws.Cell(row, 29).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 4), ws.Cell(row, 29)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 4) //รวมระดับชั้น { ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Merge().Value = "รวม " + header.education_level; ws.Cell(row, 29).Value = header.total_register_amount; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 3)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Fill.BackgroundColor = XLColor.FromArgb(198, 224, 180); ws.Range(ws.Cell(row, 4), ws.Cell(row, 29)).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 29).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Range(ws.Cell(row, 3), ws.Cell(row, 29)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 29).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (header.topic_type == 5) //รวมรายรับ { ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Merge().Value = "รวมรายรับจากการจัดการศึกษาให้กับ " + revenueEstimate.faculty + " " + " ภาคเรียน " + revenueEstimate.semester + " / " + revenueEstimate.year + " " + revenueEstimate.budget_project_name_th; ws.Cell(row, 29).Value = revenueEstimate.total_income; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 28)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 29).Style.Fill.BackgroundColor = XLColor.FromArgb(189, 215, 238); ws.Range(ws.Cell(row, 1), ws.Cell(row, 29)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 29).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; ws.Cell(row, 29).Style.NumberFormat.SetFormat("#,#"); ws.Cell(row, 29).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; } } } using (var stream = new MemoryStream()) { workbook.SaveAs(stream); var content = stream.ToArray(); return File( content, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "revenueEstimate_register" + ".xlsx"); } } [SwaggerOperation("ร13. ประมาณการรายรับภาคปกติของคณะศิลปศาสตร์จาก ค่าบำรุงการศึกษา")] [HttpPost, Route("reports/revenue_estimate_education_fee/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetEstimateReport([FromRoute] string type, [FromBody] revenue_estimate_education_fee estimate) { if (estimate.budget_project_name_th != null) { string myStr = estimate.budget_project_name_th; string[] projectname = myStr.Split("ผู้สำเร็จการศึกษา"); foreach (string projectnames in projectname) { estimate.side = projectnames; } } var estimateEducation = new List() { estimate }; Report report = new Report(); report.Load(_setting.report_path + "revenue_estimate_education_fee.frx"); report.RegisterData(estimateEducation, "revenue_estimate_education_fee"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "estimateEducation" + ".xlsx"); } return Ok(); } [SwaggerOperation("ร14. แบบฟอร์มสรุปรายรับคณะศิลปศาสตร์จากการจัดการศึกษาให้กับคณะอื่น")] [HttpPost, Route("reports/revenue_estimate_income_summary/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetEstimateIncomeReport([FromRoute] string type, [FromBody] revenue_estimate_income_summary estimate) { var s1 = estimate.data.Sum(d => d.science_1); var s2 = estimate.data.Sum(d => d.social_1); var s3 = estimate.data.Sum(d => d.science_2); var s4 = estimate.data.Sum(d => d.social_2); var s5 = estimate.data.Sum(d => d.total_register_fee); var s6 = estimate.data.Sum(d => d.science_3); var s7 = estimate.data.Sum(d => d.social_3); var s8 = estimate.data.Sum(d => d.science_4); var s9 = estimate.data.Sum(d => d.social_4); var s10 = estimate.data.Sum(d => d.total_education_fee); var s11 = estimate.data.Sum(d => d.total_science); var s12 = estimate.data.Sum(d => d.total_social); var s13 = estimate.data.Sum(d => d.total_science_social); estimate.sum_1 = s1; estimate.sum_2 = s2; estimate.sum_3 = s3; estimate.sum_4 = s4; estimate.sum_5 = s5; estimate.sum_6 = s6; estimate.sum_7 = s7; estimate.sum_8 = s8; estimate.sum_9 = s9; estimate.sum_10 = s10; estimate.sum_11 = s11; estimate.sum_12 = s12; estimate.sum_13 = s13; var estimateEducation = new List() { estimate }; Report report = new Report(); report.Load(_setting.report_path + "revenue_estimate_income_summary.frx"); report.RegisterData(estimateEducation, "revenue_estimate_income_summary"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "estimateincome_" + ".xlsx"); } return Ok(); } [SwaggerOperation("ร1. แบบฟอร์มเสนอขอปรับเปลี่ยนชื่อตำแหน่ง")] [HttpPost, Route("reports/form_1_2/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetForm2Report([FromRoute] string type, [FromBody] form_1_2 form1) { form1.dates = form1.date.Value.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("th-TH")); form1.day_start_workings = form1.start_working.Value.ToString("dd", CultureInfo.CreateSpecificCulture("th-TH")); form1.month_start_workings = form1.start_working.Value.ToString("MMMM", CultureInfo.CreateSpecificCulture("th-TH")); form1.year_start_workings = form1.start_working.Value.ToString("yyyy", CultureInfo.CreateSpecificCulture("th-TH")); var form_1 = new List() { form1 }; Report report = new Report(); report.Load(_setting.report_path + "change_position_offer_request_form.frx"); report.RegisterData(form_1, "form_1_2"); 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 "doc": Word2007Export word = new Word2007Export(); report.Export(word, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); case "docx": Word2007Export word1 = new Word2007Export(); report.Export(word1, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); case "xlsx": Excel2007Export excel = new Excel2007Export(); report.Export(excel, stream); stream.Seek(0, SeekOrigin.Begin); return File( stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "change_position_offer_request_form" + ".xlsx"); } return Ok(); } [SwaggerOperation("ร1. แบบฟอร์มเสนอขออัตราใหม่")] [HttpPost, Route("reports/form_1_3/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetForm3Report([FromRoute] string type, [FromBody] form_1_3 form3) { // if (form3 != null) // { if (form3.date != null) { form3.dates = form3.date.Value.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("th-TH")); } if (form3.checkbox_1 == true) { form3.checkbox1 = "/"; // form3.checkbox2 = null; // form3.checkbox3 = null; // form3.checkbox4 = null; // form3.checkbox5 = null; } if (form3.checkbox_1 == false) { form3.checkbox1 = null; } if (form3.checkbox_2 == true) { form3.checkbox2 = "/"; // form3.checkbox1 = null; // form3.checkbox3 = null; // form3.checkbox4 = null; // form3.checkbox5 = null; } if (form3.checkbox_2 == false) { form3.checkbox2 = null; } if (form3.checkbox_3 == true) { form3.checkbox3 = "/"; // form3.checkbox2 = null; // form3.checkbox1 = null; // form3.checkbox4 = null; // form3.checkbox5 = null; } if (form3.checkbox_3 == false) { form3.checkbox3 = null; } if (form3.checkbox_4 == true) { form3.checkbox4 = "/"; // form3.checkbox2 = null; // form3.checkbox3 = null; // form3.checkbox1 = null; // form3.checkbox5 = null; } if (form3.checkbox_4 == false) { form3.checkbox4 = null; } if (form3.checkbox_5 == true) { form3.checkbox5 = "/"; // form3.checkbox2 = null; // form3.checkbox3 = null; // form3.checkbox4 = null; // form3.checkbox1 = null; } if (form3.checkbox_5 == false) { form3.checkbox5 = null; } if (form3.other_remark != null || form3.other_remark != "") { form3.checkbox6 = "/"; } if (form3.other_remark == null || form3.other_remark == "") { form3.checkbox6 = null; } foreach (var detail in form3.form_1_3_details) { detail.order_dates = detail.order_date.Value.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("th-TH")); detail.Informations_as_of = detail.Information_as_of.Value.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("th-TH")); if (detail.checkbox_1 == true) { detail.checkbox1 = "/"; detail.checkbox2 = null; } if (detail.checkbox_1 == false) { detail.checkbox1 = null; } if (detail.checkbox_2 == true) { detail.checkbox2 = "/"; detail.checkbox1 = null; } if (detail.checkbox_2 == false) { detail.checkbox2 = null; } var a = detail.effects_if; var b = detail.workload; foreach (var aa in a) { detail.effects_if1 = aa; } foreach (var bb in b) { detail.workloads = bb; } } //} var form_3 = new List() { form3 }; Report report = new Report(); report.Load(_setting.report_path + "new_rate_offer_request_form.frx"); report.RegisterData(form_3, "form_1_3"); 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 "doc": Word2007Export word = new Word2007Export(); report.Export(word, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); case "docx": Word2007Export word1 = new Word2007Export(); report.Export(word1, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); case "xlsx": Excel2007Export excel = new Excel2007Export(); report.Export(excel, stream); stream.Seek(0, SeekOrigin.Begin); return File( stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "change_position_offer_request_form" + ".xlsx"); } return Ok(); } [SwaggerOperation("ร1. แบบฟอร์มเสนอขอปรับคุณวุฒิ")] [HttpPost, Route("reports/budget_income_qualification/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetForm1Report([FromRoute] string type, [FromBody] form_1_1 form1) { if (form1.budget_income_qualification_date != null) { form1.budget_income_qualification_dates = form1.budget_income_qualification_date.Value.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("th-TH")); } if (form1.budget_project_date != null) { form1.day_budget_project = form1.budget_project_date.Value.ToString("dd", CultureInfo.CreateSpecificCulture("th-TH")); form1.month_budget_project = form1.budget_project_date.Value.ToString("MMMM", CultureInfo.CreateSpecificCulture("th-TH")); form1.year_budget_project = form1.budget_project_date.Value.ToString("yyyy", CultureInfo.CreateSpecificCulture("th-TH")); } var form_1 = new List() { form1 }; Report report = new Report(); report.Load(_setting.report_path + "qualifications_offer_request_form.frx"); report.RegisterData(form_1, "form_1_1"); 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 "doc": Word2007Export word = new Word2007Export(); report.Export(word, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); case "docx": Word2007Export word1 = new Word2007Export(); report.Export(word1, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); case "xlsx": Excel2007Export excel = new Excel2007Export(); report.Export(excel, stream); stream.Seek(0, SeekOrigin.Begin); return File( stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "budget_income_qualification" + ".xlsx"); } return Ok(); } [SwaggerOperation("รายงานสรุปประมาณการรายรับ หลักสูตรสหกิจศึกษา")] [HttpPost, Route("reports/summary_income_cooperative/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetCooperativeReport([FromRoute] string type, [FromBody] summary_income_cooperative cooperative) { /*var sum1 = cooperative.data.Where(j=>j.topic_type==3).Sum(d => d.revenue_estimates); var sum2 = cooperative.data.Where(j=>j.topic_type==3).Sum(d => d.deduct_expenses_percent60); var sum3 = cooperative.data.Where(j=>j.topic_type==3).Sum(d => d.deduct_expenses_percent10); var sum4 = cooperative.data.Where(j=>j.topic_type==3).Sum(d => d.balance); var sum5 = cooperative.data.Where(j=>j.topic_type==3).Sum(d => d.deduct_tuition_fees); var sum6 = cooperative.data.Where(j=>j.topic_type==3).Sum(d => d.balance_university);*/ foreach (var detail in cooperative.data) { if (detail.topic_type == 4) { string myStr = detail.topic; string[] projectname = myStr.Split("ผู้สำเร็จการศึกษา"); foreach (string projectnames in projectname) { detail.topic = "รวม "+ projectnames; } } } var cooperatives = new List() { cooperative }; Report report = new Report(); report.Load(_setting.report_path + "summary_income_cooperative.frx"); report.RegisterData(cooperatives, "summary_income_cooperative"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "Cooperative" + ".xlsx"); } return Ok(); } } }