2 Commits f2f185c900 ... 4dd68c72c1

Author SHA1 Message Date
  大数据与最优化研究所 4dd68c72c1 excel导出数据BigDecimal格式 1 day ago
  大数据与最优化研究所 ace6b29fdb excel导出数据BigDecimal格式 1 day ago

+ 14 - 10
src/main/java/com/xjrsoft/module/form/controller/FormExecuteController.java

@@ -47,6 +47,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.sql.Date;
 import java.sql.SQLException;
 import java.sql.Time;
@@ -78,6 +79,8 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class FormExecuteController {
 
+    private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
     private final IFormExecuteService formExecuteService;
     
     private final IFormReleaseService formReleaseService;
@@ -316,19 +319,20 @@ public class FormExecuteController {
                     }
 
                     // 检查类层次结构
-                    if (value instanceof Integer) {
+                    if (value == null) {
+                        value = "";
+                    } else if (value instanceof Integer) {
                         value = Integer.toString((Integer) value);
-                    }
-                    if (value instanceof Double) {
+                    } else if (value instanceof Double) {
                         value = Double.toString((Double) value);
-                    }
-                    if (value instanceof Long) {
+                    } else 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);
+                    } else if (value instanceof BigDecimal) {
+                        value = ((BigDecimal) value).toPlainString();
+                    } else if (value instanceof Date) {
+                        value = DATE_FORMATTER.format((Date) value);
+                    } else {
+                        value = value.toString(); // 默认处理其他类型的对象
                     }
 
                     Cell cell = dataRow.createCell(i);