I have just Extracted the cells from the excel sheet using Apache POI, everything is working fine. But whenever there is an empty cell, the very next right cell data is what I get as a output. But, if exists a value in the latter, the desired output is coming.
This is the logic I've written.
Iterator<Row> rowIterator=sheet.rowIterator();
while(rowIterator.hasNext())
{
ExtractedRowsString extRows=new ExtractedRowsString();
ArrayList<HSSFCell> list=new ArrayList<HSSFCell>();
HSSFRow row=(HSSFRow) rowIterator.next();
Iterator<Cell> cellIterator=row.cellIterator();
while(cellIterator.hasNext())
{
HSSFCell cell=(HSSFCell)cellIterator.next();
list.add(cell);
}
if(check)
{
addBean(list,extRows);
print(extRows);
}
check=true;
}
What may be the problem?
EDITED :
public static void addBean(ArrayList list,ExtractedRowsString extRows)
{
for(int i=0;i<list.size();i++)
{
switch(i)
{
case 0:
extRows.setSchool_success_id((list.get(i)).toString());
break;
case 1:
extRows.setPem_id( (list.get(i)).toString() );
break;
case 2:
extRows.setDistrict_code((list.get(i)).toString());
break;
case 3:
extRows.setDistrict((list.get(i)).toString());
break;
}
}
}