WorkbookFile implements AutoCloseable { public void close() { closeInputStream(); closeOutputStream(); try { if (workbook != null) { workbook.close(); } } catch (IOException e) {} } WorkbookFile();  WorkbookFile(File mainWorkbook, Integer maxWorkbookSize, boolean createIfNotExists);  WorkbookFile(File mainWorkbook, Integer maxWorkbookSize, boolean createIfNotExists, boolean forUpdate); void save(); void close(); Workbook getWorkbook();  }
@Test public void testSizeLimit() { Exception ex = null; try { WorkbookFile workbook = new WorkbookFile(getResourceFile("Excel1.xlsx"), 1, false); workbook.close(); } catch (Exception e) { ex = e; } Assert.assertTrue(ex!=null && "The size of the workbook 'Excel1.xlsx' exceeds the max size 1bytes.".equals(ex.getMessage())); }