Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public static Workbook openWorkbook(File excelFile) throws ETLException {
  2. try {
  3. return WorkbookFactory.create(excelFile);
  4. } catch (IOException | InvalidFormatException e) {
  5. ETLInterfaceLogger.getLogger().error("Cannot open Excel file");
  6. throw new ETLException("Error opening excel file: " + e.getMessage());
  7. }
  8. }
  9.  
  10. public void writeWorkbook(File outputPath) throws ETLException {
  11. FileOutputStream stream = null;
  12. try {
  13. stream = new FileOutputStream(outputPath);
  14. workbook.write(stream);
  15. stream.close();
  16. workbook.close();
  17. } catch (IOException e) {
  18. throw new ETLException("Error writing XLSX to disk: " + e.getMessage());
  19. } finally {
  20. if (stream != null)
  21. try {
  22. stream.close();
  23. } catch (IOException e) {
  24. ETLInterfaceLogger.getLogger().error("Cannot close outputstream: " + e.getMessage());
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement