I have a task to read a number from the cell of file Excel.
I analyse the type of cell at first, then read information.
But, there is the following.
There is a number type and number value in a cell.
type HSSFCell.CELL_TYPE_NUMERIC ignored, a string ( HSSFCell.CELL_TYPE_STRING )
type is recognized and I get an error when reading the value.

if ( HSSFCell.CELL_TYPE_NUMERIC == 1 )
{
        fvalue = ( float ) cell.getNumericCellValue() ;
}
else if( HSSFCell.CELL_TYPE_STRING  == 1 )
{
                
   try {
        svalue = getStringCellValue( cell ) ;
        svalue = getStringForDecimal ( svalue ) ;
        fvalue = StringToDecimal( svalue ) ;
   }
   catch ( Exception e )
   {
        fvalue = ( float ) cell.getNumericCellValue() ;                         
                                
   }                                    
}


java.lang.IllegalStateException: Cannot get a text value from a numeric cell
at org.apache.poi.hssf.usermodel.HSSFCell.typeMismatch(HSSFCell.java:620)
at 
org.apache.poi.hssf.usermodel.HSSFCell.getRichStringCellValue(HSSFCell.java:699)
at 
jobs.com.konus.bean.Configproperty.getStringCellValue(Configproperty.java:554)
at jobs.com.konus.bean.Configproperty.getFloatCellValue(Configproperty.java:497)


Prompt please as correctly to read the numeric data type.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to