//导出Excel
            try {
                HSSFWorkbook wb = carService.export(list);  //调用service方法~!
                response.setContentType("application/vnd.ms-excel");  
                response.setHeader("Content-disposition", "attachment;filename=carsList.xls");  
                OutputStream ouputStream = response.getOutputStream();  
                wb.write(ouputStream);  
                ouputStream.flush();  
                ouputStream.close(); 
            } catch (Exception e) {    
                logger.error("车辆信息导出excel错误:", e);
            }  
            return null;

//导出zip文件
//response.reset();  
                        response.setCharacterEncoding("utf-8");
                        response.setContentType("application/octet-stream;charset=UTF-8");
                        response.setHeader("Content-Disposition", "attachment; filename=\"" + zipName + "\"");   
                        InputStream is = new FileInputStream(zipFile);     //是文件而不是文件名。
                        FileCopyUtils.copy(is, response.getOutputStream());//将文件写到输出流中
                        return null;

 

相关文章:

  • 2021-07-21
  • 2021-04-19
  • 2021-09-08
  • 2021-11-10
  • 2021-07-13
  • 2022-01-15
  • 2021-08-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案