|
@@ -3,6 +3,7 @@ package com.gree.mall.manager.utils.excel;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
@@ -188,6 +189,15 @@ public class ExcelUtils {
|
|
|
public static void createExcel(String filePath,ExcelData excelData) throws IOException {
|
|
|
OutputStream out = null;
|
|
|
try {
|
|
|
+ File file = new File(filePath);
|
|
|
+
|
|
|
+ // 确保文件路径存在
|
|
|
+ if (!file.getParentFile().exists()) {
|
|
|
+ // 尝试创建父目录
|
|
|
+ if (!file.getParentFile().mkdirs()) {
|
|
|
+ log.info("无法创建文件夹");
|
|
|
+ }
|
|
|
+ }
|
|
|
//标题
|
|
|
List<List<String>> titles = new ArrayList<>();
|
|
|
for(String title : excelData.getTitles()){
|