Example usage for org.apache.poi.hssf.usermodel HSSFCell getErrorCellValue

List of usage examples for org.apache.poi.hssf.usermodel HSSFCell getErrorCellValue

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFCell getErrorCellValue.

Prototype

@Override
public byte getErrorCellValue() 

Source Link

Document

get the value of the cell as an error code.

Usage

From source file:ypcnv.views.impl.FileXLS.java

License:Open Source License

/**
 * With respect to cell type get cell's content.
 * /*  ww w  .  jav  a2s .c  o  m*/
 * @param cell
 *            - cell to be processed.
 * @return Cell's content.
 */
private String getCellContent(HSSFCell cell) {

    int foundCellType = cell.getCellType();
    String cellContent = null;

    switch (foundCellType) {
    case Cell.CELL_TYPE_STRING:
        cellContent = cell.getStringCellValue();
        break;
    case Cell.CELL_TYPE_FORMULA:
        cellContent = cell.getStringCellValue();
        break;
    case Cell.CELL_TYPE_BOOLEAN:
        cellContent = cell.getBooleanCellValue() ? "TRUE" : "FALSE";
        break;
    case Cell.CELL_TYPE_ERROR:
        byte xlsErrorCode = cell.getErrorCellValue();
        if (xlsErrorCode == 0) {
            cellContent = "";
        } else {
            cellContent = "XLS error code '" + xlsErrorCode + "'.";
            String message = "XLS cell type is 'ERROR', the XLS error code is '" + xlsErrorCode + "'."
                    + " The cell row=" + cell.getRowIndex() + ", col=" + cell.getColumnIndex() + ".";
            LOG.info(message);
        }
        break;
    case Cell.CELL_TYPE_NUMERIC:
        HSSFDataFormatter numericFormat = new HSSFDataFormatter();
        cellContent = numericFormat.formatCellValue(cell);
        // cellContent = cell.getNumericCellValue();
        break;
    default:
        cellContent = "";
        break;
    }
    return cellContent;
}