From: PJ Fanning Date: Mon, 9 Aug 2021 22:39:27 +0000 (+0000) Subject: fix broken test case X-Git-Tag: REL_5_1_0~50 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5e15f7bf773afaf0a4b9d2ef4f3031b06d671ea6;p=poi.git fix broken test case git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892144 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java index 8913859a2f..4804116312 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java @@ -341,8 +341,11 @@ public class XSSFHyperlink implements Hyperlink { */ @Override public void setFirstColumn(int col) { + int lastColumn = getLastColumn(); + if (col > lastColumn) lastColumn = col; String firstCellRef = CellReference.convertNumToColString(col) + (getFirstRow() + 1); - setCellRange(firstCellRef + ":" + buildLastCellReference().formatAsString()); + String lastCellRef = CellReference.convertNumToColString(lastColumn) + (getLastRow() + 1); + setCellRange(firstCellRef + ":" + lastCellRef); } /** @@ -363,8 +366,11 @@ public class XSSFHyperlink implements Hyperlink { */ @Override public void setFirstRow(int row) { + int lastRow = getLastRow(); + if (row > lastRow) lastRow = row; String firstCellRef = CellReference.convertNumToColString(getFirstColumn()) + (row + 1); - setCellRange(firstCellRef + ":" + buildLastCellReference().formatAsString()); + String lastCellRef = CellReference.convertNumToColString(getLastColumn()) + (lastRow + 1); + setCellRange(firstCellRef + ":" + lastCellRef); } /**