From 1d65080507934686bd2b3a8035fb8727b6f2c80b Mon Sep 17 00:00:00 2001 From: Yelli <51317527+Yeleights@users.noreply.github.com> Date: Thu, 26 Dec 2019 15:27:23 +0800 Subject: [PATCH] #1300 Add right alignment function in sql email content (#1542) * modify FileUtils.readFile2Str * #1300 Add right alignment function in sql email content * cancel formatted for alert_mail_template.ftl --- .../apache/dolphinscheduler/alert/utils/ExcelUtils.java | 7 +++++++ .../main/resources/mail_templates/alert_mail_template.ftl | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java index 2aee3d4ef6..c051450841 100644 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java +++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java @@ -20,6 +20,8 @@ import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,10 +73,14 @@ public class ExcelUtils { //set the height of the first line row.setHeight((short)500); + //set Horizontal right + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.RIGHT); //setting excel headers for (int i = 0; i < headerList.size(); i++) { HSSFCell cell = row.createCell(i); + cell.setCellStyle(cellStyle); cell.setCellValue(headerList.get(i)); } @@ -88,6 +94,7 @@ public class ExcelUtils { rowIndex++; for (int j = 0 ; j < values.length ; j++){ HSSFCell cell1 = row.createCell(j); + cell1.setCellStyle(cellStyle); cell1.setCellValue(String.valueOf(values[j])); } } diff --git a/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl b/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl index c638609090..1ca9cab17e 100644 --- a/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl +++ b/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl @@ -14,4 +14,4 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - dolphinscheduler<#if title??> ${title}<#if content??> ${content}
\ No newline at end of file + dolphinscheduler<#if title??> ${title}<#if content??> ${content}
\ No newline at end of file