]> source.dussan.org Git - poi.git/commitdiff
add support for reading hyperlinks that have cell refs that are area references ...
authorPJ Fanning <fanningpj@apache.org>
Tue, 10 Aug 2021 14:10:59 +0000 (14:10 +0000)
committerPJ Fanning <fanningpj@apache.org>
Tue, 10 Aug 2021 14:10:59 +0000 (14:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892178 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java

index 4804116312b4b7be941b3294ac1dbbdb8e0e83a1..58ccde183e8cd52598007970a5fd9569fda69887 100644 (file)
@@ -355,8 +355,11 @@ public class XSSFHyperlink implements Hyperlink {
      */
     @Override
     public void setLastColumn(int col) {
+        int firstColumn = getFirstColumn();
+        if (col < firstColumn) firstColumn = col;
+        String firstCellRef = CellReference.convertNumToColString(firstColumn) + (getFirstRow() + 1);
         String lastCellRef = CellReference.convertNumToColString(col) + (getLastRow() + 1);
-        setCellRange(buildFirstCellReference().formatAsString() + ":" + lastCellRef);
+        setCellRange(firstCellRef + ":" + lastCellRef);
     }
 
     /**
@@ -380,8 +383,11 @@ public class XSSFHyperlink implements Hyperlink {
      */
     @Override
     public void setLastRow(int row) {
+        int firstRow = getFirstRow();
+        if (row < firstRow) firstRow = row;
+        String firstCellRef = CellReference.convertNumToColString(getFirstColumn()) + (firstRow + 1);
         String lastCellRef = CellReference.convertNumToColString(getLastColumn()) + (row + 1);
-        setCellRange(buildFirstCellReference().formatAsString() + ":" + lastCellRef);
+        setCellRange(firstCellRef + ":" + lastCellRef);
     }
 
     private void setCellRange(String range) {