add R1C1 test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897654 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-02-01 12:15:16 +00:00
parent f5a0a843ac
commit ba7cbf4b3c
2 changed files with 32 additions and 0 deletions

View 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.");

View 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