Reputation:
Here is my code:
long tin=0;
tin = (long)row.getCell(10).getNumericCellValue();
tin value of excel may contains string or only numeric value.. if tin value is numeric am able to fetch data.. if tin value is String am getting error.
Upvotes: 1
Views: 623
Reputation: 15842
You can check the type of the cell using Cell#getCellTypeEnum(). Possible returned values are:
In other words you should try the following scaffold:
tin = row.getCell(10).getCellTypeEnum().equals(CellType.NUMERIC) ?
(long)row.getCell(10).getNumericCellValue() :
Long.parseLong(row.getCell(10).getStringCellValue());
Upvotes: 1