From 2e06d10f39d8bbdeae8a8da99f3d94ed027df24c Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期五, 01 九月 2023 17:14:41 +0800
Subject: [PATCH] 新版excel

---
 src/main/java/com/hx/util/SimpleTool.java |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/hx/util/SimpleTool.java b/src/main/java/com/hx/util/SimpleTool.java
index fd0764b..eccf481 100644
--- a/src/main/java/com/hx/util/SimpleTool.java
+++ b/src/main/java/com/hx/util/SimpleTool.java
@@ -43,6 +43,7 @@
 import net.sourceforge.pinyin4j.PinyinHelper;
 import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
 import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import org.apache.poi.ss.usermodel.CellType;
 import org.springframework.cglib.beans.BeanMap;
 
 public class SimpleTool {
@@ -802,7 +803,7 @@
 				HSSFCell cell = hssfrow.getCell(i);
 				if (cell == null) {
 					arrayString[i] = "";
-				} else if (cell.getCellType() == 0) {
+				} else if (cell.getCellType() == CellType.NUMERIC) {
 					// arrayString[i] = new Double(cell.getNumericCellValue()).toString();
 					 short format = cell.getCellStyle().getDataFormat();  
 					    SimpleDateFormat sdf = null;  
@@ -812,7 +813,7 @@
 					    }else if (format == 20 || format == 32) {  
 					        //鏃堕棿  
 					        sdf = new SimpleDateFormat("HH:mm");  
-					    }else if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) { 
+					    }else if (CellType.NUMERIC == cell.getCellType()) {
 						  if (HSSFDateUtil.isCellDateFormatted(cell)) {    
 						    Date d = cell.getDateCellValue();    
 						    DateFormat formater = new SimpleDateFormat("yyyy骞�"); 
@@ -868,9 +869,9 @@
 						HSSFCell cell = hssfrow.getCell(i);
 						if (cell == null) {
 							arrayString[i] = "";
-						} else if (cell.getCellType() == 0) {
+						} else if (cell.getCellType() == CellType.NUMERIC) {
 							// arrayString[i] = new Double(cell.getNumericCellValue()).toString();
-							if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) {
+							if (CellType.NUMERIC == cell.getCellType()) {
 								short format = cell.getCellStyle().getDataFormat();  
 								if(format == 14 || format == 31 || format == 57 || format == 58){  
 									//鏃ユ湡锛堜腑鏂囨椂闂存牸寮忕殑锛�
@@ -884,17 +885,17 @@
 									// DateFormat formater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 									arrayString[i] = formater.format(d);   
 								} else {    
-									if(HSSFCell.CELL_TYPE_STRING == cell.getCellType()){
+									if(CellType.STRING == cell.getCellType()){
 										arrayString[i] =cell.getStringCellValue();
-									}else if(HSSFCell.CELL_TYPE_FORMULA==cell.getCellType()){
+									}else if(CellType.FORMULA==cell.getCellType()){
 										arrayString[i] =cell.getCellFormula();
-									}else if(HSSFCell.CELL_TYPE_NUMERIC== cell.getCellType()){
+									}else if(CellType.NUMERIC== cell.getCellType()){
 										HSSFDataFormatter dataFormatter = new HSSFDataFormatter();
 										arrayString[i] =dataFormatter.formatCellValue(cell);
 									}
 								}
 							}
-						} else if(cell.getCellType() == Cell.CELL_TYPE_BLANK){
+						} else if(cell.getCellType() == CellType.BLANK){
 							arrayString[i] = "";
 						} else { // 濡傛灉EXCEL琛ㄦ牸涓殑鏁版嵁绫诲瀷涓哄瓧绗︿覆鍨�
 							arrayString[i] = cell.getStringCellValue().trim();
@@ -939,9 +940,9 @@
 							HSSFCell cell = hssfrow.getCell(i);
 							if (cell == null) {
 								arrayString[i] = "";
-							} else if (cell.getCellType() == 0) {
+							} else if (cell.getCellType() == CellType.NUMERIC) {
 								// arrayString[i] = new Double(cell.getNumericCellValue()).toString();
-								if (HSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) {
+								if (CellType.NUMERIC == cell.getCellType()) {
 									short format = cell.getCellStyle().getDataFormat();  
 									if(format == 14 || format == 31 || format == 57 || format == 58){  
 										//鏃ユ湡锛堜腑鏂囨椂闂存牸寮忕殑锛�
@@ -955,20 +956,20 @@
 										// DateFormat formater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 										arrayString[i] = formater.format(d);   
 									} else {    
-										if(HSSFCell.CELL_TYPE_STRING == cell.getCellType()){
+										if(CellType.STRING == cell.getCellType()){
 											arrayString[i] =cell.getStringCellValue();
-										}else if(HSSFCell.CELL_TYPE_FORMULA==cell.getCellType()){
+										}else if(CellType.FORMULA==cell.getCellType()){
 											arrayString[i] =cell.getCellFormula();
-										}else if(HSSFCell.CELL_TYPE_NUMERIC== cell.getCellType()){
+										}else if(CellType.NUMERIC== cell.getCellType()){
 											HSSFDataFormatter dataFormatter = new HSSFDataFormatter();
 											arrayString[i] =dataFormatter.formatCellValue(cell);
 										}
 									}
 								}
-							} else if(cell.getCellType() == Cell.CELL_TYPE_BLANK){
+							} else if(cell.getCellType() == CellType.BLANK){
 								arrayString[i] = "";
 							} else { // 濡傛灉EXCEL琛ㄦ牸涓殑鏁版嵁绫诲瀷涓哄瓧绗︿覆鍨�
-								cell.setCellType(Cell.CELL_TYPE_STRING);
+								cell.setCellType(CellType.STRING);
 								String name = cell.getStringCellValue().trim();
 								if(name.equals("-")) {
 									arrayString[i] = "";

--
Gitblit v1.8.0