List of usage examples for org.apache.poi.hssf.usermodel HSSFCell getErrorCellValue
@Override public byte getErrorCellValue()
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; }