Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Workbook openWorkbook(File excelFile) throws ETLException {
- try {
- return WorkbookFactory.create(excelFile);
- } catch (IOException | InvalidFormatException e) {
- ETLInterfaceLogger.getLogger().error("Cannot open Excel file");
- throw new ETLException("Error opening excel file: " + e.getMessage());
- }
- }
- public void writeWorkbook(File outputPath) throws ETLException {
- FileOutputStream stream = null;
- try {
- stream = new FileOutputStream(outputPath);
- workbook.write(stream);
- stream.close();
- workbook.close();
- } catch (IOException e) {
- throw new ETLException("Error writing XLSX to disk: " + e.getMessage());
- } finally {
- if (stream != null)
- try {
- stream.close();
- } catch (IOException e) {
- ETLInterfaceLogger.getLogger().error("Cannot close outputstream: " + e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement