DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15303>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15303

cell.getCellValue(); cell.setCellValue();

           Summary: cell.getCellValue(); cell.setCellValue();
           Product: POI
           Version: 1.5.1
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: HSSF
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Hello!

If I understand it right I must determine the cell type to call the right 
getter method for the cell value.
Therefore I use this class method:

    public static Object getCellValue(HSSFCell _cell) {
        if (null == _cell) {
            return null;   
        }
        int nCellType = _cell.getCellType();

        switch (nCellType) {
        case HSSFCell.CELL_TYPE_BLANK:
            return "";
        case HSSFCell.CELL_TYPE_BOOLEAN:
            return new Boolean(_cell.getBooleanCellValue());
        case HSSFCell.CELL_TYPE_ERROR:
            return new Byte(_cell.getErrorCellValue());
        case HSSFCell.CELL_TYPE_FORMULA:
            throw new NotImplementedYetRuntimeException("CELL_TYPE_FORMULA not 
supported");
        case HSSFCell.CELL_TYPE_NUMERIC:
            return new Double(_cell.getNumericCellValue());
        case HSSFCell.CELL_TYPE_STRING:
            return _cell.getStringCellValue();
        default:
            throw new RuntimeException("Type " + nCellType + " not supported");
        }
    }

I think this should be a method of HSSFCell itself. And a generic setter method 
would be helpful as well.

Thanks for this great library

     Holger Schulz

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to