Browse Source

excel模板导出和数据导出列宽

大数据与最优化研究所 1 day ago
parent
commit
f2f185c900

+ 6 - 1
src/main/java/com/xjrsoft/module/form/controller/FormExecuteController.java

@@ -51,6 +51,7 @@ import java.sql.Date;
 import java.sql.SQLException;
 import java.sql.Time;
 import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
@@ -315,7 +316,6 @@ public class FormExecuteController {
                     }
 
                     // 检查类层次结构
-
                     if (value instanceof Integer) {
                         value = Integer.toString((Integer) value);
                     }
@@ -325,6 +325,11 @@ public class FormExecuteController {
                     if (value instanceof Long) {
                         value = Long.toString((Long) value);
                     }
+                    if (value instanceof Date) {
+                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        // 将Date对象格式化为字符串
+                        value = formatter.format((Date) value);
+                    }
 
                     Cell cell = dataRow.createCell(i);
                     cell.setCellValue((String)value);