This commit is contained in:
kamonwan taengsuk
2023-02-08 17:35:54 +07:00
parent 23c2e53d08
commit b2ddfd2c97
2 changed files with 94 additions and 49 deletions

View File

@@ -141,54 +141,85 @@ namespace rmutr_report.Controllers
ws.Range("D2:E2").Style.Font.Bold = true;
foreach (var header in _kpi.header_data)
{
string kpiname = "ประเด็นยุทธ์ศาสตร์ที่ " + no + " :";
no++;
ws.Cell(row, 1).SetValue(kpiname).Style.Font.Bold = true;
ws.Cell(row, 2).Value = header.header_1;
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Bisque;
ws.Cell(row, 1).Style.Border.OutsideBorder =
XLBorderStyleValues.None;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 8)).Merge().Style.Fill.BackgroundColor = XLColor.Bisque;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 8)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
row++;
string target = "เป้าหมายหลัก :";
ws.Cell(row, 1).SetValue(target).Style.Font.Bold = true;
int g = target.Length;
g++;
ws.Cell(row, 2).Value = header.header_2;
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.LavenderBlush;
ws.Cell(row, 1).Style.Border.OutsideBorder =
XLBorderStyleValues.None;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 8)).Merge().Style.Fill.BackgroundColor =
XLColor.LavenderBlush;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 8)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.TopBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Border.TopBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
row++;
ws.Cell(row, 1).Value = "ตัวชี้วัดกลยุทธ์ : " + header.indicator_type_name_th;
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Beige;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Font.Bold = true;
row++;
if (header.header_1 != null || header.header_1 != "")
{
string kpiname = "ประเด็นยุทธ์ศาสตร์ที่ " + no + " :";
no++;
ws.Cell(row, 1).SetValue(kpiname).Style.Font.Bold = true;
ws.Cell(row, 2).Value = header.header_1;
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Bisque;
ws.Cell(row, 1).Style.Border.OutsideBorder =
XLBorderStyleValues.None;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 8)).Merge().Style.Fill.BackgroundColor = XLColor.Bisque;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 8)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
row++;
}
if (header.header_1 == null)
{
header.header_1 = null;
}
if (header.header_2!=null||header.header_2!="")
{
string target = "เป้าหมายหลัก :";
ws.Cell(row, 1).SetValue(target).Style.Font.Bold = true;
int g = target.Length;
g++;
ws.Cell(row, 2).Value = header.header_2;
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.LavenderBlush;
ws.Cell(row, 1).Style.Border.OutsideBorder =
XLBorderStyleValues.None;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 8)).Merge().Style.Fill.BackgroundColor =
XLColor.LavenderBlush;
ws.Range(ws.Cell(row, 3), ws.Cell(row, 8)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Border.TopBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Border.TopBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
row++;
}
if (header.header_2 == null)
{
header.header_2 = null;
}
// if (header.indicator_type_name_th!=null||header.indicator_type_name_th!="")
// {
// ws.Cell(row, 1).Value = "ตัวชี้วัดกลยุทธ์ : " + header.indicator_type_name_th;
// ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Beige;
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder =
// XLBorderStyleValues.Thin;
// ws.Cell(row, 1).Style.Font.Bold = true;
// row++;
// }
// if (header.indicator_type_name_th == null)
// {
// header.indicator_type_name_th = null;
// }
//var data = _kpi.header_data.Select(d => d.data).ToList();
// foreach (var detail in header)
// {
foreach (var data1 in header.data)
{
if ( rowno > 1 )
{
ws.Range(ws.Cell(row, 1), ws.Cell(row,1)).Merge();
}
ws.Cell(row, 2).Value = rowno;
foreach (var data in header.data)
{
if (data.indicator_type_name_th != null || data.indicator_type_name_th != "")
{
ws.Cell(row, 1).Value = "ตัวชี้วัดกลยุทธ์ : " + data.indicator_type_name_th;
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Beige;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Font.Bold = true;
row++;
}
foreach (var data1 in data.data_detail)
{
ws.Cell(row, 2).Value = data1.row;
ws.Cell(row, 3).Value = data1.name;
ws.Cell(row, 4).Value = data1.unit;
ws.Cell(row, 5).Value = data1.value;
@@ -228,9 +259,16 @@ namespace rmutr_report.Controllers
ws.Cell(row, 8).Style.Border.RightBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 8).Style.Alignment.WrapText = true;
row++;
rowno++;
//rowno++;
// if (rowno > 1)
// {
// ws.Range(ws.Cell(row, 1), ws.Cell(row, 1)).Merge();
//
// }
}
//row++;
}
//row++;
}
}