update excel file
This commit is contained in:
@@ -37,172 +37,195 @@ namespace rmutr_report.Controllers
|
|||||||
[ApiExplorerSettings(GroupName = "reports")]
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
public IActionResult GetKpiReport([FromRoute] string type, [FromBody] List<kpi> _kpi)
|
public IActionResult GetKpiReport([FromRoute] string type, [FromBody] List<kpi> _kpi)
|
||||||
{
|
{
|
||||||
DataTable table = new DataTable();
|
var workbook = new XLWorkbook();
|
||||||
var workbook1 = new XLWorkbook();
|
var ws = workbook.Worksheets.Add("kpi");
|
||||||
var ws = workbook1.Worksheets.Add("kpi");
|
|
||||||
table.TableName = "kpi";
|
|
||||||
ws.Cell("A1").Value = "ประเด็นยุทธศาสตร์/เป้าหมายหลัก/ตัวชี้วัด";
|
ws.Cell("A1").Value = "ประเด็นยุทธศาสตร์/เป้าหมายหลัก/ตัวชี้วัด";
|
||||||
|
ws.Cell("A1").Style.Font.Bold = true;
|
||||||
ws.Cell("A1").Style.Alignment.WrapText = true;
|
ws.Cell("A1").Style.Alignment.WrapText = true;
|
||||||
ws.Range("A1:A2").Column(1).Merge();
|
ws.Range("A1:A2").Column(1).Merge();
|
||||||
ws.Range("B1:C2").Merge().Value = "ตัวชี้วัด";
|
ws.Range("B1:C2").Merge().Value = "ตัวชี้วัด";
|
||||||
ws.Range("D2").Value = "หน่วย";
|
ws.Range("B1:C2").Style.Font.Bold = true;
|
||||||
ws.Range("E2").Value = "ค่าเป้าหมาย";
|
ws.Range("D2").Value = "หน่วย";
|
||||||
ws.Range("F1:F2").Merge().Value = "ผู้รับผิดชอบกำกับดูแล";
|
ws.Range("D2").Style.Font.Bold = true;
|
||||||
ws.Range("G1:G2").Merge().Value = "ผู้รับผิดชอบในการปฎิบัติงาน";
|
ws.Range("E2").Value = "ค่าเป้าหมาย";
|
||||||
ws.Range("H1:H2").Merge().Value = "ผู้รวบรวมและรายงานผลตัวชี้วัด";
|
ws.Range("E2").Style.Font.Bold = true;
|
||||||
ws.Range("A1:A2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("F1:F2").Merge().Value = "ผู้รับผิดชอบกำกับดูแล";
|
||||||
ws.Range("B1:C2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("G1:G2").Merge().Value = "ผู้รับผิดชอบในการปฎิบัติงาน";
|
||||||
ws.Range("B1:C2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
ws.Range("H1:H2").Merge().Value = "ผู้รวบรวมและรายงานผลตัวชี้วัด";
|
||||||
ws.Range("D1:E1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("F1:F2").Style.Font.Bold = true;
|
||||||
ws.Range("D2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("G1:G2").Style.Font.Bold = true;
|
||||||
ws.Range("E2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("H1:H2").Style.Font.Bold = true;
|
||||||
ws.Range("F1:F2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("A1:A2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Cell("F1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
ws.Range("B1:C2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Range("G1:G2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("B1:C2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
ws.Cell("G1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
ws.Range("D1:E1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Range("H1:H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Range("D2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Cell("H1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
ws.Range("E2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
//ws.Cell("B1:C2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
ws.Range("F1:F2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Range("A1:A2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Cell("F1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
ws.Range("B1:C2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Range("G1:G2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Range("D1:E1").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Cell("G1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
ws.Range("D2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Range("H1:H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Range("E2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Cell("H1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
ws.Range("F1:F2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
//ws.Cell("B1:C2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
ws.Range("G1:G2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Range("A1:A2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("H1:H2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
ws.Range("B1:C2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("A1:A2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("D1:E1").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("B1:C2").Style.Border.BottomBorder = XLBorderStyleValues.Thin;
|
ws.Range("D2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("D1:E1").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("E2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("D2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("F1:F2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("E2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("G1:G2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("F1:F2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("H1:H2").Style.Fill.BackgroundColor = XLColor.SkyBlue;
|
||||||
ws.Range("G1:G2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("A1:A2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Range("H1:H2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Range("B1:C2").Style.Border.BottomBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(1).Width = 20;
|
ws.Range("D1:E1").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(2).Width = 5;
|
ws.Range("D2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(3).Width = 30;
|
ws.Range("E2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(4).Width = 10;
|
ws.Range("F1:F2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(5).Width = 20;
|
ws.Range("G1:G2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(6).Width = 40;
|
ws.Range("H1:H2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Column(7).Width = 40;
|
ws.Column(1).Width = 22;
|
||||||
ws.Column(8).Width = 40;
|
ws.Column(2).Width = 5;
|
||||||
ws.Column(2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(3).Width = 30;
|
||||||
ws.Column(3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(4).Width = 10;
|
||||||
ws.Column(4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(5).Width = 20;
|
||||||
ws.Column(5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(6).Width = 40;
|
||||||
ws.Column(6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(7).Width = 40;
|
||||||
ws.Column(7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(8).Width = 40;
|
||||||
ws.Column(8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
ws.Column(2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(1).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(1).Style.Font.FontSize = 16;
|
ws.Column(4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(2).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(2).Style.Font.FontSize = 16;
|
ws.Column(6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(3).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(3).Style.Font.FontSize = 16;
|
ws.Column(8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
ws.Column(4).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(1).Style.Font.FontName = "TH Sarabun New";
|
||||||
ws.Column(4).Style.Font.FontSize = 16;
|
ws.Column(1).Style.Font.FontSize = 16;
|
||||||
ws.Column(5).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(2).Style.Font.FontName = "TH Sarabun New";
|
||||||
ws.Column(5).Style.Font.FontSize = 16;
|
ws.Column(2).Style.Font.FontSize = 16;
|
||||||
ws.Column(6).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(3).Style.Font.FontName = "TH Sarabun New";
|
||||||
ws.Column(6).Style.Font.FontSize = 16;
|
ws.Column(3).Style.Font.FontSize = 16;
|
||||||
ws.Column(7).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(4).Style.Font.FontName = "TH Sarabun New";
|
||||||
ws.Column(7).Style.Font.FontSize = 16;
|
ws.Column(4).Style.Font.FontSize = 16;
|
||||||
ws.Column(8).Style.Font.FontName = "TH Sarabun New";
|
ws.Column(5).Style.Font.FontName = "TH Sarabun New";
|
||||||
ws.Column(8).Style.Font.FontSize = 16;
|
ws.Column(5).Style.Font.FontSize = 16;
|
||||||
int col = 1;
|
ws.Column(6).Style.Font.FontName = "TH Sarabun New";
|
||||||
int row = 3;
|
ws.Column(6).Style.Font.FontSize = 16;
|
||||||
foreach (var kpis in _kpi)
|
ws.Column(7).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(7).Style.Font.FontSize = 16;
|
||||||
|
ws.Column(8).Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Column(8).Style.Font.FontSize = 16;
|
||||||
|
int col = 1;
|
||||||
|
int row = 3;
|
||||||
|
int no = 1;
|
||||||
|
|
||||||
|
foreach (var kpis in _kpi)
|
||||||
{
|
{
|
||||||
if (_kpi != null)
|
if (_kpi != null)
|
||||||
{
|
{
|
||||||
ws.Range("D1:E1").Merge().Value = "ค่าเป้าหมาย ปี " + kpis.academic_year.Substring(2, 2);
|
ws.Range("D1:E1").Merge().Value = "ค่าเป้าหมาย ปี " + kpis.academic_year.Substring(2, 2);
|
||||||
// var mergedRange = ws.MergedRanges.First(r => r.Contains("A"));
|
ws.Range("D1:E1").Style.Font.Bold = true;
|
||||||
// mergedRange.Style.Fill.BackgroundColor = XLColor.Bisque;
|
foreach (var header in kpis.header_data)
|
||||||
foreach (var header in kpis.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 = "ตัวชี้วัดกลยุทธ์";
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = kpis.header_data.Select(d => d.data).ToList();
|
||||||
|
foreach (var detail in data)
|
||||||
|
{
|
||||||
|
foreach (var data1 in detail)
|
||||||
{
|
{
|
||||||
ws.Cell(row, 1).Value = header.header_1;
|
ws.Cell(row, 2).Value = data1.row;
|
||||||
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Bisque;
|
ws.Cell(row, 3).Value = data1.name;
|
||||||
ws.Range(ws.Cell(row, 1),ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Cell(row, 4).Value = data1.unit;
|
||||||
row++;
|
ws.Cell(row, 5).Value = data1.value;
|
||||||
ws.Cell(row, 1).Value = header.header_2;
|
ws.Cell(row, 6).Value = data1.responsible_person;
|
||||||
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.LavenderBlush;
|
ws.Cell(row, 7).Value = data1.responsible_work;
|
||||||
ws.Range(ws.Cell(row, 1),ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Cell(row, 8).Value = data1.collector;
|
||||||
row++;
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Cell(row, 1).Value = header.header_3;
|
ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Cell(row, 1).Style.Fill.BackgroundColor = XLColor.Beige;
|
ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
ws.Range(ws.Cell(row, 1),ws.Cell(row, 8)).Merge().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
ws.Cell(row, 1).Style.Alignment.WrapText = true;
|
||||||
row++;
|
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 2).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 2).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 2).Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 3).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 3).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 3).Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 4).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 4).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 4).Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 5).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 5).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 5).Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 6).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 6).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 6).Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 7).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 7).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 7).Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 8).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 8).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 8).Style.Alignment.WrapText = true;
|
||||||
|
row++;
|
||||||
}
|
}
|
||||||
var data = kpis.header_data.Select(d => d.data).ToList();
|
//row++;
|
||||||
foreach (var detail in data)
|
}
|
||||||
{
|
|
||||||
foreach (var data1 in 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;
|
|
||||||
ws.Cell(row, 6).Value = data1.responsible_person;
|
|
||||||
ws.Cell(row, 7).Value = data1.responsible_work;
|
|
||||||
ws.Cell(row, 8).Value = data1.collector;
|
|
||||||
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row,2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row,2).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row,2).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 3).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 3).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 4).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 4).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 5).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 5).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 6).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 6).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 7).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 7).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 8).Style.Border.LeftBorder = XLBorderStyleValues.Thin;
|
|
||||||
ws.Cell(row, 8).Style.Border.RightBorder = XLBorderStyleValues.Thin;
|
|
||||||
row++;
|
|
||||||
// ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
// ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
// ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
// ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
// ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
|
||||||
}
|
|
||||||
//row++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
using (var stream = new MemoryStream())
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
workbook1.SaveAs(stream);
|
workbook.SaveAs(stream);
|
||||||
var content = stream.ToArray();
|
var content = stream.ToArray();
|
||||||
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
return File(
|
return File(
|
||||||
content,
|
content,
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
"kpi_" + date + ".xlsx");
|
"kpi_" + date + ".xlsx");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using ClosedXML.Excel;
|
||||||
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||||
using FastReport;
|
using FastReport;
|
||||||
using FastReport.Export.Csv;
|
using FastReport.Export.Csv;
|
||||||
using FastReport.Export.Mht;
|
using FastReport.Export.Mht;
|
||||||
@@ -14,9 +17,9 @@ using Swashbuckle.AspNetCore.Annotations;
|
|||||||
namespace rmutr_report.Controllers
|
namespace rmutr_report.Controllers
|
||||||
{
|
{
|
||||||
[SwaggerTag("สำหรับรายงานสรุปแผนความต้องการ")]
|
[SwaggerTag("สำหรับรายงานสรุปแผนความต้องการ")]
|
||||||
public class SummaryController: Controller
|
public class SummaryController : Controller
|
||||||
{
|
{
|
||||||
readonly Setting _setting;
|
readonly Setting _setting;
|
||||||
|
|
||||||
public SummaryController(Setting setting)
|
public SummaryController(Setting setting)
|
||||||
{
|
{
|
||||||
@@ -25,10 +28,10 @@ namespace rmutr_report.Controllers
|
|||||||
|
|
||||||
[HttpPost, Route("reports/summary_of_equipment/{type}")]
|
[HttpPost, Route("reports/summary_of_equipment/{type}")]
|
||||||
[ApiExplorerSettings(GroupName = "reports")]
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
public IActionResult GetSum1Report([FromRoute] string type, [FromBody] summary_of_equipment summary_of_equipments)
|
public IActionResult GetSum1Report([FromRoute] string type,
|
||||||
|
[FromBody] summary_of_equipment summary_of_equipments)
|
||||||
{
|
{
|
||||||
|
var _summary_of_equipment = new List<summary_of_equipment>() {summary_of_equipments};
|
||||||
var _summary_of_equipment = new List<summary_of_equipment>() { summary_of_equipments };
|
|
||||||
|
|
||||||
Report report = new Report();
|
Report report = new Report();
|
||||||
report.Load(_setting.report_path + "summary_of_equipment.frx");
|
report.Load(_setting.report_path + "summary_of_equipment.frx");
|
||||||
@@ -66,49 +69,262 @@ namespace rmutr_report.Controllers
|
|||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Route("reports/summary_of_equipment_five_year/{type}")]
|
[HttpPost, Route("reports/summary_of_equipment_five_year/{type}")]
|
||||||
[ApiExplorerSettings(GroupName = "reports")]
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
public IActionResult GetEquipmentReport([FromRoute] string type, [FromBody] summary_of_equipment_five_year summary_of_equipments)
|
public IActionResult GetEquipmentReport([FromRoute] string type,
|
||||||
|
[FromBody] List<summary_of_equipment_five_year> summary_of_equipments)
|
||||||
{
|
{
|
||||||
|
var workbook = new XLWorkbook();
|
||||||
var _summary_of_equipment = new List<summary_of_equipment_five_year>() { summary_of_equipments };
|
var ws = workbook.Worksheets.Add("รายการครุภัณฑ์");
|
||||||
|
var imagePath = @"C:\Users\Mercedes Benz\Documents\rmutr_report\wwwroot\Logo-RMUTR.png";
|
||||||
|
ws.AddPicture(imagePath).MoveTo(ws.Cell("A1")).Scale(0.27);
|
||||||
|
ws.Range("A1:P1").Merge().Value =
|
||||||
|
"สรุปแผนความต้องการ รายการครุภัณฑ์ ของมหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
|
||||||
|
ws.Range("A1:P1").Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A1:P1").Merge().Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("A1").Style.Font.Bold = true;
|
||||||
|
ws.Cell("A1").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("A1").Style.Font.FontSize = 16;
|
||||||
|
ws.Range("A2:A4").Merge().Value = "ลำดับความสำคัญ(1)";
|
||||||
|
ws.Cell("A2").Style.Alignment.WrapText = true;
|
||||||
|
ws.Range("A2:A4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A2:A4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A2:A4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("A2").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("A2").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("B2:B4").Merge().Value = "รายการ";
|
||||||
|
ws.Cell("B2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("B2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("B2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("B2").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("B2").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("C3:E3").Merge().Value = "ประเภทของครุภัณฑ์";
|
||||||
|
ws.Range("C3:E3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("C3:E3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("C3:E3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("C3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("C3").Style.Font.FontSize = 11;
|
||||||
|
ws.Range("C4").Value = "ทดแทนของเดิม";
|
||||||
|
ws.Cell("C4").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("C4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("C4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("C4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("C4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("C4").Style.Font.FontSize = 11;
|
||||||
|
ws.Range("D4").Value = "เพิ่มประสิทธิภาพ";
|
||||||
|
ws.Cell("D4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("D4").Style.Font.FontSize = 11;
|
||||||
|
ws.Cell("D4").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("D4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("D4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("D4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("E4").Value = "ครุภัณฑ์ใหม่";
|
||||||
|
ws.Cell("E4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("E4").Style.Font.FontSize = 11;
|
||||||
|
ws.Cell("E4").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("E4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("F3:F4").Merge().Value = "หน่วยนับ";
|
||||||
|
ws.Cell("F3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("F3").Style.Font.FontSize = 12;
|
||||||
|
//ws.Range("F3").Style.Font.Bold = true;
|
||||||
|
ws.Range("F3:F4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("F3:F4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("F3:F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("G3:G4").Merge().Value = "จำนวน";
|
||||||
|
ws.Cell("G3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("G3").Style.Font.FontSize = 12;
|
||||||
|
//ws.Range("G3").Style.Font.Bold = true;
|
||||||
|
ws.Range("G3:G4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("G3:G4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("G3:G4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("G3").Style.Alignment.SetTextRotation(90);
|
||||||
|
ws.Range("H3:H4").Merge().Value = "ราคาต่อหน่วย";
|
||||||
|
ws.Cell("H3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("H3").Style.Font.FontSize = 12;
|
||||||
|
//ws.Range("H3").Style.Font.Bold = true;
|
||||||
|
ws.Range("H3:H4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("H3:H4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("H3:H4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("I2:M2").Merge().Value = "แผนความต้องการครุภัณฑ์";
|
||||||
|
ws.Cell("I2").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("I2").Style.Font.FontSize = 14;
|
||||||
|
//ws.Range("I2").Style.Font.Bold = true;
|
||||||
|
ws.Range("I2:M2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("I2:M2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("I2:M2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("I3:M3").Merge().Value = "วงเงิน";
|
||||||
|
ws.Cell("I3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("I3").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("I3:M3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("I3:M3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("I3:M3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("N4").Value = "วงเงิน";
|
||||||
|
ws.Cell("N4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("N4").Style.Font.FontSize = 12;
|
||||||
|
//ws.Range("N4").Style.Font.Bold = true;
|
||||||
|
ws.Cell("N4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("N4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("N4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("O4").Value = "ชื่อบริษัท";
|
||||||
|
ws.Cell("O4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("O4").Style.Font.FontSize = 12;
|
||||||
|
//ws.Range("O4").Style.Font.Bold = true;
|
||||||
|
ws.Cell("O4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("O4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("O4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("P2:P4").Merge().Value = "คำอธิบายความพร้อม/ประโยชน์ที่จะได้รับ";
|
||||||
|
ws.Cell("P2").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("P2").Style.Font.FontSize = 14;
|
||||||
|
//ws.Cell("P2").Style.Font.Bold = true;
|
||||||
|
ws.Cell("P2").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("P2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("P2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("P2:P4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Row(1).Height = 60;
|
||||||
|
ws.Column(1).Width = 8;
|
||||||
|
ws.Column(2).Width = 40;
|
||||||
|
ws.Column(3).Width = 5;
|
||||||
|
ws.Column(4).Width = 5;
|
||||||
|
ws.Column(5).Width = 5;
|
||||||
|
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(14).Width = 10;
|
||||||
|
ws.Column(15).Width = 10;
|
||||||
|
ws.Column(16).Width = 50;
|
||||||
|
|
||||||
Report report = new Report();
|
int row = 5;
|
||||||
report.Load(_setting.report_path + "summary_of_equipment_5_year.frx");
|
int no = 1;
|
||||||
report.RegisterData(_summary_of_equipment, "summary_of_equipment_five_year");
|
|
||||||
report.Prepare();
|
|
||||||
|
|
||||||
MemoryStream stream = new MemoryStream();
|
foreach (var equipments in summary_of_equipments)
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
case "pdf":
|
if (summary_of_equipments != null)
|
||||||
PDFExport pdf = new PDFExport();
|
{
|
||||||
report.Export(pdf, stream);
|
ws.Range("C2:H2").Merge().Value = "ปี " + equipments.academic_year;
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
ws.Cell("C2").Style.Font.FontName = "TH Sarabun New";
|
||||||
return File(stream, "application/pdf");
|
ws.Cell("C2").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("C2:H2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
case "xls":
|
ws.Range("C2:H2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
Excel2007Export excel = new Excel2007Export();
|
ws.Range("C2:H2").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
report.Export(excel, stream);
|
ws.Cell("I4").Value = equipments.budget_year_1;
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
ws.Cell("I4").Style.Font.FontName = "TH Sarabun New";
|
||||||
return File(stream, "application/vnd.ms-excel");
|
ws.Cell("I4").Style.Font.FontSize = 12;
|
||||||
break;
|
ws.Cell("I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
case "mht":
|
ws.Cell("I4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
MHTExport mht = new MHTExport();
|
ws.Cell("I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
report.Export(mht, stream);
|
ws.Cell("J4").Value = equipments.budget_year_2;
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
ws.Cell("J4").Style.Font.FontName = "TH Sarabun New";
|
||||||
return File(stream, "multipart/related");
|
ws.Cell("J4").Style.Font.FontSize = 12;
|
||||||
break;
|
ws.Cell("J4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
case "csv":
|
ws.Cell("J4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
CSVExport csv = new CSVExport();
|
ws.Cell("J4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
report.Export(csv, stream);
|
ws.Cell("K4").Value = equipments.budget_year_3;
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
ws.Cell("K4").Style.Font.FontName = "TH Sarabun New";
|
||||||
return File(stream, "text/csv");
|
ws.Cell("K4").Style.Font.FontSize = 12;
|
||||||
break;
|
ws.Cell("K4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("K4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("K4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("L4").Value = equipments.budget_year_4;
|
||||||
|
ws.Cell("L4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("L4").Style.Font.FontSize = 12;
|
||||||
|
ws.Cell("L4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("L4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("L4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("M4").Value = equipments.budget_year_5;
|
||||||
|
ws.Cell("M4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("M4").Style.Font.FontSize = 12;
|
||||||
|
ws.Cell("M4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("M4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("M4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("N2:O3").Merge().Value = "ใบเสนอราคาครุภัณฑ์ ปี " + equipments.academic_year;
|
||||||
|
ws.Cell("N2").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("N2").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("N2:O3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("N2:O3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("N2:O3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("N2").Style.Alignment.WrapText = true;
|
||||||
|
foreach (var equipment in equipments.data)
|
||||||
|
{
|
||||||
|
ws.Cell(row, 1).Value = no;
|
||||||
|
no++;
|
||||||
|
ws.Cell(row, 2).Value = equipment.list;
|
||||||
|
ws.Cell(row, 3).Value = equipment.type_1;
|
||||||
|
ws.Cell(row, 4).Value = equipment.type_2;
|
||||||
|
ws.Cell(row, 5).Value = equipment.type_3;
|
||||||
|
ws.Cell(row, 6).Value = equipment.unit;
|
||||||
|
ws.Cell(row, 7).Value = equipment.quantity;
|
||||||
|
ws.Cell(row, 8).Value = equipment.unit_price;
|
||||||
|
ws.Cell(row, 9).Value = equipment.price_1;
|
||||||
|
ws.Cell(row, 10).Value = equipment.price_2;
|
||||||
|
ws.Cell(row, 11).Value = equipment.price_3;
|
||||||
|
ws.Cell(row, 12).Value = equipment.price_4;
|
||||||
|
ws.Cell(row, 13).Value = equipment.price_5;
|
||||||
|
ws.Cell(row, 14).Value = equipment.amount;
|
||||||
|
ws.Cell(row, 15).Value = equipment.company;
|
||||||
|
ws.Cell(row, 16).Value = equipment.description;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.FontName =
|
||||||
|
"TH Sarabun New";
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 16)).Style.Font.FontSize = 12;
|
||||||
|
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.Alignment.Vertical =
|
||||||
|
XLAlignmentVerticalValues.Center;
|
||||||
|
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.Right;
|
||||||
|
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
|
ws.Cell(row, 16).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok();
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
var content = stream.ToArray();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
|
return File(
|
||||||
|
content,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
"equipment_" + date + ".xlsx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Route("reports/statement_of_equipment/{type}")]
|
[HttpPost, Route("reports/statement_of_equipment/{type}")]
|
||||||
[ApiExplorerSettings(GroupName = "reports")]
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
public IActionResult GetStEquipmentReport([FromRoute] string type, [FromBody] statement_of_equipment equipments)
|
public IActionResult GetStEquipmentReport([FromRoute] string type, [FromBody] statement_of_equipment equipments)
|
||||||
@@ -125,30 +341,35 @@ namespace rmutr_report.Controllers
|
|||||||
{
|
{
|
||||||
aa.sum1 = s1;
|
aa.sum1 = s1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.quantity == null)
|
if (b.quantity == null)
|
||||||
{
|
{
|
||||||
aa.sum1 = 0;
|
aa.sum1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.unit_price != null)
|
if (b.unit_price != null)
|
||||||
{
|
{
|
||||||
aa.sum2 = s2;
|
aa.sum2 = s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.unit_price == null)
|
if (b.unit_price == null)
|
||||||
{
|
{
|
||||||
aa.sum2 = 0;
|
aa.sum2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.amount != null)
|
if (b.amount != null)
|
||||||
{
|
{
|
||||||
aa.sum3 = s3;
|
aa.sum3 = s3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.amount == null)
|
if (b.amount == null)
|
||||||
{
|
{
|
||||||
aa.sum3 = 0;
|
aa.sum3 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _statement_of_equipment = new List<statement_of_equipment>() { equipments };
|
var _statement_of_equipment = new List<statement_of_equipment>() {equipments};
|
||||||
|
|
||||||
Report report = new Report();
|
Report report = new Report();
|
||||||
report.Load(_setting.report_path + "statement_of_equipment.frx");
|
report.Load(_setting.report_path + "statement_of_equipment.frx");
|
||||||
@@ -186,48 +407,327 @@ namespace rmutr_report.Controllers
|
|||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Route("reports/summary_building_construction/{type}")]
|
[HttpPost, Route("reports/summary_building_construction/{type}")]
|
||||||
[ApiExplorerSettings(GroupName = "reports")]
|
[ApiExplorerSettings(GroupName = "reports")]
|
||||||
public IActionResult GetSum2Report([FromRoute] string type, [FromBody] summary_building_construction summary_building_constructions)
|
public IActionResult GetSum2Report([FromRoute] string type,
|
||||||
|
[FromBody] List<summary_building_construction> summary_building_constructions)
|
||||||
{
|
{
|
||||||
|
|
||||||
var _summary_building_constructions = new List<summary_building_construction>() { summary_building_constructions };
|
|
||||||
|
|
||||||
Report report = new Report();
|
|
||||||
report.Load(_setting.report_path + "summary_building_constructions.frx");
|
|
||||||
report.RegisterData(_summary_building_constructions, "summary_building_construction");
|
|
||||||
report.Prepare();
|
|
||||||
|
|
||||||
MemoryStream stream = new MemoryStream();
|
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
case "pdf":
|
var workbook = new XLWorkbook();
|
||||||
PDFExport pdf = new PDFExport();
|
var ws = workbook.Worksheets.Add("รายการก่อสร้างอาคาร");
|
||||||
report.Export(pdf, stream);
|
var imagePath = @"C:\Users\Mercedes Benz\Documents\rmutr_report\wwwroot\Logo-RMUTR.png";
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
ws.AddPicture(imagePath).MoveTo(ws.Cell("A1")).Scale(0.3);
|
||||||
return File(stream, "application/pdf");
|
ws.Range("A4:A6").Merge().Value = "ลำดับความสำคัญ(1)";
|
||||||
|
ws.Range("A4:A6").Style.Alignment.WrapText = true;
|
||||||
|
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.Cell("A4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("A4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("A4:A6").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("B4:B6").Merge().Value = "รายการ";
|
||||||
|
ws.Cell("B4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("B4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("B4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("B4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("B4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("B4:B6").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("C4:C6").Merge().Value = "จำนวน";
|
||||||
|
ws.Cell("C4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("C4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("C4:C6").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("C4:C6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("C4:C6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("C4:C6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("C4").Style.Alignment.SetTextRotation(90);
|
||||||
|
ws.Range("D4:F4").Merge().Value = "อายุการใช้งาน";
|
||||||
|
ws.Cell("D4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("D4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("D4:F4").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("D4:F4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("D4:F4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("D4:F4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("D5").Value = "ต่ำกว่า 10 ปี";
|
||||||
|
ws.Cell("D5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("D5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("D5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("D5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("D5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("D5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("E5").Value = "10-20 ปี";
|
||||||
|
ws.Cell("E5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("E5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("E5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("E5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("E5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("E5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("F5").Value = "มากกว่า 20 ปี";
|
||||||
|
ws.Cell("F5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("F5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("F5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("F5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("F5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("F5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("D5:F5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Cell("D6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("E6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("F6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("G4:G6").Merge().Value = "ปัญหาของอาคาร";
|
||||||
|
ws.Cell("G4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("G4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("G4:G6").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("G4:G6").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("G4:G6").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("G4:G6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("H4:I4").Merge().Value = "ประเภท";
|
||||||
|
ws.Cell("H4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("H4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("H4:I4").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("H4:I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("H4:I4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("H4:I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("H5").Value = "ทดแทนอาคารเดิม";
|
||||||
|
ws.Cell("H5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("H5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("H5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("H5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("H5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("H5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("I5").Value = "อาคารใหม่";
|
||||||
|
ws.Cell("I5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("I5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("I5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("I5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("I5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("I5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("H5:I5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("J4:J5").Merge().Value = "ปรับปรุง/ซ่อมแซม/ต่อเติม";
|
||||||
|
ws.Range("J4:J5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("J4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("J4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("J4:J5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("J4:J5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("J4:J5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("J4:J5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("J6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("I6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("H6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("K4:K5").Merge().Value = "วงเงินที่จะเสนอของบประมาณ";
|
||||||
|
ws.Range("K4:K5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("K4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("K4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("K4:K5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("K4:K5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("K4:K5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("K4:K5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("K6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("L4:P4").Merge().Value = "ปีงบประมาณที่จะเสนอขอ";
|
||||||
|
ws.Range("L4:P4").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("L4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("L4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("L4:P4").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("L4:P4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("L4:P4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("L4:P4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("L6:P6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("Q5").Value = "BOQ";
|
||||||
|
ws.Cell("Q5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("Q5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("Q5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("Q5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("Q5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("Q5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("R5").Value = "แบบรูป";
|
||||||
|
ws.Cell("R5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("R5").Style.Font.FontSize = 10;
|
||||||
|
ws.Range("Q5:R5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Cell("R5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("R5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("R5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("Q6:R6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("S4:S5").Merge().Value = "คำอธิบาย";
|
||||||
|
ws.Range("S4:S5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("S4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("S4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("S4:S5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("S4:S5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("S4:S5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("S4:S5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("S6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Row(4).Height = 30;
|
||||||
|
ws.Row(5).Height = 30;
|
||||||
|
ws.Row(6).Height = 30;
|
||||||
|
ws.Column(1).Width = 10;
|
||||||
|
ws.Column(2).Width = 40;
|
||||||
|
ws.Column(3).Width = 5;
|
||||||
|
ws.Column(4).Width = 5;
|
||||||
|
ws.Column(5).Width = 5;
|
||||||
|
ws.Column(6).Width = 5;
|
||||||
|
ws.Column(7).Width = 30;
|
||||||
|
ws.Column(8).Width = 5;
|
||||||
|
ws.Column(9).Width = 5;
|
||||||
|
ws.Column(10).Width = 10;
|
||||||
|
ws.Column(11).Width = 20;
|
||||||
|
ws.Column(12).Width = 5;
|
||||||
|
ws.Column(13).Width = 5;
|
||||||
|
ws.Column(14).Width = 5;
|
||||||
|
ws.Column(15).Width = 5;
|
||||||
|
ws.Column(16).Width = 5;
|
||||||
|
ws.Column(17).Width = 15;
|
||||||
|
ws.Column(18).Width = 15;
|
||||||
|
ws.Column(19).Width = 40;
|
||||||
|
|
||||||
case "xls":
|
int row = 7;
|
||||||
Excel2007Export excel = new Excel2007Export();
|
int no = 1;
|
||||||
report.Export(excel, stream);
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
foreach (var build in summary_building_constructions)
|
||||||
return File(stream, "application/vnd.ms-excel");
|
{
|
||||||
break;
|
if (summary_building_constructions != null)
|
||||||
case "mht":
|
{
|
||||||
MHTExport mht = new MHTExport();
|
//string first = "สรุปแผนความต้องการ รายการก่อสร้างอาคารหรือสิ่งก่อสร้างและปรับปรุงซ่อมแซมต่อเติม ของมหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
|
||||||
report.Export(mht, stream);
|
string second = "ปีงบประมาณ " + build.academic_year_name_th + " " + build.header_name;
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
string third = "หน่วยงาน/คณะ " + build.agency_name_th + " พื้นที่ " + build.location;
|
||||||
return File(stream, "multipart/related");
|
ws.Range("A1:S1").Merge().Value = "สรุปแผนความต้องการ รายการก่อสร้างอาคารหรือสิ่งก่อสร้างและปรับปรุงซ่อมแซมต่อเติม ของมหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์";
|
||||||
break;
|
ws.Range("A1:S1").Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
case "csv":
|
ws.Range("A1:S1").Merge().Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
CSVExport csv = new CSVExport();
|
ws.Range("A2:S2").Merge().Value = second;
|
||||||
report.Export(csv, stream);
|
ws.Range("A2:S2").Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
ws.Range("A2:S2").Merge().Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
return File(stream, "text/csv");
|
ws.Range("A3:S3").Merge().Value = third;
|
||||||
break;
|
ws.Range("A3:S3").Merge().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("A3:S3").Merge().Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("A1:A3").Style.Font.Bold = true;
|
||||||
|
ws.Range("A1:A3").Style.Font.FontSize = 16;
|
||||||
|
ws.Range("A1:A3").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("L5").Value = build.budget_year_1;
|
||||||
|
ws.Cell("L5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("L5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("L5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("L5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("L5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("L5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("M5").Value = build.budget_year_2;
|
||||||
|
ws.Cell("M5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("M5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("M5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("M5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("M5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("M5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("N5").Value = build.budget_year_3;
|
||||||
|
ws.Cell("N5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("N5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("N5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("N5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("N5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("N5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("O5").Value = build.budget_year_4;
|
||||||
|
ws.Cell("O5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("O5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("O5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("O5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("O5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("O5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell("P5").Value = build.budget_year_5;
|
||||||
|
ws.Cell("P5").Style.Alignment.WrapText = true;
|
||||||
|
ws.Cell("P5").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("P5").Style.Font.FontSize = 10;
|
||||||
|
ws.Cell("P5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell("P5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Cell("P5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("L5:P5").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Range("Q4:R4").Merge().Value = "ความพร้อมสิ่งก่อสร้าง ปี "+build.academic_year;
|
||||||
|
ws.Range("Q4:R4").Style.Fill.BackgroundColor = XLColor.MistyRose;
|
||||||
|
ws.Cell("Q4").Style.Font.FontName = "TH Sarabun New";
|
||||||
|
ws.Cell("Q4").Style.Font.FontSize = 14;
|
||||||
|
ws.Range("Q4:R4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Range("Q4:R4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||||
|
ws.Range("Q4:R4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("L6:R6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range("D6:F6").Style.Fill.BackgroundColor = XLColor.Gainsboro;
|
||||||
|
ws.Range("H6:S6").Style.Fill.BackgroundColor = XLColor.Gainsboro;
|
||||||
|
foreach (var building in build.data)
|
||||||
|
{
|
||||||
|
ws.Cell(row, 1).Value = no;
|
||||||
|
no++;
|
||||||
|
ws.Cell(row, 2).Value = building.list;
|
||||||
|
ws.Cell(row, 3).Value = building.total;
|
||||||
|
ws.Cell(row, 4).Value = building.lesser;
|
||||||
|
ws.Cell(row, 5).Value = building.between;
|
||||||
|
ws.Cell(row, 6).Value = building.over;
|
||||||
|
ws.Cell(row, 7).Value = building.problem;
|
||||||
|
ws.Cell(row, 8).Value = building.type_1;
|
||||||
|
ws.Cell(row, 9).Value = building.type_2;
|
||||||
|
ws.Cell(row, 10).Value = building.renovated;
|
||||||
|
ws.Cell(row, 11).Value = building.budget;
|
||||||
|
ws.Cell(row, 12).Value = building.price_1;
|
||||||
|
ws.Cell(row, 13).Value = building.price_2;
|
||||||
|
ws.Cell(row, 14).Value = building.price_3;
|
||||||
|
ws.Cell(row, 15).Value = building.price_4;
|
||||||
|
ws.Cell(row, 16).Value = building.price_5;
|
||||||
|
ws.Cell(row, 17).Value = building.boq;
|
||||||
|
ws.Cell(row, 18).Value = building.image;
|
||||||
|
ws.Cell(row, 19).Value = building.description;
|
||||||
|
ws.Cell(row, 1).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 12).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 13).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 18).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Cell(row, 19).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName =
|
||||||
|
"TH Sarabun New";
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontSize = 11;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true;
|
||||||
|
ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical =
|
||||||
|
XLAlignmentVerticalValues.Center;
|
||||||
|
ws.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.Left;
|
||||||
|
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.Cell(row, 11).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell(row, 12).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 13).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 14).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 15).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 16).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
||||||
|
ws.Cell(row, 17).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell(row, 18).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||||
|
ws.Cell(row, 19).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
workbook.SaveAs(stream);
|
||||||
|
var content = stream.ToArray();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||||
|
return File(
|
||||||
|
content,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
"building_" + date + ".xlsx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ namespace rmutr_report.Models
|
|||||||
{
|
{
|
||||||
public string header_1 { get; set; }
|
public string header_1 { get; set; }
|
||||||
public string header_2 { get; set; }
|
public string header_2 { get; set; }
|
||||||
public string header_3 { get; set; }
|
//public string header_3 { get; set; }
|
||||||
public List<kpi_data_details> data { get; set; }
|
public List<kpi_data_details> data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace rmutr_report.Models
|
|||||||
|
|
||||||
public class summary_building_construction_detail
|
public class summary_building_construction_detail
|
||||||
{
|
{
|
||||||
public int? no { get; set; }
|
//public int? no { get; set; }
|
||||||
public string list { get; set; }
|
public string list { get; set; }
|
||||||
public decimal? total { get; set; }
|
public decimal? total { get; set; }
|
||||||
public string lesser { get; set; }
|
public string lesser { get; set; }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace rmutr_report.Models
|
|||||||
|
|
||||||
public class summary_of_equipment_five_year_detail
|
public class summary_of_equipment_five_year_detail
|
||||||
{
|
{
|
||||||
public int? no { get; set; }
|
//public int? no { get; set; }
|
||||||
public string list { get; set; }
|
public string list { get; set; }
|
||||||
public string type_1 { get; set; }
|
public string type_1 { get; set; }
|
||||||
public string type_2 { get; set; }
|
public string type_2 { get; set; }
|
||||||
|
|||||||
15622
obj/Debug/net5.0/project.razor.json
Normal file
15622
obj/Debug/net5.0/project.razor.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user