Commit be54188ba6c0ff9a0d3d286f102041cd98f7eabc
1 parent
a4e2339f
导出Excel调整targetAttr获取值方法,防止get方法不规范
Showing
1 changed file
with
3 additions
and
4 deletions
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
| ... | ... | @@ -6,7 +6,6 @@ import java.io.IOException; |
| 6 | 6 | import java.io.InputStream; |
| 7 | 7 | import java.io.OutputStream; |
| 8 | 8 | import java.lang.reflect.Field; |
| 9 | -import java.lang.reflect.Method; | |
| 10 | 9 | import java.math.BigDecimal; |
| 11 | 10 | import java.text.DecimalFormat; |
| 12 | 11 | import java.util.ArrayList; |
| ... | ... | @@ -864,9 +863,9 @@ public class ExcelUtil<T> |
| 864 | 863 | if (StringUtils.isNotEmpty(name)) |
| 865 | 864 | { |
| 866 | 865 | Class<?> clazz = o.getClass(); |
| 867 | - String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); | |
| 868 | - Method method = clazz.getMethod(methodName); | |
| 869 | - o = method.invoke(o); | |
| 866 | + Field field = clazz.getDeclaredField(name); | |
| 867 | + field.setAccessible(true); | |
| 868 | + o = field.get(o); | |
| 870 | 869 | } |
| 871 | 870 | return o; |
| 872 | 871 | } | ... | ... |