How to export / generate two files at the same time?

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.

+3
source share
4 answers

I have a requirement to create two excel files at once.

, " ", " " , .

  • , "", ( , ), ( ), , .

  • - " ", zip . , / # 1: . , " zip". , , .

webapps .

+4

, HTTP-. . , , , , , excel, .

2 excel, , , , . - , RFC1341 7.2. , - java, .

( ) ZIP-. Java ZIP-.

+1

POI Apache. OutputStream.

, , , , , , "ExportFile1.xls" "ExportFile2.xls", ( , 2), . , .

0

.

zip , excel, . , , .

0

Source: https://habr.com/ru/post/1756311/


All Articles