dhatim / fastexcel

Generate and read big Excel files quickly
Other
677 stars 122 forks source link

how to display the download window on the bottom in the browser? #267

Open dcKangs opened 1 year ago

dcKangs commented 1 year ago

Hi, I wrote an excel file using the fastexcel library and then i'm trying to download it at my front engine(jquery). As far as I know, I think using the fastexcel can be instantly show the download window on the bottom in the browser, while downloading the streaming data of the excel file on my server. But the download window, in my case, for the Chrome browser is showing that after being downloaded the all data completely. that's not what i want.

following is my server application sample to write to the stream of response OutputStream, immediately client request. I want to display instantly download window on the bottom in the browser while downloading bulk data. Can anyone tell me how to achieve this?

@PostMapping( value = "/download/excel", consumes = "application/json" ) public void excelDownload( @RequestBody TestRequest testRequest, HttpServletResponse response) { try (OutputStream os = response.getOutputStream()) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); String fileNameUtf8 = URLEncoder.encode(testRequest.getExcel().getFileName(), "UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=" + fileNameUtf8 + ".xlsx"); response.setHeader("Content-Transfer-Encoding", "binary"); ...... Workbook wb = new Workbook(os, "Excel", "1.0"); wb.setGlobalDefaultFont("Arial", 10); ..... ..... (blar blar) Worksheet ws = wb.newWorksheet(...); ws.value(blar blar); ws.flush(); ws.finish(); .... wb.finish(); } ....

meiMingle commented 1 year ago

This may be a related issue to #224 #134