From 72e7d01b5b249ae1a079d19cdc62ecd2782c325c Mon Sep 17 00:00:00 2001 From: Hentua <wangdoubleone@gmail.com> Date: Sat, 10 Jun 2023 01:24:36 +0800 Subject: [PATCH] ecel --- src/main/java/cc/mrbird/febs/common/utils/excl/ExcelUtil.java | 94 +++++++++++++++++++++++----------------------- 1 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/common/utils/excl/ExcelUtil.java b/src/main/java/cc/mrbird/febs/common/utils/excl/ExcelUtil.java index 51d799b..a093282 100644 --- a/src/main/java/cc/mrbird/febs/common/utils/excl/ExcelUtil.java +++ b/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; } -- Gitblit v1.9.1