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.
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());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.