use of com.monitorjbl.xlsx.exceptions.OpenException 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);
ReadOnlySharedStringsTable sst = new ReadOnlySharedStringsTable(pkg);
StylesTable styles = reader.getStylesTable();
loadSheets(reader, sst, styles, builder.getRowCacheSize());
} catch (IOException e) {
throw new OpenException("Failed to open file", e);
} catch (OpenXML4JException | XMLStreamException | SAXException e) {
throw new ReadException("Unable to read workbook", e);
} catch (GeneralSecurityException e) {
throw new ReadException("Unable to read workbook - Decryption failed", e);
}
}
Aggregations