Skip to content

Commit

Permalink
导出Excel调整targetAttr获取值方法,防止get方法不规范
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Aug 26, 2020
1 parent a4e2339 commit be54188
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -864,9 +863,9 @@ private Object getValue(Object o, String name) throws Exception
if (StringUtils.isNotEmpty(name))
{
Class<?> clazz = o.getClass();
String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method method = clazz.getMethod(methodName);
o = method.invoke(o);
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
o = field.get(o);
}
return o;
}
Expand Down

0 comments on commit be54188

Please sign in to comment.