diff options
author | PJ Fanning <fanningpj@apache.org> | 2024-07-02 12:58:37 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2024-07-02 12:58:37 +0000 |
commit | 3d1375deee56ea921c35e86bcb8fe3e511fb80aa (patch) | |
tree | e1a5313baf0cc925f0e1fe272a0c495285c08ef1 /poi-ooxml | |
parent | a78d594b7396666e231cc19abf49ee5fd197235f (diff) | |
download | poi-3d1375deee56ea921c35e86bcb8fe3e511fb80aa.tar.gz poi-3d1375deee56ea921c35e86bcb8fe3e511fb80aa.zip |
[bug-69154] XSSF: Shifting columns with merged regions generates an error about overlapping regions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918838 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftColumns.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftColumns.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftColumns.java index 92d5735ec5..166fa73659 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftColumns.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftColumns.java @@ -21,9 +21,16 @@ package org.apache.poi.xssf.usermodel; import java.io.IOException; import org.apache.poi.ss.usermodel.BaseTestSheetShiftColumns; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellAddress; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; class TestXSSFSheetShiftColumns extends BaseTestSheetShiftColumns { public TestXSSFSheetShiftColumns() { @@ -40,4 +47,26 @@ class TestXSSFSheetShiftColumns extends BaseTestSheetShiftColumns { return XSSFTestDataSamples.writeOutAndReadBack(wb); } + @Test + public void testBug69154() throws Exception { + // this does not appear to work for HSSF but let's get it working for XSSF anyway + try (Workbook wb = _testDataProvider.createWorkbook()) { + Sheet sheet = wb.createSheet(); + for (int i = 0; i < 4; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < 6; j++) { + String value = new CellAddress(i, j).formatAsString(); + row.createCell(j).setCellValue(value); + } + } + final int firstRow = 1; // works with 0, but fails with 1! + final int secondRow = firstRow + 1; + sheet.addMergedRegion(new CellRangeAddress(firstRow, secondRow, 0, 0)); + sheet.addMergedRegion(new CellRangeAddress(firstRow, firstRow, 1, 2)); + sheet.addMergedRegion(new CellRangeAddress(firstRow, secondRow, 3, 3)); + assertEquals(3, sheet.getNumMergedRegions()); + sheet.shiftColumns(2, 5, -1); + assertEquals(2, sheet.getNumMergedRegions()); + } + } }
\ No newline at end of file |