use of com.monitorjbl.xlsx.exceptions.ReadException in project data-prep by Talend.
the class StreamingWorkbookReader method init.
// to override https://bz.apache.org/bugzilla/show_bug.cgi?id=57699
public void init(File f) {
try {
if (builder.getPassword() != null) {
// Based on: https://poi.apache.org/encryption.html
POIFSFileSystem poifs = new POIFSFileSystem(f);
EncryptionInfo info = new EncryptionInfo(poifs);
Decryptor d = Decryptor.getInstance(info);
d.verifyPassword(builder.getPassword());
pkg = OPCPackage.open(d.getDataStream(poifs));
} else {
pkg = OPCPackage.open(f);
}
XSSFReader reader = new XSSFReader(pkg);
SharedStringsTable sst = reader.getSharedStringsTable();
StylesTable styles = reader.getStylesTable();
loadSheets(reader, sst, styles, builder.getRowCacheSize());
} catch (IOException e) {
throw new OpenException("Failed to open file", e);
} catch (OpenXML4JException | XMLStreamException e) {
throw new ReadException("Unable to read workbook", e);
} catch (GeneralSecurityException e) {
throw new ReadException("Unable to read workbook - Decryption failed", e);
}
}
use of com.monitorjbl.xlsx.exceptions.ReadException in project data-prep by Talend.
the class StreamingWorkbookReader method init.
public void init(InputStream is) {
File f = null;
try {
f = writeInputStreamToFile(is, builder.getBufferSize());
LOGGER.debug("Created temp file [{}", f.getAbsolutePath());
init(f);
tmp = f;
} catch (IOException e) {
throw new ReadException("Unable to read input stream", e);
} catch (RuntimeException e) {
FilesHelper.deleteQuietly(f);
throw e;
}
}
Aggregations