对于JSON中的API响应,$ this-> set不起作用

时间:2019-07-02 09:23:22

标签: cakephp-3.x

我包括了$ routes-> extensions(['json','xml']);在routes.php中。但是下面的代码不起作用

try (Workbook workbook = new XSSFWorkbook()) {
                new XlsExporter().exportXls(workbook, grh);
                SimpleDateFormat sdf = new SimpleDateFormat("_dd_MM_yyyy_HH_mm");
                String name = grh.getReportName() + sdf.format(new Date());
                response.setContentType(MediaType.APPLICATION_OCTET_STREAM.getType());
                response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + name +  ".xlsx\"");
                workbook.write(response.getOutputStream());
                response.getOutputStream().flush();
            }

0 个答案:

没有答案