diff --git a/src/main/java/com/zh/project0512/controller/UtilsController.java b/src/main/java/com/zh/project0512/controller/UtilsController.java index 815c478..03e4517 100644 --- a/src/main/java/com/zh/project0512/controller/UtilsController.java +++ b/src/main/java/com/zh/project0512/controller/UtilsController.java @@ -91,12 +91,12 @@ public class UtilsController { file.transferTo(dest); JSONObject res = new JSONObject(); int fileTypeNum = FileTypeUtil.getcontentTypeNum((fileName.substring(fileName.lastIndexOf(".")))); + res.put("fileUrl", "/upload/" + newFileName); res.put("fileName", fileName); - res.put("duration", new MultimediaObject(dest).getInfo().getDuration()); res.put("fileType", FileTypeUtil.getcontentType((fileName.substring(fileName.lastIndexOf("."))))); res.put("fileTypeNum", fileTypeNum); if (fileTypeNum == 1) { - res.put("fileUrl", "/upload/" + newFileName); + res.put("duration", new MultimediaObject(dest).getInfo().getDuration()); } return Result.success(res, "上传完成"); } catch (Exception e) { diff --git a/src/main/java/com/zh/project0512/utils/ExcelUtil.java b/src/main/java/com/zh/project0512/utils/ExcelUtil.java index f97d87b..a0980cd 100644 --- a/src/main/java/com/zh/project0512/utils/ExcelUtil.java +++ b/src/main/java/com/zh/project0512/utils/ExcelUtil.java @@ -30,10 +30,17 @@ public class ExcelUtil { sheet.autoSizeColumn(0); // 在sheet中添加标题行// 行数从0开始 Row row = sheet.createRow((int) 0); - for (int i = 0; i < array.length; i++) { - Cell cell = row.createCell(i); - cell.setCellValue(array[i]); +// for (int i = 0; i < array.length; i++) { +// Cell cell = row.createCell(i); +// cell.setCellValue(array[i]); +// cell.setCellStyle(titleStyle); +// } + int titleIndex = 0; + for (Object key : list.get(0).keySet()) { + Cell cell = row.createCell(titleIndex); + cell.setCellValue((String) list.get(0).get(key)); cell.setCellStyle(titleStyle); + titleIndex += 1; } // 数据样式 因为标题和数据样式不同 需要分开设置 不然会覆盖 CellStyle dataStyle = wb.createCellStyle();