From ef127cbdfbf77969468df8a597df3a27f285fa79 Mon Sep 17 00:00:00 2001
From: freelansam <79205526+freelansam@users.noreply.github.com>
Date: Mon, 31 Jan 2022 21:48:39 +0530
Subject: [PATCH] JAVA-9566: Update apache-poi version and articles (#11748)
* JAVA-9566: Update apache-poi version and articles
* JAVA-9566: Update apache-poi version and articles
---
apache-poi/pom.xml | 2 +-
.../baeldung/poi/excel/ExcelPOIHelper.java | 27 +++++++++----------
.../com/baeldung/poi/excel/ExcelUtility.java | 1 +
.../poi/excel/cellstyle/CellStyler.java | 1 -
.../jexcel/JExcelIntegrationTest.java | 27 +++++++------------
.../poi/excel/ExcelIntegrationTest.java | 21 +++++----------
.../cellstyle/CellStyleHandlerUnitTest.java | 16 ++++++-----
7 files changed, 41 insertions(+), 54 deletions(-)
diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml
index 5471c77961..1a0f77b025 100644
--- a/apache-poi/pom.xml
+++ b/apache-poi/pom.xml
@@ -33,7 +33,7 @@
- 4.1.1
+ 5.2.0
1.0.6
diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelPOIHelper.java b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelPOIHelper.java
index b6b0cbef20..6c2a8c68f7 100644
--- a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelPOIHelper.java
+++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelPOIHelper.java
@@ -1,25 +1,24 @@
package com.baeldung.poi.excel;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFFont;
-import org.apache.poi.ss.usermodel.DateUtil;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelPOIHelper {
@@ -33,7 +32,7 @@ public class ExcelPOIHelper {
for (Row row : sheet) {
data.put(i, new ArrayList());
for (Cell cell : row) {
- switch (cell.getCellTypeEnum()) {
+ switch (cell.getCellType()) {
case STRING:
data.get(i)
.add(cell.getRichStringCellValue()
diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java
index 50bbfbbe3c..f22b0f094f 100644
--- a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java
+++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelUtility.java
@@ -44,6 +44,7 @@ public class ExcelUtility {
}
}
inputStream.close();
+ baeuldungWorkBook.close();
} catch (IOException e) {
throw e;
diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java b/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java
index 6d8b303fd3..0f8f8b6cd9 100644
--- a/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java
+++ b/apache-poi/src/main/java/com/baeldung/poi/excel/cellstyle/CellStyler.java
@@ -1,7 +1,6 @@
package com.baeldung.poi.excel.cellstyle;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
-import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
diff --git a/apache-poi/src/test/java/com/baeldung/jexcel/JExcelIntegrationTest.java b/apache-poi/src/test/java/com/baeldung/jexcel/JExcelIntegrationTest.java
index 41efd9d9ba..abf3d3d50c 100644
--- a/apache-poi/src/test/java/com/baeldung/jexcel/JExcelIntegrationTest.java
+++ b/apache-poi/src/test/java/com/baeldung/jexcel/JExcelIntegrationTest.java
@@ -1,25 +1,18 @@
package com.baeldung.jexcel;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import jxl.read.biff.BiffException;
-import java.util.Map;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.baeldung.jexcel.JExcelHelper;
-
-import jxl.write.WriteException;
-import jxl.read.biff.BiffException;
-
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.Before;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import jxl.read.biff.BiffException;
+import jxl.write.WriteException;
public class JExcelIntegrationTest {
diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelIntegrationTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelIntegrationTest.java
index 5d7ccb9b94..d2fa08e9ea 100644
--- a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelIntegrationTest.java
+++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelIntegrationTest.java
@@ -1,22 +1,15 @@
package com.baeldung.poi.excel;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import jxl.read.biff.BiffException;
-import java.util.Map;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.baeldung.poi.excel.ExcelPOIHelper;
-
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.Before;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class ExcelIntegrationTest {
diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStyleHandlerUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStyleHandlerUnitTest.java
index e131db8e56..1aa6445511 100644
--- a/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStyleHandlerUnitTest.java
+++ b/apache-poi/src/test/java/com/baeldung/poi/excel/cellstyle/CellStyleHandlerUnitTest.java
@@ -1,17 +1,19 @@
package com.baeldung.poi.excel.cellstyle;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.URISyntaxException;
import java.nio.file.Paths;
-import static org.junit.Assert.assertEquals;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Before;
+import org.junit.Test;
public class CellStyleHandlerUnitTest {
private static final String FILE_NAME = "cellstyle/CellStyleHandlerTest.xlsx";