This is an automated email from the ASF dual-hosted git repository.

centic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git

commit 62ae400993f3d42edb08949f6d7fc63b030d879f
Author: Dominik Stadler <[email protected]>
AuthorDate: Mon Feb 2 18:09:40 2026 +0100

    Do not call getColumn() twice
    
    It always iterates over the array of columns, so we
    should reuse the result here.
---
 .../org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java | 13 +++++++++----
 .../apache/poi/xssf/usermodel/helpers/TestColumnHelper.java |  3 +--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
index a394b72d4a..6dcee13193 100644
--- 
a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
+++ 
b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
@@ -38,7 +38,7 @@ import 
org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
  */
 public class ColumnHelper {
 
-    private CTWorksheet worksheet;
+    private final CTWorksheet worksheet;
 
     public ColumnHelper(CTWorksheet worksheet) {
         super();
@@ -303,10 +303,15 @@ public class ColumnHelper {
         col.setStyle(styleId);
     }
     
-    // Returns -1 if no column is found for the given index
+    /**
+     * Get the default style index for the given column index
+     *
+     * @return The style-index or -1 if no column is found for the given index
+     */
     public int getColDefaultStyle(long index) {
-        if (getColumn(index, false) != null) {
-            return (int) getColumn(index, false).getStyle();
+        final CTCol column = getColumn(index, false);
+        if (column != null) {
+            return (int) column.getStyle();
         }
         return -1;
     }
diff --git 
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
 
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
index 95ccbb3c8a..2c92887a0a 100644
--- 
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
+++ 
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/helpers/TestColumnHelper.java
@@ -252,7 +252,7 @@ public final class TestColumnHelper {
     }
 
     /**
-     * Creates and adds a hidden column and then a best fit column with the 
given min/max pairs.
+     * Creates and adds a hidden column and then the best fit column with the 
given min/max pairs.
      * Suitable for testing handling of overlap.
      */
     private static CTCols createHiddenAndBestFitColsWithHelper(int hiddenMin, 
int hiddenMax, int bestFitMin, int bestFitMax) {
@@ -404,7 +404,6 @@ public final class TestColumnHelper {
         return count;
     }
 
-    @SuppressWarnings("deprecation")
     @Test
     void testColumnsCollapsed() throws IOException {
         try (XSSFWorkbook wb = new XSSFWorkbook()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to