From 2ed1199d48f7207f4a012c04f61e13ac1a8d5154 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期四, 16 六月 2022 10:27:44 +0800 Subject: [PATCH] 新增请求安全工具 --- src/main/java/com/hx/util/ExcelUtil.java | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/hx/util/ExcelUtil.java b/src/main/java/com/hx/util/ExcelUtil.java index 9bd0712..5e9c4d6 100644 --- a/src/main/java/com/hx/util/ExcelUtil.java +++ b/src/main/java/com/hx/util/ExcelUtil.java @@ -370,7 +370,11 @@ arrayString.add(""); //arrayString[i] = ""; } else { // 濡傛灉EXCEL琛ㄦ牸涓殑鏁版嵁绫诲瀷涓哄瓧绗︿覆鍨� - arrayString.add(cell.getStringCellValue().trim()); + if(cell.getCellType() != Cell.CELL_TYPE_BOOLEAN){ + arrayString.add(cell.getStringCellValue().trim()); + }else{ + arrayString.add(cell.getBooleanCellValue() ? "TRUE" : "FALSE"); + } //arrayString[i] = cell.getStringCellValue().trim(); } } @@ -424,7 +428,7 @@ arrayString.add(""); } else if (cell.getCellType() == 0) { // arrayString[i] = new Double(cell.getNumericCellValue()).toString(); - if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) { + if (XSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) { short format = cell.getCellStyle().getDataFormat(); if(format == 14 || format == 31 || format == 57 || format == 58){ //鏃ユ湡锛堜腑鏂囨椂闂存牸寮忕殑锛� @@ -440,13 +444,13 @@ arrayString.add(formater.format(d)); //arrayString[i] = formater.format(d); } else { - if(HSSFCell.CELL_TYPE_STRING == cell.getCellType()){ + if(XSSFCell.CELL_TYPE_STRING == cell.getCellType()){ arrayString.add(cell.getStringCellValue()); //arrayString[i] =cell.getStringCellValue(); - }else if(HSSFCell.CELL_TYPE_FORMULA==cell.getCellType()){ + }else if(XSSFCell.CELL_TYPE_FORMULA==cell.getCellType()){ arrayString.add(cell.getCellFormula()); //arrayString[i] =cell.getCellFormula(); - }else if(HSSFCell.CELL_TYPE_NUMERIC== cell.getCellType()){ + }else if(XSSFCell.CELL_TYPE_NUMERIC== cell.getCellType()){ HSSFDataFormatter dataFormatter = new HSSFDataFormatter(); arrayString.add(dataFormatter.formatCellValue(cell)); //arrayString[i] =dataFormatter.formatCellValue(cell); @@ -457,7 +461,13 @@ arrayString.add(""); //arrayString[i] = ""; } else { // 濡傛灉EXCEL琛ㄦ牸涓殑鏁版嵁绫诲瀷涓哄瓧绗︿覆鍨� - arrayString.add(cell.getStringCellValue().trim()); + if(cell.getCellType() != Cell.CELL_TYPE_BOOLEAN){ + arrayString.add(cell.getStringCellValue().trim()); + }else{ + arrayString.add(cell.getBooleanCellValue() ? "TRUE" : "FALSE"); + } + + //arrayString[i] = cell.getStringCellValue().trim(); } } -- Gitblit v1.8.0