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:

  1. read fields of given class using reflection,
  2. iterate through rows of excel file.
  3. match field names headers , header index of fields.
  4. get value cell each index.
  5. finally set values each field of object using reflection.
  6. return list of objects.

i have created simple java library convert excel file list of object time ago. might you.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -