Hentua
2023-06-10 72e7d01b5b249ae1a079d19cdc62ecd2782c325c
src/main/java/cc/mrbird/febs/common/utils/excl/ExcelUtil.java
@@ -135,35 +135,35 @@
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            // 格式化数字
            DecimalFormat nf = new DecimalFormat("0.00");
            switch (cell.getCellType()) {
                case Cell.CELL_TYPE_STRING:
                    columnValue = cell.getStringCellValue();
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    if ("@".equals(cell.getCellStyle().getDataFormatString())) {
                        columnValue = df.format(cell.getNumericCellValue());
                    } else if ("General".equals(cell.getCellStyle().getDataFormatString())) {
                        columnValue = nf.format(cell.getNumericCellValue());
                    } else {
                        columnValue = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
                    }
                    break;
                case Cell.CELL_TYPE_BOOLEAN:
                    columnValue = cell.getBooleanCellValue();
                    break;
                case Cell.CELL_TYPE_BLANK:
                    columnValue = "";
                    break;
                case Cell.CELL_TYPE_FORMULA:
                    // 格式单元格
                    FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
                    evaluator.evaluateFormulaCell(cell);
                    CellValue cellValue = evaluator.evaluate(cell);
                    columnValue = cellValue.getNumberValue();
                    break;
                default:
                    columnValue = cell.toString();
            }
//            switch (cell.getCellType()) {
//                case Cell.CELL_TYPE_STRING:
//                    columnValue = cell.getStringCellValue();
//                    break;
//                case Cell.CELL_TYPE_NUMERIC:
//                    if ("@".equals(cell.getCellStyle().getDataFormatString())) {
//                        columnValue = df.format(cell.getNumericCellValue());
//                    } else if ("General".equals(cell.getCellStyle().getDataFormatString())) {
//                        columnValue = nf.format(cell.getNumericCellValue());
//                    } else {
//                        columnValue = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
//                    }
//                    break;
//                case Cell.CELL_TYPE_BOOLEAN:
//                    columnValue = cell.getBooleanCellValue();
//                    break;
//                case Cell.CELL_TYPE_BLANK:
//                    columnValue = "";
//                    break;
//                case Cell.CELL_TYPE_FORMULA:
//                    // 格式单元格
//                    FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
//                    evaluator.evaluateFormulaCell(cell);
//                    CellValue cellValue = evaluator.evaluate(cell);
//                    columnValue = cellValue.getNumberValue();
//                    break;
//                default:
//                    columnValue = cell.toString();
//            }
        }
        return columnValue;
    }
@@ -285,24 +285,24 @@
//      style.setBorderTop(HSSFCellStyle.BORDER_THIN);
        style.setWrapText(true);
        if (STYLE_HEADER == type) {
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
            Font font = wb.createFont();
            font.setFontHeightInPoints((short) 16);
            font.setBoldweight(Font.BOLDWEIGHT_BOLD);
            style.setFont(font);
        } else if (STYLE_TITLE == type) {
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
            Font font = wb.createFont();
            font.setFontHeightInPoints((short) 18);
            font.setBoldweight(Font.BOLDWEIGHT_BOLD);
            style.setFont(font);
        } else if (STYLE_DATA == type) {
            style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
            Font font = wb.createFont();
            font.setFontHeightInPoints((short) 12);
            style.setFont(font);
        }
//        if (STYLE_HEADER == type) {
//            style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//            Font font = wb.createFont();
//            font.setFontHeightInPoints((short) 16);
//            font.setBoldweight(Font.BOLDWEIGHT_BOLD);
//            style.setFont(font);
//        } else if (STYLE_TITLE == type) {
//            style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//            Font font = wb.createFont();
//            font.setFontHeightInPoints((short) 18);
//            font.setBoldweight(Font.BOLDWEIGHT_BOLD);
//            style.setFont(font);
//        } else if (STYLE_DATA == type) {
//            style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
//            Font font = wb.createFont();
//            font.setFontHeightInPoints((short) 12);
//            style.setFont(font);
//        }
        cellStyleMap.put(type, style);
        return style;
    }