Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/main/java/com/ebay/xcelite/Xcelite.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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.
*
Expand Down