- /**
- * 获取单元格数据内容为字符串类型的数据
- *
- * @param cell Excel 单元格
- * @return String 单元格数据内容
- */
- public static String getCellStringValue(HSSFCell cell) {
- String strCell;
- switch (cell.getCellType()) {
- case HSSFCell.CELL_TYPE_STRING:
- strCell = cell.getStringCellValue();
- break;
- case HSSFCell.CELL_TYPE_NUMERIC:
- Double value = cell.getNumericCellValue();
- BigDecimal bd1 = new BigDecimal(Double.toString(value));
- strCell = bd1.toPlainString();
- break;
- case HSSFCell.CELL_TYPE_BOOLEAN:
- strCell = String.valueOf(cell.getBooleanCellValue());
- break;
- case HSSFCell.CELL_TYPE_BLANK:
- strCell = "";
- break;
- default:
- strCell = null;
- break;
- }
- return strCell;
- }
来源: http://www.jianshu.com/p/416fb53e7147