fixed format number

This commit is contained in:
kamonwan taengsuk
2023-06-28 10:54:05 +07:00
parent 0ed7123115
commit fcfbb5626f
7 changed files with 44 additions and 43 deletions

View File

@@ -411,7 +411,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.national_budget_details)
{
@@ -429,7 +429,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -463,7 +463,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -497,7 +497,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -529,7 +529,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -564,7 +564,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -594,28 +594,29 @@ namespace rmutr_report.Controllers
report.Prepare();
MemoryStream stream = new MemoryStream();
if (type == "pdf")
switch (type)
{
workbook.SaveAs(stream);
var content = stream.ToArray();
stream.Position = 0;
// Set the content type and return the PDF file
return File(content, "application/pdf", "converted.pdf");
}
if (type == "xlsx")
{
workbook.SaveAs(stream);
var content = stream.ToArray();
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"basic_plan_" + date + ".xlsx");
case "pdf":
{
workbook.SaveAs(stream);
var content = stream.ToArray();
stream.Position = 0;
// Set the content type and return the PDF file
return File(content, "application/pdf", "converted.pdf");
}
case "xlsx":
{
workbook.SaveAs(stream);
var content = stream.ToArray();
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
return File(
content,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"basic_plan_" + date + ".xlsx");
}
default:
return Ok();
}
return Ok();
}
[HttpPost, Route("reports/integration_strategic_plan/{type}")]
@@ -797,7 +798,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.integration_strategic_plan_details)
{
@@ -820,7 +821,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -870,7 +871,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -919,7 +920,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -968,7 +969,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 11)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -1232,7 +1233,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(5, 2), ws.Cell(5, 15)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.integration_strategic_plan_details)
{
@@ -1259,7 +1260,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -1320,7 +1321,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
@@ -1381,7 +1382,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -1441,7 +1442,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
@@ -1502,7 +1503,7 @@ namespace rmutr_report.Controllers
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.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 15)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 15)).Style.Border.OutsideBorder =
XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;

View File

@@ -6269,7 +6269,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontName = "TH SarabunPSK";
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontSize = 14;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.Font.FontColor = XLColor.Blue;
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(5, 2), ws.Cell(5, 6)).Style.NumberFormat.SetFormat("#,#0");
foreach (var detail in personnel.national_budget_details)
{
@@ -6287,7 +6287,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
@@ -6319,7 +6319,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
@@ -6350,7 +6350,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
@@ -6380,7 +6380,7 @@ namespace rmutr_report.Controllers
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.WrapText = true;
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Alignment.Vertical =
XLAlignmentVerticalValues.Center;
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#");
ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.NumberFormat.SetFormat("#,#0");
ws.Range(ws.Cell(row, 1), ws.Cell(row, 6)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;

View File

@@ -1 +1 @@
f2347ed1bcc09b6148623823522308b3e2a73432
ea26ea84899ae618caf9974b39c318714cc0cbc6