From 7f9b53d982c0210ffc25db3a639bd858fc5db79b Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期三, 31 五月 2023 10:56:55 +0800
Subject: [PATCH] 数据库公用方法添加

---
 src/main/java/com/hx/util/ExcelUtil.java |   47 +++++++++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/hx/util/ExcelUtil.java b/src/main/java/com/hx/util/ExcelUtil.java
index 320ecb7..a21a8dc 100644
--- a/src/main/java/com/hx/util/ExcelUtil.java
+++ b/src/main/java/com/hx/util/ExcelUtil.java
@@ -57,10 +57,11 @@
 		// 鍦ㄧ储寮�0鐨勪綅缃垱寤鸿锛堟渶椤剁鐨勮锛�
 		HSSFRow row = sheet.createRow(0);
 		// ===============================================================
-		for (int i = 0; i < headList.length; i++) {
 
+		HSSFCell cell;
+		for (int i = 0; i < headList.length; i++) {
 			// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
-			HSSFCell cell = row.createCell(i);
+			cell = row.createCell(i);
 			// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 			cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 			// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -68,14 +69,16 @@
 		}
 		// ===============================================================
 		if (dataList != null) {
+			HSSFRow row_value;
+			Map<String, Object> dataMap;
 			for (int n = 0; n < dataList.size(); n++) {
 				// 鍦ㄧ储寮�1鐨勪綅缃垱寤鸿
-				HSSFRow row_value = sheet.createRow(n + 1);
-				Map<String, Object> dataMap = dataList.get(n);
+				row_value = sheet.createRow(n + 1);
+				dataMap = dataList.get(n);
 				// ===============================================================
 				for (int i = 0; i < fieldList.length; i++) {
 					// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
-					HSSFCell cell = row_value.createCell(i);
+					cell = row_value.createCell(i);
 					// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 					cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 					// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -125,10 +128,10 @@
 			// 鍦ㄧ储寮�0鐨勪綅缃垱寤鸿锛堟渶椤剁鐨勮锛�
 			HSSFRow row = sheet.createRow(0);
 			// ===============================================================
+			HSSFCell cell;
 			for (int i = 0; i < headList.length; i++) {
-
 				// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
-				HSSFCell cell = row.createCell(i);
+				cell = row.createCell(i);
 				// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 				cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 				// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -136,14 +139,16 @@
 			}
 			// ===============================================================
 			if (dataList != null) {
+				HSSFRow row_value;
+				Map<String, Object> dataMap;
 				for (int n = 0; n < dataList.size(); n++) {
 					// 鍦ㄧ储寮�1鐨勪綅缃垱寤鸿
-					HSSFRow row_value = sheet.createRow(n + 1);
-					Map<String, Object> dataMap = dataList.get(n);
+					row_value = sheet.createRow(n + 1);
+					dataMap = dataList.get(n);
 					// ===============================================================
 					for (int i = 0; i < fieldList.length; i++) {
 						// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
-						HSSFCell cell = row_value.createCell(i);
+						cell = row_value.createCell(i);
 						// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 						cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 						// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -204,12 +209,13 @@
 			// 鍦ㄧ储寮�0鐨勪綅缃垱寤鸿锛堟渶椤剁鐨勮锛�
 			HSSFRow row = sheet.createRow(0);
 			// ===============================================================
+			HSSFCell cell;
 			for (int i = 0; i < headList.length; i++) {
 				//楂樺害
 				row.setHeight(height.shortValue());
 				sheet.setColumnWidth(i,width);
 				// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
-				HSSFCell cell = row.createCell(i);
+				cell = row.createCell(i);
 				// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 				cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 				// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -218,16 +224,18 @@
 			}
 			// ===============================================================
 			if (dataList != null) {
+				HSSFRow row_value;
+				Map<String, Object> dataMap;
 				for (int n = 0; n < dataList.size(); n++) {
 					// 鍦ㄧ储寮�1鐨勪綅缃垱寤鸿
-					HSSFRow row_value = sheet.createRow(n + 1);
+					row_value = sheet.createRow(n + 1);
 					row_value.setHeight(height.shortValue());
-					Map<String, Object> dataMap = dataList.get(n);
+					dataMap = dataList.get(n);
 					// ===============================================================
 					for (int i = 0; i < fieldList.length; i++) {
 						// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
 						sheet.setColumnWidth(i,width);
-						HSSFCell cell = row_value.createCell(i);
+						cell = row_value.createCell(i);
 						// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 						cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 						// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -292,12 +300,13 @@
 			// 鍦ㄧ储寮�0鐨勪綅缃垱寤鸿锛堟渶椤剁鐨勮锛�
 			XSSFRow row = sheet.createRow(0);
 			// ===============================================================
+			XSSFCell cell;
 			for (int i = 0; i < headList.length; i++) {
 				//楂樺害
 				row.setHeight(height.shortValue());
 				sheet.setColumnWidth(i,width);
 				// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
-				XSSFCell cell = row.createCell(i);
+				cell = row.createCell(i);
 				// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 				cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 				// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�
@@ -306,16 +315,18 @@
 			}
 			// ===============================================================
 			if (dataList != null) {
+				XSSFRow row_value;
+				Map<String, Object> dataMap;
 				for (int n = 0; n < dataList.size(); n++) {
 					// 鍦ㄧ储寮�1鐨勪綅缃垱寤鸿
-					XSSFRow row_value = sheet.createRow(n + 1);
+					row_value = sheet.createRow(n + 1);
 					row_value.setHeight(height.shortValue());
-					Map<String, Object> dataMap = dataList.get(n);
+					dataMap = dataList.get(n);
 					// ===============================================================
 					for (int i = 0; i < fieldList.length; i++) {
 						// 鍦ㄧ储寮�0鐨勪綅缃垱寤哄崟鍏冩牸锛堝乏涓婄锛�
 						sheet.setColumnWidth(i,width);
-						XSSFCell cell = row_value.createCell(i);
+						cell = row_value.createCell(i);
 						// 瀹氫箟鍗曞厓鏍间负瀛楃涓茬被鍨�
 						cell.setCellType(HSSFCell.CELL_TYPE_STRING);
 						// 鍦ㄥ崟鍏冩牸涓緭鍏ヤ竴浜涘唴瀹�

--
Gitblit v1.8.0