https://issues.apache.org/bugzilla/show_bug.cgi?id=51193

--- Comment #3 from mai00ihf <[email protected]> 2011-05-26 09:09:18 
UTC ---
        Cell cell =
sheet.getRow(getIntValueRowID(rowID)).getCell(getIntValue(colID));
             //      System.out.println("Type " + cell.getCellType());


                   //System.out.println( cell.getCellStyle());

                   switch(cell.getCellType()) {
                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING:
                    value = cell.getStringCellValue();                          
                    break;
                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC:
                   
if(org.apache.poi.hssf.usermodel.HSSFDateUtil.isCellDateFormatted(cell)) {
                        value = cell.getDateCellValue().toString();             
                    } else {
                        value = cell.getNumericCellValue() +"";                 
                    }
                    break;
                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN:
                    value = Boolean.toString(cell.getBooleanCellValue());       
                    break;

                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR:
                    value = null;
                    break;

                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK:
                    value=null;
                    break;

                case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA:
                    //Formula cells have the formula string, as well as the
formula result, which can be numeric or string.                
                    try{
                        // get the formula result as string
                        value = cell.getStringCellValue();    
                    }    
                    catch (Exception e) {
                        //wenn eine Exception ausfällt, dann gib es als ein
Number wert zurück
                        value = Double.toString((cell.getNumericCellValue()));  
                    }
                    break;                    
                default:
                    value = null;
                    break;
                }

                String errorMessage = null;

                if (checkEmpty && (value == null || value.length() == 0)) {
                        errorMessage = "Wert in Feld: " + colID + rowID + " ist
leer!";
                } else if (datatype != null) {
                    if (!checkDataType(value, datatype)) {                    
                       // vorgegeben typen: String, numerische datens           
                        errorMessage = TEXT_UNERWARTET + colID + rowID + ",
Arbeitsblatt: " + sheetName + " Erwartet war: "+ datatype;
                    }
                }    
                // Fehler Ausgeben falls vorhanden
                if (errorMessage != null) {
                    handleError(errorMessage);
                }
            }catch(Exception e){
                //throw new ContentAccessException("Zugriff auf Zelle " + colID
+ rowID + " nicht möglich." + e.getMessage());
                 String message = "Zugriff auf Zelle " + colID + rowID + "
nicht möglich."+ e.getMessage();
                 reportError(message);
            }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to