Author: fanningpj
Date: Tue May 13 17:35:25 2025
New Revision: 1925536

URL: http://svn.apache.org/viewvc?rev=1925536&view=rev
Log:
[bug-69688] only try to get formula if the cell is of formula type

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowColShifter.java

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=1925536&r1=1925535&r2=1925536&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java 
(original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java 
Tue May 13 17:35:25 2025
@@ -862,7 +862,7 @@ public final class HSSFCellStyle impleme
             CellUtil.cloneStyle(source, this, _hssfWorkbook);
         }
     }
-    
+
     public void cloneStyleFrom(HSSFCellStyle source) {
         // First we need to clone the extended format
         //  record

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowColShifter.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowColShifter.java?rev=1925536&r1=1925535&r2=1925536&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowColShifter.java
 (original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowColShifter.java
 Tue May 13 17:35:25 2025
@@ -62,19 +62,19 @@ import static org.apache.logging.log4j.u
     }
 
     /**
-     * Update the formulas in specified row using the formula shifting policy 
specified by shifter
+     * Update the formulas in the specified row using the formula shifting 
policy specified by shifter
      *
      * @param row the row to update the formulas on
      * @param formulaShifter the formula shifting policy
      */
     /*package*/ static void updateRowFormulas(HSSFRow row, FormulaShifter 
formulaShifter) {
-        HSSFSheet sheet = row.getSheet();
-        for (Cell c : row) {
-            HSSFCell cell = (HSSFCell) c;
-            String formula = cell.getCellFormula();
-            if (formula.length() > 0) {
-                String shiftedFormula = shiftFormula(row, formula, 
formulaShifter);
-                cell.setCellFormula(shiftedFormula);
+        for (Cell cell : row) {
+            if (cell.getCellType() == CellType.FORMULA) {
+                String formula = cell.getCellFormula();
+                if (formula != null && !formula.isEmpty()) {
+                    String shiftedFormula = shiftFormula(row, formula, 
formulaShifter);
+                    cell.setCellFormula(shiftedFormula);
+                }
             }
         }
     }



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

Reply via email to