[bug-65973] partial fix for removing hyperlinks that span multiple cells

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899138 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-03-22 17:55:53 +00:00
parent d41a40abc8
commit aff20dc6f9
1 changed files with 20 additions and 1 deletions

View File

@ -2288,7 +2288,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
}
@Test
void testRowShiftWithHyperlink() throws IOException {
void testRowShiftWithHyperlink1() throws IOException {
try (XSSFWorkbook wb = createWorkbookForRowShiftWithHyperlink1(true)) {
XSSFSheet sheet = wb.getSheetAt(0);
List<XSSFHyperlink> hyperlinks = sheet.getHyperlinkList();
@ -2306,6 +2306,25 @@ public final class TestXSSFSheet extends BaseTestXSheet {
}
}
@Test
void testRowShiftWithHyperlink2() throws IOException {
try (XSSFWorkbook wb = createWorkbookForRowShiftWithHyperlink1(false)) {
XSSFSheet sheet = wb.getSheetAt(0);
List<XSSFHyperlink> hyperlinks = sheet.getHyperlinkList();
assertEquals(1, hyperlinks.size());
assertEquals("B1:B2", hyperlinks.get(0).getCellRef());
assertEquals(3, sheet.getLastRowNum());
sheet.shiftRows(2, 3, -2);
assertEquals(1, sheet.getLastRowNum());
XSSFRow row0 = sheet.getRow(0);
XSSFRow row1 = sheet.getRow(1);
assertEquals("row2", row0.getCell(0).getStringCellValue());
assertEquals("row3", row1.getCell(0).getStringCellValue());
assertEquals(0, sheet.getHyperlinkList().size());
}
}
private XSSFWorkbook createWorkbookForRowShiftWithHyperlink1(boolean hyperlinkOneRow) {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");