Skip to content

Commit

Permalink
Merge pull request #25 from dsl-builders/feature/fill-workbook
Browse files Browse the repository at this point in the history
prepare workbook without writing the output
  • Loading branch information
musketyr authored Oct 17, 2022
2 parents 0860300 + 56aa666 commit 9ae48f8
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static SpreadsheetBuilder create(File file, File template) throws IOExcep
return new PoiSpreadsheetBuilder(new XSSFWorkbook(template), new FileOutputStream(file));
}

public static SpreadsheetBuilder prepare(Workbook workbook) {
return new PoiSpreadsheetBuilder(workbook, null);
}

public static SpreadsheetBuilder stream(OutputStream out) {
return new PoiSpreadsheetBuilder(new SXSSFWorkbook(), out);
}
Expand Down Expand Up @@ -90,7 +94,9 @@ public void build(Consumer<WorkbookDefinition> workbookDefinition) {
PoiWorkbookDefinition poiWorkbook = new PoiWorkbookDefinition(workbook);
workbookDefinition.accept(poiWorkbook);
poiWorkbook.resolve();
writeTo(outputStream);
if (outputStream != null) {
writeTo(outputStream);
}
}

private void writeTo(OutputStream outputStream) {
Expand Down

0 comments on commit 9ae48f8

Please sign in to comment.