hankunkun 10 сар өмнө
parent
commit
3a3b6f3136

+ 7 - 7
src/main/java/ieven/server/webapp/domain/exporter/Exporter.java

@@ -106,7 +106,7 @@ public class Exporter {
         Fields fields =
                 mongoTemplate.findOne(new Query(Criteria.where("fileId").is(fileId)), Fields.class);
         String date = DataUtils.currentDate().replaceAll(":", "_");
-        filename = filename + date + ".csv";
+        filename = filename + date + ".xlsx";
         if (fields == null) {
             return "";
         }
@@ -125,7 +125,7 @@ public class Exporter {
             throws Exception {
         Fields fields =
                 mongoTemplate.findOne(new Query(Criteria.where("fileId").is(fileId)), Fields.class);
-        String path = tmpdir + File.separator + filename + ".csv";
+        String path = tmpdir + File.separator + filename + ".xlsx";
         if (fields == null) {
             return "";
         }
@@ -143,7 +143,7 @@ public class Exporter {
     public String generateCsv(Fields fields, String filename, String filePath, MongoCursor<Document> cursor) throws Exception {
         LinkedHashMap<String, String> headers = fields.getFields();
         LinkedHashMap<String, String> headersReverse = fields.getFieldsReverse();
-        filePath = filePath + File.separator + filename + ".csv";
+        filePath = filePath + File.separator + filename + ".xlsx";
 
         FileWriter writer = new FileWriter(filePath);
         StringBuilder header = new StringBuilder();
@@ -198,7 +198,7 @@ public class Exporter {
         if (sheet == null) {
             sheet = wb.createSheet("sheet" + currentSheetNum);
         }
-        filePath = filePath + File.separator + filename + ".csv";
+        filePath = filePath + File.separator + filename + ".xlsx";
         // 创建表头
         cRow = sheet.createRow(0);
         int hcIndex = 0;
@@ -255,7 +255,7 @@ public class Exporter {
         headersReverse.put("测试1", "测试1");
         headersReverse.put("测试2", "测试2");
         headersReverse.put("测试3", "测试3");
-        filePath = filePath + File.separator + filename + ".csv";
+        filePath = filePath + File.separator + filename + ".xlsx";
 
         FileWriter writer = new FileWriter(filePath);
         StringBuilder header = new StringBuilder();
@@ -325,7 +325,7 @@ public class Exporter {
         if (sheet == null) {
             sheet = wb.createSheet("sheet" + currentSheetNum);
         }
-        filePath = filePath + File.separator + filename + ".csv";
+        filePath = filePath + File.separator + filename + ".xlsx";
         // 创建表头
         cRow = sheet.createRow(0);
         int hcIndex = 0;
@@ -411,7 +411,7 @@ public class Exporter {
             boolean created = file.mkdirs();
             log.info(created ? "创建文件夹成功" : "创建文件夹失败");
         }
-        filePath = filePath + File.separator + filename + ".csv";
+        filePath = filePath + File.separator + filename + ".xlsx";
         log.info("导出路径:" + filePath);
         FileOutputStream fOut = new FileOutputStream(filePath);
         wb.write(fOut);