How can i set numeric number from excel to string type? as i want to show 0001 instead of 1 in system. Below are part of the detect excel cell type function. How should i modify it ?
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
value = dateFormat.format(cell.getDateCellValue());
}
else
{
double value2 = cell.getNumericCellValue();
if( Math.floor(value2) == value2 )
{
int value3 = (int)value2;
value = ""+value3;
}else{
value = String.valueOf(value2);
}
}
break;
case HSSFCell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;
case HSSFCell.CELL_TYPE_FORMULA:
if(cell.getCachedFormulaResultType()==HSSFCell.CELL_TYPE_NUMERIC)
{
double value2 = cell.getNumericCellValue();
if( Math.floor(value2) == value2 )
{
int value3 = (int)value2;
value = ""+value3;
}else{
value = String.valueOf(value2);
}
}else if(cell.getCachedFormulaResultType()==HSSFCell.CELL_TYPE_STRING){
value = cell.getStringCellValue();
}
break;
case HSSFCell.CELL_TYPE_BLANK:
value = "";
break;
}
}