best possible way of mapping excel fields with java object -
i trying map excel field java object. best possible way of doing rather being dependent on column number.
cell orderid=row.getcell(0); system.out.println("orderid" +orderid); cell trackingid=row.getcell(1); cell ordertitle = row.getcell(2); cell customername = row.getcell(3); cell customeraddress = row.getcell(5);
how map column object variable without bieng dependent on column numbers?
i looking can map row header object , rest should independent of row number. suggestions?
if want map column object variable without being dependent on column numbers, need have way match class fieldname excel file header name , set value accordingly. 1 way use reflection
:
- read fields of given class using reflection,
- iterate through rows of excel file.
- match field names headers , header index of fields.
- get value cell each index.
- finally set values each field of object using reflection.
- return list of objects.
i have created simple java library convert excel file list of object time ago. might you.
Comments
Post a Comment