Skip to content

Commit 89b57de

Browse files
committed
增加一个直接保存List的静态方法
1 parent 517fa76 commit 89b57de

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/main/java/seven/ExcelFactory.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private ExcelFactory() {
4646
* @return
4747
* @throws Exception
4848
*/
49-
public static Wrapper getBeans(String FilePath, WrapperObj r) throws Exception {
49+
public static Wrapper getBeans(String FilePath, WrapperObj r) throws Exception {
5050
return (Wrapper)r.init(FilePath);
5151
}
5252

@@ -67,6 +67,23 @@ public static SaveExcel saveExcel(List<? extends Object> bean, String FilePath)
6767
return new ResExprotObj((List)bean, FilePath);
6868
}
6969

70+
/**
71+
* 保存Excel
72+
* @param bean
73+
* @return
74+
* @throws Exception
75+
*/
76+
public static SaveExcel saveExcel(List<? extends Object> bean) throws Exception {
77+
if (bean.size() < 1) {
78+
throw new Exception("请传入数据");
79+
}
80+
if (bean.get(0) instanceof Map) {
81+
return new ResExprotMap((List<Map>) bean);
82+
}
83+
return new ResExprotObj((List)bean);
84+
}
85+
86+
7087
/**
7188
* 保存Excel
7289
* @param resultSet

src/main/java/seven/savewapper/wapperRef/sysWppers/ResExprotMap.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public ResExprotMap(ResultSet resultSet, String path) {
4040
public ResExprotMap(ResultSet resultSet) {
4141
super(resultSet);
4242
}
43+
public ResExprotMap(List<Map> list) {
44+
super(list);
45+
}
4346

4447

4548
@Override

0 commit comments

Comments
 (0)