From 0dcabaa25dde835d7babf4683843c22360bef22c Mon Sep 17 00:00:00 2001 From: Harid Promsri <52228846+Harid-999@users.noreply.github.com> Date: Tue, 7 Oct 2025 17:15:32 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=88=E0=B8=B1=E0=B8=94=20Align=20(#1846)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: harid --- .../Controllers/LeaveReportController.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/BMA.EHR.Leave/Controllers/LeaveReportController.cs b/BMA.EHR.Leave/Controllers/LeaveReportController.cs index f897e075..2ef225dc 100644 --- a/BMA.EHR.Leave/Controllers/LeaveReportController.cs +++ b/BMA.EHR.Leave/Controllers/LeaveReportController.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Routing.Template; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OfficeOpenXml; +using OfficeOpenXml.Style; using Swashbuckle.AspNetCore.Annotations; using System.Globalization; using System.Security.Claims; @@ -2227,6 +2228,21 @@ namespace BMA.EHR.Leave.Service.Controllers range.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; range.Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; range.Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; + range.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top; + + // Center Align: คอลัมน์ 1 (A), 3 (C), 4 (D), 6 (F), 7 (G), 9 (I) + var centerColumns = new[] { 1, 3, 4, 6, 7, 9 }; + foreach (var col in centerColumns) + { + worksheet.Cells[startRow, col, startRow + totalRows - 1, col].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; + } + + // Left Align: คอลัมน์ 2 (B), 5 (E), 8 (H), 10 (J) + var leftColumns = new[] { 2, 5, 8, 10 }; + foreach (var col in leftColumns) + { + worksheet.Cells[startRow, col, startRow + totalRows - 1, col].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; + } } // ส่วนสรุปท้ายตาราง