use of org.apache.poi.openxml4j.util.ZipFileZipEntrySource in project poi by apache.
the class SXSSFWorkbook method write.
/**
* Write out this workbook to an OutputStream.
*
* @param stream - the java OutputStream you wish to write to
* @exception IOException if anything can't be written.
*/
@Override
public void write(OutputStream stream) throws IOException {
flushSheets();
//Save the template
File tmplFile = TempFile.createTempFile("poi-sxssf-template", ".xlsx");
boolean deleted;
try {
FileOutputStream os = new FileOutputStream(tmplFile);
try {
_wb.write(os);
} finally {
os.close();
}
//Substitute the template entries with the generated sheet data files
final ZipEntrySource source = new ZipFileZipEntrySource(new ZipFile(tmplFile));
injectData(source, stream);
} finally {
deleted = tmplFile.delete();
}
if (!deleted) {
throw new IOException("Could not delete temporary file after processing: " + tmplFile);
}
}
Aggregations