|
@@ -139,8 +139,21 @@ public class ExcelUtil {
|
|
log.error("excel读取报错", e);
|
|
log.error("excel读取报错", e);
|
|
if (e instanceof IllegalArgumentException) {
|
|
if (e instanceof IllegalArgumentException) {
|
|
String errorColumn = e.getMessage();
|
|
String errorColumn = e.getMessage();
|
|
- if (errorColumn.indexOf("Can not set java.lang.String field") != -1 && errorColumn.indexOf("to java.lang.Long") != -1) {
|
|
|
|
- String column = errorColumn.substring(errorColumn.indexOf("Can not set java.lang.String field") + 1, errorColumn.indexOf("to java.lang.Long"));
|
|
|
|
|
|
+ if (errorColumn.indexOf("Can not set java.lang.String field") != -1 &&
|
|
|
|
+ (errorColumn.indexOf("to java.lang.Long") != -1 ||
|
|
|
|
+ errorColumn.indexOf("to java.lang.Double") != -1 ||
|
|
|
|
+ errorColumn.indexOf("to java.lang.Integer") != -1 ||
|
|
|
|
+ errorColumn.indexOf("to java.lang.Float") != -1)) {
|
|
|
|
+ String column = null;
|
|
|
|
+ if (errorColumn.indexOf("to java.lang.Long") != -1) {
|
|
|
|
+ column = errorColumn.substring(errorColumn.indexOf("Can not set java.lang.String field") + 1, errorColumn.indexOf("to java.lang.Long"));
|
|
|
|
+ } else if (errorColumn.indexOf("to java.lang.Double") != -1) {
|
|
|
|
+ column = errorColumn.substring(errorColumn.indexOf("Can not set java.lang.String field") + 1, errorColumn.indexOf("to java.lang.Double"));
|
|
|
|
+ } else if (errorColumn.indexOf("to java.lang.Integer") != -1) {
|
|
|
|
+ column = errorColumn.substring(errorColumn.indexOf("Can not set java.lang.String field") + 1, errorColumn.indexOf("to java.lang.Integer"));
|
|
|
|
+ } else if (errorColumn.indexOf("to java.lang.Float") != -1) {
|
|
|
|
+ column = errorColumn.substring(errorColumn.indexOf("Can not set java.lang.String field") + 1, errorColumn.indexOf("to java.lang.Float"));
|
|
|
|
+ }
|
|
column = column.substring(column.lastIndexOf(".") + 1, column.length());
|
|
column = column.substring(column.lastIndexOf(".") + 1, column.length());
|
|
Field field = o.getClass().getDeclaredField(column.trim());
|
|
Field field = o.getClass().getDeclaredField(column.trim());
|
|
ExcelNote note = field.getAnnotation(ExcelNote.class);
|
|
ExcelNote note = field.getAnnotation(ExcelNote.class);
|