use of org.apache.poi.openxml4j.exceptions.OpenXML4JException in project poi by apache.
the class TestXSSFBugs method bug54764.
@Test
public void bug54764() throws IOException, OpenXML4JException, XmlException {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("54764.xlsx");
// Check the core properties - will be found but empty, due
// to the expansion being too much to be considered valid
POIXMLProperties props = new POIXMLProperties(pkg);
assertEquals(null, props.getCoreProperties().getTitle());
assertEquals(null, props.getCoreProperties().getSubject());
assertEquals(null, props.getCoreProperties().getDescription());
// Now check the spreadsheet itself
try {
new XSSFWorkbook(pkg).close();
fail("Should fail as too much expansion occurs");
} catch (POIXMLException e) {
// Expected
}
pkg.close();
// Try with one with the entities in the Content Types
try {
XSSFTestDataSamples.openSamplePackage("54764-2.xlsx").close();
fail("Should fail as too much expansion occurs");
} catch (Exception e) {
// Expected
}
// Check we can still parse valid files after all that
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
assertEquals(3, wb.getNumberOfSheets());
wb.close();
}
Aggregations