|
|
@ -46,11 +46,12 @@ public class ExcelHeadProperty { |
|
|
|
if (this.headClazz != null) { |
|
|
|
if (this.headClazz != null) { |
|
|
|
List<Field> fieldList = new ArrayList<Field>(); |
|
|
|
List<Field> fieldList = new ArrayList<Field>(); |
|
|
|
Class tempClass = this.headClazz; |
|
|
|
Class tempClass = this.headClazz; |
|
|
|
//当父类为null的时候说明到达了最上层的父类(Object类).
|
|
|
|
//When the parent class is null, it indicates that the parent class (Object class) has reached the top
|
|
|
|
|
|
|
|
// level.
|
|
|
|
while (tempClass != null) { |
|
|
|
while (tempClass != null) { |
|
|
|
fieldList.addAll(Arrays.asList(tempClass .getDeclaredFields())); |
|
|
|
fieldList.addAll(Arrays.asList(tempClass.getDeclaredFields())); |
|
|
|
|
|
|
|
//Get the parent class and give it to yourself
|
|
|
|
tempClass = tempClass.getSuperclass(); |
|
|
|
tempClass = tempClass.getSuperclass(); |
|
|
|
//得到父类,然后赋给自己
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
List<List<String>> headList = new ArrayList<List<String>>(); |
|
|
|
List<List<String>> headList = new ArrayList<List<String>>(); |
|
|
|
for (Field f : fieldList) { |
|
|
|
for (Field f : fieldList) { |
|
|
@ -187,19 +188,20 @@ public class ExcelHeadProperty { |
|
|
|
* @return the last consecutive string position |
|
|
|
* @return the last consecutive string position |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private int getLastRangNum(int j, String value, List<String> values) { |
|
|
|
private int getLastRangNum(int j, String value, List<String> values) { |
|
|
|
int lastRow = -1; |
|
|
|
if (value == null) { |
|
|
|
if (StringUtils.isEmpty(value)) { |
|
|
|
|
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 0; i < values.size(); i++) { |
|
|
|
if (j > 0) { |
|
|
|
String current = values.get(i); |
|
|
|
String preValue = values.get(j - 1); |
|
|
|
if (value.equals(current)) { |
|
|
|
if (value.equals(preValue)) { |
|
|
|
if (i >= j) { |
|
|
|
|
|
|
|
lastRow = i; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//if i<j && value.equals(current) Indicates that a merger has occurred
|
|
|
|
|
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int last = j; |
|
|
|
|
|
|
|
for (int i = last + 1; i < values.size(); i++) { |
|
|
|
|
|
|
|
String current = values.get(i); |
|
|
|
|
|
|
|
if (value.equals(current)) { |
|
|
|
|
|
|
|
last = i; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// if i>j && !value.equals(current) Indicates that the continuous range is exceeded
|
|
|
|
// if i>j && !value.equals(current) Indicates that the continuous range is exceeded
|
|
|
|
if (i > j) { |
|
|
|
if (i > j) { |
|
|
@ -207,7 +209,7 @@ public class ExcelHeadProperty { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return lastRow; |
|
|
|
return last; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|