修复配置导入Excel文件存在空行时,错误信息行号与文件行号对不上bug
This commit is contained in:
@@ -432,12 +432,14 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
|
|||||||
Map<String, Map<String, Object>> dictMap = new HashMap<String,Map<String, Object>>();
|
Map<String, Map<String, Object>> dictMap = new HashMap<String,Map<String, Object>>();
|
||||||
Object val1 = null;
|
Object val1 = null;
|
||||||
for (int i = 0, len = dataList.size(); i < len; i++) {
|
for (int i = 0, len = dataList.size(); i < len; i++) {
|
||||||
E e = (E)cls.newInstance();
|
List<Object> row=dataList.get(i);
|
||||||
if(i<=headerNum) {
|
//boolean flag = row.stream().allMatch(obj -> "".equals(obj));
|
||||||
|
if(i <= headerNum || row.size() == 0) {// 跳过第一行和空行
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
E e = (E)cls.newInstance();
|
||||||
int column = 0;
|
int column = 0;
|
||||||
List<Object> row=dataList.get(i);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Object[] os : annotationList){
|
for (Object[] os : annotationList){
|
||||||
Object val=row.get(column);
|
Object val=row.get(column);
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ public abstract class XLSXCovertCSVReader {
|
|||||||
// private String[] record;
|
// private String[] record;
|
||||||
// private List<String[]> rows = new ArrayList<String[]>();
|
// private List<String[]> rows = new ArrayList<String[]>();
|
||||||
private boolean isCellNull = false;
|
private boolean isCellNull = false;
|
||||||
|
|
||||||
|
private int upRowId; // 记录上一行行号
|
||||||
/**
|
/**
|
||||||
* Accepts objects needed while parsing.
|
* Accepts objects needed while parsing.
|
||||||
*
|
*
|
||||||
@@ -203,8 +204,23 @@ public abstract class XLSXCovertCSVReader {
|
|||||||
if (this.formatString == null)
|
if (this.formatString == null)
|
||||||
this.formatString = BuiltinFormats
|
this.formatString = BuiltinFormats
|
||||||
.getBuiltinFormat(this.formatIndex);
|
.getBuiltinFormat(this.formatIndex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}else if("row".equals(name)) {
|
||||||
|
// 获取行号
|
||||||
|
String r = attributes.getValue("r");
|
||||||
|
int index = Integer.parseInt(r);
|
||||||
|
|
||||||
|
int gap = index - upRowId;
|
||||||
|
if(gap > 1) { // 存在空行
|
||||||
|
while(gap > 1) {
|
||||||
|
optRows(sheetIndex,lastColumnNumber,rowlist);
|
||||||
|
gap--;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
upRowId = index;
|
||||||
|
}
|
||||||
lastContents = "";
|
lastContents = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user