Skip to Content
0
Former Member
Apr 24, 2014 at 09:36 AM

how to write each element of a set to the excel sheet?

25 Views

I am trying to iterate through each element of the set and write each of them to an excel file? Can Somebody help me to achieve this?

Code snippet is:

Iterator<String> nameIterator = names.iterator();

for(int size = 0;size<names.size();size++){

row = mdm_lastLoginDate.createRow(size);

//cell = row.createCell(1);

while(nameIterator.hasNext()){

String setName = nameIterator.next();

cell = row.createCell(1);

cell.setCellValue(setName);

System.out.println("setName:->"+setName);

}

mdm_lastLoginDate.autoSizeColumn(size);

}

above code prints each element in the console but not getting each value in the excel file. I am only getting the last value.

Thanks & regards

Amita