修复配置导入Excel文件存在空行时,错误信息行号与文件行号对不上bug

This commit is contained in:
zhangwenqing
2019-03-25 10:00:31 +08:00
parent 253adc1396
commit a1ad694260
2 changed files with 24 additions and 6 deletions

View File

@@ -432,12 +432,14 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
Map<String, Map<String, Object>> dictMap = new HashMap<String,Map<String, Object>>();
Object val1 = null;
for (int i = 0, len = dataList.size(); i < len; i++) {
E e = (E)cls.newInstance();
if(i<=headerNum) {
List<Object> row=dataList.get(i);
//boolean flag = row.stream().allMatch(obj -> "".equals(obj));
if(i <= headerNum || row.size() == 0) {// 跳过第一行和空行
continue;
}
E e = (E)cls.newInstance();
int column = 0;
List<Object> row=dataList.get(i);
StringBuilder sb = new StringBuilder();
for (Object[] os : annotationList){
Object val=row.get(column);

View File

@@ -112,7 +112,8 @@ public abstract class XLSXCovertCSVReader {
// private String[] record;
// private List<String[]> rows = new ArrayList<String[]>();
private boolean isCellNull = false;
private int upRowId; // 记录上一行行号
/**
* Accepts objects needed while parsing.
*
@@ -203,8 +204,23 @@ public abstract class XLSXCovertCSVReader {
if (this.formatString == null)
this.formatString = BuiltinFormats
.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 = "";
}