private void ReadAndPrintExcelFile(String filePath, String sSheetName) {
try {
FileInputStream fis = new FileInputStream(filePath);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet = wb.getSheet(sSheetName);
for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) {
String cellNovalue = "";
XSSFRow row = sheet.getRow(i);
Iterator it = row.cellIterator();
while (it.hasNext()) {
XSSFCell cell = (XSSFCell) it.next();
try {
cellNovalue = cell.getStringCellValue();
} catch (IllegalStateException e) {
try {
double dcellNovalue = sheet.getRow(i).getCell(0)
.getNumericCellValue();
cellNovalue = String.valueOf(dcellNovalue);
} catch (IllegalStateException e2) {
cellNovalue = "";
e.printStackTrace();
}
} catch (Exception e3) {
cellNovalue = "";
e3.printStackTrace();
}
System.out.println("Row=" + i + "; Cell="
+ cell.getColumnIndex() + "; Value=" + cellNovalue);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}