I have a requirement to create two excel files at once. We use Apache POI to generate excel files and struts frames.
In an action class, steps like,
OutputStream outputStream = response.getOutputStream();
and then fill in the data from db and create one file using POI and call
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment; filename=ExportFile1.xls");
workbook.write(outputStream);
outputStream.flush();
and followed the same steps (fill in the data from db, write excel content) for the second file, like,
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment; filename=ExportFile2.xls");
workbook.write(outputStream);
outputStream.flush();
But only one file is created.
Is it possible in java to generate two files at the same time? Has anyone implemented this?
Pls note: Creating two sheets in one excel file is not required.
source
share