diff --git a/src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java b/src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java
index 33e60530..b8dd3764 100644
--- a/src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java
+++ b/src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java
@@ -28,7 +28,6 @@ public class ExcelAnalyserImpl implements ExcelAnalyser {
eventListener, trim);
}
-
private BaseSaxAnalyser getSaxAnalyser() {
if (saxAnalyser != null) {
return this.saxAnalyser;
@@ -50,14 +49,14 @@ public class ExcelAnalyserImpl implements ExcelAnalyser {
if (!analysisContext.getInputStream().markSupported()) {
throw new ExcelAnalysisException(
"Xls must be available markSupported,you can do like this new "
- + "BufferedInputStream(new FileInputStream(\"/xxxx/xxx/77.xlsx\"))
");
+ + "BufferedInputStream(new FileInputStream(\"/xxxx\")) ");
}
this.saxAnalyser = new XlsSaxAnalyser(analysisContext);
}
}
} catch (Exception e) {
throw new ExcelAnalysisException("File type error,io must be available markSupported,you can do like "
- + "this new BufferedInputStream(new FileInputStream(\\\"/xxxx/xxx/77.xlsx\\\"))
\"", e);
+ + "this new BufferedInputStream(new FileInputStream(\\\"/xxxx\\\"))
\"", e);
}
return this.saxAnalyser;
}
diff --git a/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java b/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java
index 06ff0703..95ff9fda 100644
--- a/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java
+++ b/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java
@@ -46,11 +46,12 @@ public class ExcelHeadProperty {
if (this.headClazz != null) {
List fieldList = new ArrayList();
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) {
- fieldList.addAll(Arrays.asList(tempClass .getDeclaredFields()));
+ fieldList.addAll(Arrays.asList(tempClass.getDeclaredFields()));
+ //Get the parent class and give it to yourself
tempClass = tempClass.getSuperclass();
- //得到父类,然后赋给自己
}
List> headList = new ArrayList>();
for (Field f : fieldList) {
@@ -187,19 +188,20 @@ public class ExcelHeadProperty {
* @return the last consecutive string position
*/
private int getLastRangNum(int j, String value, List values) {
- int lastRow = -1;
- if (StringUtils.isEmpty(value)) {
+ if (value == null) {
return -1;
}
- for (int i = 0; i < values.size(); i++) {
+ if (j > 0) {
+ String preValue = values.get(j - 1);
+ if (value.equals(preValue)) {
+ return -1;
+ }
+ }
+ int last = j;
+ for (int i = last + 1; i < values.size(); i++) {
String current = values.get(i);
if (value.equals(current)) {
- if (i >= j) {
- lastRow = i;
- } else {
- //if ij && !value.equals(current) Indicates that the continuous range is exceeded
if (i > j) {
@@ -207,7 +209,7 @@ public class ExcelHeadProperty {
}
}
}
- return lastRow;
+ return last;
}