apache poi - How to read column value using grails excel import plugin? -
i using grails excel import plugin import excel file.
      static map propertyconfigurationmap = [           name:([expectedtype: excelimportservice.property_type_string, defaultvalue:null]),           age:([expectedtype: excelimportservice.property_type_int, defaultvalue:0])]        static map config_book_column_map = [           sheet:'sheet1',           startrow: 1,           columnmap:  [            //col, map-key            'a':'name',            'b':'age',           ]          ]   i able retrieve array list using code snippet:
def userslist = excelimportservice.columns(workbook, config_user_column_map)
which results in
[[name: mark, age: 25], [name: jhon, age: 46], [name: anil, age: 62], [name: steve, age: 32]]
and i'm able read each record [name: mark, age: 25] using userslist.get(0)
how read each column value? know can read this
string[] row = userslist.get(0) (string s : row)     println s   i wonder there thing plugin supports can read column value directly rather manipulating desired result.
your userslist list<map<string, object>> (list of maps). can read column using name gave in config. in example, named column name , column b age. using iteration example basis, can read each column this:
map row = userslist.get(0)  for(map.entry entry : row) {     println entry.value }   groovy makes easier object.each(closure):
row.each { key, value ->      println value  }   if want read specific column value, here few ways it:
println row.name // 1 println row['name'] // 2 println row.getat('name') // 3   hint: these end calling row.getat('name')
Comments
Post a Comment