bug fixed

This commit is contained in:
kamonwan taengsuk
2023-03-24 17:37:34 +07:00
parent 5c053f8fd5
commit 379fc76fac
2 changed files with 256 additions and 84 deletions

View File

@@ -17,6 +17,7 @@ namespace rmutr_report.Controllers
{
this._setting = setting;
}
[HttpPost, Route("reports/study_material/{type}")]
[ApiExplorerSettings(GroupName = "reports")]
public IActionResult GetMaterialReport([FromRoute] string type,
@@ -25,14 +26,16 @@ namespace rmutr_report.Controllers
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("ง.7");
ws.Range("A1:J1").Merge().Value = "แบบฟอร์มแผนการเรียน คณะ" + _study_material.faculty + "ปีงบประมาณ "+ _study_material.budget_year;
ws.Range("A1:J1").Merge().Value = "แบบฟอร์มแผนการเรียน คณะ" + _study_material.faculty + "ปีงบประมาณ " +
_study_material.budget_year;
ws.Range("A1:J1").Style.Alignment.WrapText = true;
ws.Range("A1:J1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A1:J1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
ws.Cell("A1").Style.Font.FontName = "TH SarabunPSK";
ws.Cell("A1").Style.Font.FontSize = 16;
ws.Range("A1:J1").Style.Font.Bold = true;
ws.Range("A2:J2").Merge().Value = "ผลผลิต " + _study_material.product+" คณะ "+ _study_material.faculty;
ws.Range("A2:J2").Merge().Value =
"ผลผลิต " + _study_material.product + " คณะ " + _study_material.faculty;
ws.Range("A2:J2").Style.Alignment.WrapText = true;
ws.Range("A2:J2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range("A2:J2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
@@ -143,21 +146,40 @@ namespace rmutr_report.Controllers
if (_study_material != null)
{
foreach (var data in _study_material.data)
foreach (var data in _study_material.data1)
{
if (data.academic_semester != "รวม")
// ws.Cell(row, 1).Value = "ภาคการศึกษา " + data.academic_semester + "/" + data.academic_year;
// 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.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.Alignment.Vertical =
// XLAlignmentVerticalValues.Center;
// ws.Cell(row, 1).Style.Font.Bold = 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.Border.RightBorder =
// XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
//
// ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).SetDataType(XLDataType.Number);
// ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Style.NumberFormat.SetFormat("#,#");
// row++;
ws.Cell(row, 1).Value = "ภาคการศึกษา " + data.academic_semester + "/" + data.academic_year;
foreach (var data2 in data.data2)
{
ws.Cell(row, 1).Value = data.academic_semester;
ws.Cell(row, 2).Value = data.student;
ws.Cell(row, 3).Value = data.pohchang;
ws.Cell(row, 4).Value = data.bophitphimuk;
ws.Cell(row, 5).Value = data.salaya;
ws.Cell(row, 6).Value = data.klai_kangwon;
ws.Cell(row, 7).Value = data.sum_science;
ws.Cell(row, 8).Value = data.sum_social;
ws.Cell(row, 9).Value = data.cost_science;
ws.Cell(row, 10).Value = data.cost_social;
// ws.Cell(row, 1).Value = "ภาคการศึกษา " + data.academic_semester + "/" + data.academic_year;
ws.Cell(row, 2).Value =
"ชั้นปีที่ " + data2.year_class + " (รหัส " + data.academic_year + ")";
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.FontSize = 16;
@@ -165,11 +187,12 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Cell(row, 1).Style.Font.Bold = true;
ws.Cell(row, 2).Style.Font.Bold = 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.Border.RightBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
@@ -183,22 +206,65 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).SetDataType(XLDataType.Number);
ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Style.NumberFormat.SetFormat("#,#");
row++;
}
if (data.academic_semester == "รวม" || data.academic_semester == "รวม 1 ปีภาคการศึกษา")
foreach (var data3 in data2.data3)
{
//_study_material.text = " - สาขา ";
if (data3.academic_semester == "รวม" ||
data3.academic_semester == "รวม 1 ปีภาคการศึกษา")
{
ws.Cell(row, 1).Value = data3.academic_semester;
ws.Cell(row, 2).Value = null ;
ws.Cell(row, 3).Value = data3.pohchang;
ws.Cell(row, 4).Value = data3.bophitphimuk;
ws.Cell(row, 5).Value = data3.salaya;
ws.Cell(row, 6).Value = data3.klai_kangwon;
ws.Cell(row, 7).Value = data3.sum_science;
ws.Cell(row, 8).Value = data3.sum_social;
ws.Cell(row, 9).Value = data3.cost_science;
ws.Cell(row, 10).Value = data3.cost_social;
ws.Cell(row, 1).Value = data.academic_semester;
ws.Cell(row, 2).Value = data.student;
ws.Cell(row, 3).Value = data.pohchang;
ws.Cell(row, 4).Value = data.bophitphimuk;
ws.Cell(row, 5).Value = data.salaya;
ws.Cell(row, 6).Value = data.klai_kangwon;
ws.Cell(row, 7).Value = data.sum_science;
ws.Cell(row, 8).Value = data.sum_social;
ws.Cell(row, 9).Value = data.cost_science;
ws.Cell(row, 10).Value = data.cost_social;
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.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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.Bold = 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.Border.RightBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).SetDataType(XLDataType.Number);
ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Style.NumberFormat.SetFormat("#,#");
//row++;
}
if (data3.academic_semester != "รวม" &&
data3.academic_semester != "รวม 1 ปีภาคการศึกษา")
{
string major = " - สาขา ";
ws.Cell(row, 1).Value = data3.academic_semester;
ws.Cell(row, 2).Value = data3.student;
ws.Cell(row, 3).Value = data3.pohchang;
ws.Cell(row, 4).Value = data3.bophitphimuk;
ws.Cell(row, 5).Value = data3.salaya;
ws.Cell(row, 6).Value = data3.klai_kangwon;
ws.Cell(row, 7).Value = data3.sum_science;
ws.Cell(row, 8).Value = data3.sum_social;
ws.Cell(row, 9).Value = data3.cost_science;
ws.Cell(row, 10).Value = data3.cost_social;
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.FontSize = 16;
@@ -211,7 +277,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.RightBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
@@ -223,9 +289,95 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).SetDataType(XLDataType.Number);
ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Style.NumberFormat.SetFormat("#,#");
//row++;
}
row++;
}
}
// if (data.academic_semester != "รวม")
// {
// ws.Cell(row, 1).Value = data.academic_semester;
// ws.Cell(row, 2).Value = data.student;
// ws.Cell(row, 3).Value = data.pohchang;
// ws.Cell(row, 4).Value = data.bophitphimuk;
// ws.Cell(row, 5).Value = data.salaya;
// ws.Cell(row, 6).Value = data.klai_kangwon;
// ws.Cell(row, 7).Value = data.sum_science;
// ws.Cell(row, 8).Value = data.sum_social;
// ws.Cell(row, 9).Value = data.cost_science;
// ws.Cell(row, 10).Value = data.cost_social;
//
// 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.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.Alignment.Vertical =
// XLAlignmentVerticalValues.Center;
// ws.Cell(row, 1).Style.Font.Bold = 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.Border.RightBorder =
// XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
// ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
//
// ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).SetDataType(XLDataType.Number);
// ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Style.NumberFormat.SetFormat("#,#");
// row++;
//
// }
// if (data.academic_semester == "รวม" || data.academic_semester == "รวม 1 ปีภาคการศึกษา")
// {
//
// ws.Cell(row, 1).Value = data.academic_semester;
// ws.Cell(row, 2).Value = data.student;
// ws.Cell(row, 3).Value = data.pohchang;
// ws.Cell(row, 4).Value = data.bophitphimuk;
// ws.Cell(row, 5).Value = data.salaya;
// ws.Cell(row, 6).Value = data.klai_kangwon;
// ws.Cell(row, 7).Value = data.sum_science;
// ws.Cell(row, 8).Value = data.sum_social;
// ws.Cell(row, 9).Value = data.cost_science;
// ws.Cell(row, 10).Value = data.cost_social;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.Bold = true;
// 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.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.Alignment.Vertical =
// XLAlignmentVerticalValues.Center;
// ws.Cell(row, 1).Style.Font.Bold = 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.Border.RightBorder =
// XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
// ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
//
// ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).SetDataType(XLDataType.Number);
// ws.Range(ws.Cell(row, 3), ws.Cell(row, 10)).Style.NumberFormat.SetFormat("#,#");
// row++;
// }
}
}
using (var stream = new MemoryStream())

View File

@@ -7,10 +7,29 @@ namespace rmutr_report.Models
public string budget_year { get; set; }
public string product { get; set; }
public string faculty { get; set; }
public List<study_material_detail> data { get; set; }
public List<study_material_detail1> data1 { get; set; }
//public string text { get; set; }
}
public class study_material_detail
public class study_material_detail1
{
public string academic_semester { get; set; }
public string academic_year { get; set; }
public string year_class { get; set; }
public string code { get; set; }
public List<study_material_detail2> data2 { get; set; }
}
public class study_material_detail2
{
public string year_class { get; set; }
public string code { get; set; }
public List<study_material_detail3> data3 { get; set; }
}
public class study_material_detail3
{
public string academic_semester { get; set; }
public string student { get; set; }
@@ -24,5 +43,6 @@ namespace rmutr_report.Models
public decimal? sum_social { get; set; }
public decimal? cost_science { get; set; }
public decimal? cost_social { get; set; }
}
}