From 4f1f2c9f80ccbd8722f9109321a311c0901bc55b Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 24 Jul 2021 13:33:30 +0000 Subject: [PATCH] handle case where row nums are the same git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891775 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/poi/xssf/usermodel/XSSFRow.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 3992d59139..4c4f6a831b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -686,9 +686,11 @@ public class XSSFRow implements Row, Comparable { final int destRowNum = getRowNum(); final int rowDifference = destRowNum - srcRowNum; - final FormulaShifter formulaShifter = FormulaShifter.createForRowCopy(sheetIndex, sheetName, srcRowNum, srcRowNum, rowDifference, SpreadsheetVersion.EXCEL2007); - final XSSFRowShifter rowShifter = new XSSFRowShifter(_sheet); - rowShifter.updateRowFormulas(this, formulaShifter); + if (rowDifference != 0) { + final FormulaShifter formulaShifter = FormulaShifter.createForRowCopy(sheetIndex, sheetName, srcRowNum, srcRowNum, rowDifference, SpreadsheetVersion.EXCEL2007); + final XSSFRowShifter rowShifter = new XSSFRowShifter(_sheet); + rowShifter.updateRowFormulas(this, formulaShifter); + } // Copy merged regions that are fully contained on the row // FIXME: is this something that rowShifter could be doing? -- 2.39.5