use of org.apache.poi.xssf.XLSBUnsupportedException in project poi by apache.
the class TestXSSFBugs method bug56800_xlsb.
/**
* .xlsb files are not supported, but we should generate a helpful
* error message if given one
*/
@Test
public void bug56800_xlsb() throws IOException, InvalidFormatException {
// Can be opened at the OPC level
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("Simple.xlsb");
// XSSF Workbook gives helpful error
try {
new XSSFWorkbook(pkg).close();
fail(".xlsb files not supported");
} catch (XLSBUnsupportedException e) {
// Good, detected and warned
}
// Workbook Factory gives helpful error on package
try {
WorkbookFactory.create(pkg).close();
fail(".xlsb files not supported");
} catch (XLSBUnsupportedException e) {
// Good, detected and warned
}
// Workbook Factory gives helpful error on file
File xlsbFile = HSSFTestDataSamples.getSampleFile("Simple.xlsb");
try {
WorkbookFactory.create(xlsbFile).close();
fail(".xlsb files not supported");
} catch (XLSBUnsupportedException e) {
// Good, detected and warned
}
pkg.close();
}
Aggregations