| | |
| | | value = ""; |
| | | return value; |
| | | } |
| | | |
| | | DecimalFormat df = new DecimalFormat("0"); // 格式化number String字符 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 日期格式化 |
| | | DecimalFormat df2 = new DecimalFormat("0.00"); // 格式化数字 |
| | | // 格式化number String字符 |
| | | DecimalFormat df = new DecimalFormat("0"); |
| | | // 日期格式化 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 格式化数字 |
| | | DecimalFormat df2 = new DecimalFormat("0.00"); |
| | | |
| | | switch (cell.getCellType()) { |
| | | case Cell.CELL_TYPE_STRING: |
| | | value = cell.getRichStringCellValue().getString(); |
| | | break; |
| | | case Cell.CELL_TYPE_NUMERIC: |
| | | if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式 |
| | | |
| | | if (cell.getCellStyle().getDataFormat() == HSSFDataFormat.getBuiltinFormat("h:mm") |
| | | || cell.getCellStyle().getDataFormat() == 176) { |
| | | sdf = new SimpleDateFormat("HH:mm"); |
| | | } |
| | | Date date = cell.getDateCellValue(); |
| | | value = sdf.format(date); |
| | | |
| | | if (HSSFDateUtil.isCellDateFormatted(cell)) { |
| | | // 处理日期格式、时间格式 |
| | | Date date = cell.getDateCellValue(); |
| | | sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | value = sdf.format(date); |
| | | } else if (cell.getCellStyle().getDataFormat() == 58) { |
| | | // 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58) |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("MM-dd"); |