From 695d820947f8ed6a68b180cf60f27b2b20af74c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20G=C3=B6bel?= Date: Wed, 28 Sep 2016 15:06:49 +0200 Subject: [PATCH] fix #3 --- src/main/java/com/ebay/xcelite/Xcelite.java | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ebay/xcelite/Xcelite.java b/src/main/java/com/ebay/xcelite/Xcelite.java index 90b7e9b..7735562 100644 --- a/src/main/java/com/ebay/xcelite/Xcelite.java +++ b/src/main/java/com/ebay/xcelite/Xcelite.java @@ -21,7 +21,8 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; - +import java.io.InputStream; +import java.io.OutputStream; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -45,6 +46,16 @@ public class Xcelite { public Xcelite() { workbook = new XSSFWorkbook(); } + + public Xcelite(InputStream inputStream) { + try { + workbook = new XSSFWorkbook(inputStream); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } + } public Xcelite(File file) { try { @@ -139,6 +150,21 @@ public void write(File file) { } } + /** + * Saves data to a new outputStream. + * + * @param out the outputstream to save the data into + */ + public void write(OutputStream out) { + try { + workbook.write(out); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } catch (IOException e) { + new RuntimeException(e); + } + } + /** * Gets the excel file as byte array. *