}
@Test
- public void existingWorkbook() {
+ public void existingWorkbook() throws IOException {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
xssfWorkbook.createSheet("S1");
SXSSFWorkbook wb = new SXSSFWorkbook(xssfWorkbook);
- xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
- assertTrue(wb.dispose());
-
- wb = new SXSSFWorkbook(xssfWorkbook);
- assertEquals(1, wb.getNumberOfSheets());
- Sheet sheet = wb.getSheetAt(0);
- assertNotNull(sheet);
- assertEquals("S1", sheet.getSheetName());
- assertTrue(wb.dispose());
+ try {
+ xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
+ assertTrue(wb.dispose());
+
+ wb = new SXSSFWorkbook(xssfWorkbook);
+ assertEquals(1, wb.getNumberOfSheets());
+ Sheet sheet = wb.getSheetAt(0);
+ assertNotNull(sheet);
+ assertEquals("S1", sheet.getSheetName());
+ } finally {
+ assertTrue(wb.dispose());
+ wb.close();
+ }
}
XSSFWorkbook xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
sss = (SharedStringsTable)f.get(wb);
assertEquals(2, sss.getUniqueCount());
- wb.dispose();
+ assertTrue(wb.dispose());
Sheet sheet1 = xssfWorkbook.getSheetAt(0);
assertEquals("S1", sheet1.getSheetName());
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.BaseTestCell;
import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.ErrorConstants;
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.usermodel.Row;
// string to error code
cell.setCellValue("abc");
confirmStringRecord(sheet, true);
- cell.setCellErrorValue((byte)ErrorConstants.ERROR_REF);
+ cell.setCellErrorValue(FormulaError.REF.getCode());
confirmStringRecord(sheet, false);
// string to boolean