]> source.dussan.org Git - poi.git/commitdiff
add R1C1 test
authorPJ Fanning <fanningpj@apache.org>
Tue, 1 Feb 2022 12:15:16 +0000 (12:15 +0000)
committerPJ Fanning <fanningpj@apache.org>
Tue, 1 Feb 2022 12:15:16 +0000 (12:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897654 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java

index 0846f9499a89bc4c4e63ba4f9955fe469ec8c7b7..1087a4327ec661f50c9493181ecb1ce64b59aa0b 100644 (file)
@@ -1341,6 +1341,22 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
         }
     }
 
+    @Test
+    void checkExistingFileForR1C1Refs() throws IOException {
+        try (
+                UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+                XSSFWorkbook wb = openSampleWorkbook("WithTable.xlsx")
+        ) {
+            assertFalse(wb.usesR1C1CellReferences());
+            wb.setUseR1C1CellReferences(true);
+            assertTrue(wb.usesR1C1CellReferences());
+            wb.write(bos);
+            try (XSSFWorkbook wb2 = new XSSFWorkbook(bos.toInputStream())) {
+                assertTrue(wb2.usesR1C1CellReferences());
+            }
+        }
+    }
+
     private static void expectFormattedContent(Cell cell, String value) {
         assertEquals(value, new DataFormatter().formatCellValue(cell),
                 "Cell " + ref(cell) + " has wrong formatted content.");
index 0a42ed937a116b749cacf06c876111721ebd6b13..d0a5129cc81ca7a85cea7282810be005110e7b96 100644 (file)
@@ -1178,6 +1178,22 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
         }
     }
 
+    @Test
+    void checkExistingFileForR1C1Refs() throws IOException {
+        try (
+                UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+                HSSFWorkbook wb = openSampleWorkbook("49423.xls")
+        ) {
+            assertFalse(wb.usesR1C1CellReferences());
+            wb.setUseR1C1CellReferences(true);
+            assertTrue(wb.usesR1C1CellReferences());
+            wb.write(bos);
+            try (HSSFWorkbook wb2 = new HSSFWorkbook(bos.toInputStream())) {
+                assertTrue(wb2.usesR1C1CellReferences());
+            }
+        }
+    }
+
     @Disabled
     void createDrawing() {
         // the dimensions for this image are different than for XSSF and SXSSF