// ignore password protected files
if (POIXMLDocumentHandler.isEncrypted(stream)) return;
- final XSSFWorkbook wb;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ IOUtils.copy(stream, out);
- // make sure the potentially large byte-array is freed up quickly again
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- IOUtils.copy(stream, out);
- final byte[] bytes = out.toByteArray();
-
- checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes)));
+ final byte[] bytes = out.toByteArray();
+ final XSSFWorkbook wb;
+ wb = new XSSFWorkbook(new ByteArrayInputStream(bytes));
- wb = new XSSFWorkbook(new ByteArrayInputStream(bytes));
- }
-
// use the combined handler for HSSF/XSSF
handleWorkbook(wb, ".xlsx");
// and finally ensure that exporting to XML works
exportToXML(wb);
+
+ checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes)));
}
// a test-case to test this locally without executing the full TestAllFiles
@Test
public void test() throws Exception {
- InputStream stream = new BufferedInputStream(new FileInputStream("test-data/openxml4j/50154.xlsx"));
+ InputStream stream = new BufferedInputStream(new FileInputStream("test-data/spreadsheet/ref-56737.xlsx"));
try {
handleFile(stream);
} finally {
// a test-case to test this locally without executing the full TestAllFiles
@Test
public void testExtractor() throws Exception {
- handleExtracting(new File("test-data/spreadsheet/56278.xlsx"));
+ handleExtracting(new File("test-data/spreadsheet/ref-56737.xlsx"));
}
}
\ No newline at end of file