Skip to content

Commit 0f02f33

Browse files
committed
处理数据源为空引起的空指针问题
1 parent 8b353ac commit 0f02f33

4 files changed

Lines changed: 7 additions & 0 deletions

File tree

ExcelReads.jar

-2.25 KB
Binary file not shown.

src/main/java/seven/savewapper/wapperRef/SaveExcelObject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@ public SaveExcelObject FilterCol(DataFilterColumnInterface df) {
7474
}
7575
return this;
7676
}
77+
protected void checkData() throws Exception {
78+
if (this.list.isEmpty()) {
79+
throw new Exception("数据为空,请检查数据源");
80+
}
81+
}
7782
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public ResExprotMap(ResultSet resultSet, String path) {
4444
public void Save() throws Exception {
4545
Workbook wk = ExcelTool.newInstance(path, true);
4646
OutputStream out = new FileOutputStream(path);
47+
checkData();
4748
if (c != null) {
4849
list.sort(c);
4950
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public ResExprotObj(ResultSet resultSet, String path) {
4444
public void Save() throws Exception {
4545
Workbook wk = ExcelTool.newInstance(path, true);
4646
OutputStream out = new FileOutputStream(path);
47+
checkData();
4748
Class<?> clazz = list.get(0).getClass();
4849
Field[] fields = ExcelTool.GetFilesDeep(clazz);
4950
String[] title = new String[fields.length];

0 commit comments

Comments
 (0)