[bug-66230] don't fail to create SXSSFSheet if auto size tracker can't be initialized

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903533 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-08-18 21:08:41 +00:00
parent fafadd5037
commit 214fe205c4
2 changed files with 13 additions and 2 deletions

View File

@ -31,7 +31,7 @@ public class SXSSFITestDataProviderWithNullAutoSizeTracker extends SXSSFITestDat
@Override
public SXSSFWorkbook createWorkbook() {
SXSSFWorkbook wb = new SXSSFWorkbook();
SXSSFWorkbook wb = new SXSSFWorkbookWithNullAutoSizeTracker();
instances.add(wb);
return wb;
}
@ -39,7 +39,7 @@ public class SXSSFITestDataProviderWithNullAutoSizeTracker extends SXSSFITestDat
//************ SXSSF-specific methods ***************//
@Override
public SXSSFWorkbook createWorkbook(int rowAccessWindowSize) {
SXSSFWorkbook wb = new SXSSFWorkbook(rowAccessWindowSize);
SXSSFWorkbook wb = new SXSSFWorkbookWithNullAutoSizeTracker(rowAccessWindowSize);
instances.add(wb);
return wb;
}

View File

@ -671,4 +671,15 @@ public final class TestSXSSFWorkbookWithNullAutoSizeTracker extends BaseTestXWor
}
}
@Test
public void disableAutoSizeTracker() throws IOException {
try (Workbook workbook = _testDataProvider.createWorkbook(10)) {
assertThrows(IllegalStateException.class, () -> {
Sheet sheet = workbook.createSheet("testSheet");
sheet.createRow(0).createCell(0).setCellValue(0);
sheet.autoSizeColumn(0);
});
}
}
}