Commit 17a46be1 authored by yanzg's avatar yanzg

Excel导出功能

parent f52aa9b7
...@@ -559,7 +559,7 @@ public class ObjectHelper { ...@@ -559,7 +559,7 @@ public class ObjectHelper {
public static <T> ArrayList<T> getList(Class<T> cls, Object froms) { public static <T> ArrayList<T> getList(Class<T> cls, Object froms) {
ArrayList<T> tos = new ArrayList<T>(); ArrayList<T> tos = new ArrayList<T>();
if (froms instanceof List) { if (froms instanceof List) {
List vCodeFrom = (List) ((froms instanceof List) ? froms : new ArrayList<>()); List vCodeFrom = (List) froms;
for (Object from : vCodeFrom) { for (Object from : vCodeFrom) {
if (StringHelper.isEmpty(from)) { if (StringHelper.isEmpty(from)) {
continue; continue;
......
...@@ -92,9 +92,14 @@ public class FileHelper { ...@@ -92,9 +92,14 @@ public class FileHelper {
if (file.exists()) { if (file.exists()) {
throw new CodeException("文件删除失败"); throw new CodeException("文件删除失败");
} }
// 创建文件 // 创建文件夹
file.getParentFile().mkdirs(); File parentFile = file.getParentFile();
if (parentFile != null && !parentFile.exists()) {
parentFile.mkdirs();
}
if (!parentFile.exists()) {
throw new CodeException("创建文件夹失败");
}
file.createNewFile(); file.createNewFile();
// 写入文件 // 写入文件
RandomAccessFile raf = new RandomAccessFile(file, "rwd"); RandomAccessFile raf = new RandomAccessFile(file, "rwd");
......
...@@ -336,8 +336,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -336,8 +336,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
workbook = null; workbook = null;
} }
File file = new File(this.getFileName()); File file = new File(this.getFileName());
if (file.exists()) { if (file.exists() && file.delete()) {
file.delete();
} }
return this; return this;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment