Skip to content

Commit e03a791

Browse files
committed
支持DB查询直接导出excel
1 parent 6fc2896 commit e03a791

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package seven.savewapper.wapperRef.sysWppers;
2+
//=======================================================
3+
// .----.
4+
// _.'__ `.
5+
// .--(^)(^^)---/!\
6+
// .' @ /!!!\
7+
// : , !!!!
8+
// `-..__.-' _.-\!!!/
9+
// `;_: `"'
10+
// .'"""""`.
11+
// /, ya ,\\
12+
// //¹·Éñ±£ÓÓ\\
13+
// `-._______.-'
14+
// ___`. | .'___
15+
// (______|______)
16+
//=======================================================
17+
18+
import java.sql.ResultSet;
19+
import java.sql.ResultSetMetaData;
20+
import java.util.ArrayList;
21+
import java.util.HashMap;
22+
23+
/**
24+
* [Zhihu]https://www.zhihu.com/people/Sweets07
25+
* [Github]https://github.com/MatrixSeven
26+
* Created by seven on 2017/1/1.
27+
*/
28+
public class ResExprotDBMap extends ResExprotMap {
29+
30+
public ResExprotDBMap(ResultSet resultSet, String path) {
31+
super(resultSet, path);
32+
}
33+
34+
public ResExprotMap CreateList() throws Exception {
35+
this.list = new ArrayList<>();
36+
HashMap<String, String> stringStringHashMap;
37+
if (resultSet != null) {
38+
stringStringHashMap = new HashMap<>();
39+
ResultSetMetaData res = resultSet.getMetaData();
40+
int index = res.getColumnCount() + 1;
41+
while (resultSet.next()) {
42+
for (int i = 0; i < index; i++) {
43+
stringStringHashMap.put(res.getColumnName(i),
44+
resultSet.getString(res.getColumnName(i)));
45+
}
46+
list.add(stringStringHashMap);
47+
}
48+
}
49+
return this;
50+
}
51+
52+
@Override
53+
public void Save() throws Exception {
54+
CreateList().Save();
55+
}
56+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package seven.savewapper.wapperRef.sysWppers;
2+
//=======================================================
3+
// .----.
4+
// _.'__ `.
5+
// .--(^)(^^)---/!\
6+
// .' @ /!!!\
7+
// : , !!!!
8+
// `-..__.-' _.-\!!!/
9+
// `;_: `"'
10+
// .'"""""`.
11+
// /, ya ,\\
12+
// //¹·Éñ±£ÓÓ\\
13+
// `-._______.-'
14+
// ___`. | .'___
15+
// (______|______)
16+
//=======================================================
17+
18+
import seven.callBack.PackageDataInterface;
19+
20+
import java.sql.ResultSet;
21+
import java.util.ArrayList;
22+
23+
/**
24+
* [Zhihu]https://www.zhihu.com/people/Sweets07
25+
* [Github]https://github.com/MatrixSeven
26+
* Created by seven on 2017/1/1.
27+
*/
28+
public class ResExprotDBObj extends ResExprotObj{
29+
protected PackageDataInterface dataInterface;
30+
// protected T type;
31+
public ResExprotDBObj(ResultSet resultSet, String path, PackageDataInterface dataInterface) {
32+
super(resultSet, path);
33+
this.dataInterface=dataInterface;
34+
// Type sType = getClass().getGenericSuperclass();
35+
// Type[] generics = ((ParameterizedType) sType).getActualTypeArguments();
36+
// Class<T> mTClass = (Class<T>) (generics[0]);
37+
// try {
38+
// type = mTClass.newInstance();
39+
// } catch (Exception e) {
40+
// e.printStackTrace();
41+
// }
42+
43+
}
44+
45+
public ResExprotDBObj CreateList() throws Exception {
46+
this.list=new ArrayList<>();
47+
// T o= (T) type.getClass().newInstance();
48+
while (resultSet.next()){
49+
list.add(dataInterface.PackageDataProcess(resultSet));
50+
}
51+
return this;
52+
}
53+
54+
@Override
55+
public void Save() throws Exception {
56+
CreateList().Save();
57+
}
58+
}

0 commit comments

Comments
 (0)