You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2002/12/12 11:24:45 UTC

DO NOT REPLY [Bug 15303] New: - cell.getCellValue(); cell.setCellValue();

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: poi-dev@jakarta.apache.org
        ReportedBy: Holger.Schulz@epost.de


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