aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java10
1 files changed, 8 insertions, 2 deletions
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);
}
/**