Skip to content

Commit e7bae35

Browse files
committed
Changed the way I set values in an object when converting from Excel to Objects
1 parent 297f871 commit e7bae35

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/io/github/mbenincasa/javaexcelutils/tools/Converter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.*;
2626
import java.lang.reflect.Field;
2727
import java.lang.reflect.InvocationTargetException;
28+
import java.lang.reflect.Method;
2829
import java.time.LocalDate;
2930
import java.time.LocalDateTime;
3031
import java.util.*;
@@ -608,7 +609,11 @@ public static Map<String, Stream<?>> excelStreamToObjects(InputStream inputStrea
608609
throw new RuntimeException();
609610
}
610611
Field field = fieldOptional.get();
611-
PropertyUtils.setSimpleProperty(obj, headerName, excelCell.readValue(field.getType()));
612+
613+
/* Set the value */
614+
String methodName = "set" + Character.toUpperCase(headerName.charAt(0)) + headerName.substring(1);
615+
Method setMethod = clazz.getMethod(methodName, field.getType());
616+
setMethod.invoke(obj, excelCell.readValue(field.getType()));
612617
}
613618
/* Adds the object to the Stream after it has finished cycling through all cells */
614619
streamBuilder.add(obj);

0 commit comments

Comments
 (0)