public void readExcel(String fileName)
try
{
FileInputStream myInput = new FileInputStream(fileName);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
HSSFSheet mySheet = myWorkBook.getSheetAt(0);
Iterator rowIter = mySheet.rowIterator();
while(rowIter.hasNext())
{
HSSFRow myRow = (HSSFRow) rowIter.next();
Iterator cellIter = myRow.cellIterator();
ArrayList cellStoreVector=new ArrayList();
String header_name = null;
while(cellIter.hasNext())
{
HSSFCell myCell = (HSSFCell) cellIter.next();
// if it is empty cell in my excel file its not added to
// array List
cellStoreVector.add(myCell);
}
cellVectorHolder.add(cellStoreVector);
}
}catch (Exception e)
{
e.printStackTrace();
}
saveToDatabase(cellVectorHolder);
}
public void saveToDatabase(ArrayList array)
{
for (int i=0;i<array.size(); i++)
{
ArrayList cellStoreVector=(ArrayList)array.get(i);
for (int j=0; j < cellStoreVector.size();j++)
{
HSSFCell myCell = (HSSFCell)cellStoreVector.get(j);
String st = myCell.toString();
System.out.println("values "+st);
}
}
}
The above code is my sample code for reading excel file and print values into console. Here I have a problem when reading blank cells and this blank cells are not displayed in the console. So please give me solution for reading blank cell and print this blank in console.