]> source.dussan.org Git - poi.git/commitdiff
[bug-65973] partial fix for removing hyperlinks that span multiple cells
authorPJ Fanning <fanningpj@apache.org>
Tue, 22 Mar 2022 11:44:31 +0000 (11:44 +0000)
committerPJ Fanning <fanningpj@apache.org>
Tue, 22 Mar 2022 11:44:31 +0000 (11:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899129 13f79535-47bb-0310-9956-ffa450edef68

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

index a5aa37b7fe93370dfbea2da6f509e0044586128c..27bd123c23a3fb818d6a37d028b854f0129940ea 100644 (file)
@@ -3084,8 +3084,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
         // also remove any hyperlinks associated with this row
         if (hyperlinks != null) {
             for (XSSFHyperlink link : new ArrayList<>(hyperlinks)) {
-                CellReference ref = new CellReference(link.getCellRef());
-                if (rowsToRemoveSet.contains(ref.getRow())) {
+                CellRangeAddress range = CellRangeAddress.valueOf(link.getCellRef());
+                //TODO handle case where hyperlink ref spans many rows (https://bz.apache.org/bugzilla/show_bug.cgi?id=65973)
+                if (range.getFirstRow() == range.getLastRow() && rowsToRemoveSet.contains(range.getFirstRow())) {
                     hyperlinks.remove(link);
                 }
             }