Excel支持导入Boolean型数据

pull/200/MERGE
RuoYi 2020-11-28 11:51:41 +08:00
parent c0d66fffcd
commit 9d30a4652c
2 changed files with 8 additions and 5 deletions

View File

@ -279,6 +279,10 @@ public class ExcelUtil<T>
val = DateUtil.getJavaDate((Double) val);
}
}
else if (Boolean.TYPE == fieldType || Boolean.class == fieldType)
{
val = Convert.toBool(val, false);
}
if (StringUtils.isNotNull(fieldType))
{
Excel attr = field.getAnnotation(Excel.class);
@ -295,9 +299,6 @@ public class ExcelUtil<T>
{
val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator());
}
if (fieldType == boolean.class && (val == null||"".equals(val))) {
val = false;
}
ReflectUtils.invokeSetter(entity, propertyName, val);
}
}

View File

@ -204,8 +204,10 @@ public class ReflectUtils
args[i] = DateUtil.getJavaDate((Double) args[i]);
}
}
else if (cs[i] == boolean.class|| cs[i] == Boolean.class) {
args[i] = Convert.toBool(args[i]);}
else if (cs[i] == boolean.class|| cs[i] == Boolean.class)
{
args[i] = Convert.toBool(args[i]);
}
}
}
return (E) method.invoke(obj, args);