Reputation: 939
I have an Excel file
containing values of following data types
String
, Boolean
, Numeric
and Alpha Numeric
. Using HSSF poi
, I extracted the same.
cell.getStringCellValue(); //for String values
cell.getBooleanCellValue(); //for Boolean values True or False
cell.getNumericCellValue(); //for Numeric values.
Can anyone please help me to fetch data of alphanumeric
data from a Excel cell value?
FYI :
Following are the available constants in HSSF poi
,
Cell.CELL_TYPE_BLANK
Cell.CELL_TYPE_NUMERIC
Cell.CELL_TYPE_STRING
Cell.CELL_TYPE_FORMULA
Cell.CELL_TYPE_BOOLEAN
Cell.CELL_TYPE_ERROR
Upvotes: 0
Views: 1699
Reputation: 939
I solved using the following way,
int cellType = cell.getCellType();
switch(cellType)
{
case Cell.CELL_TYPE_BLANK:
//
cell.get
break;
case Cell.CELL_TYPE_BOOLEAN:
//
cellValue = cell.getBooleanCellValue();
break;
case Cell.CELL_TYPE_ERROR:
//
break;
case Cell.CELL_TYPE_FORMULA:
//
break;
case Cell.CELL_TYPE_NUMERIC:
//
cellValue = cell.getNumericCellValue();
break;
case Cell.CELL_TYPE_STRING:
//
cellValue = cell.RichStringCellValue();
break;
}
Upvotes: 1