@RequestMapping("getExcel")
public void getExcel(InsExcelParas insExcelParas, HttpServletResponse response) throws IOException {
try {
if (null!= insExcelParas){
if (insExcelParas.getImei()!=null && !insExcelParas.getImei().equals("")) {
HSSFWorkbook wb = excelUtil.getHSSFWorkbook(new HSSFWorkbook(), insExcelParas);
response.reset();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=".concat(String.valueOf(URLEncoder.encode(insExcelParas.getImei() + new Date().getTime() + ".xlsx", "UTF-8"))));
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
wb.write(toClient);
toClient.flush();
toClient.close();
}
}
}catch (Exception e){
e.printStackTrace();
}
}
insExcelParas.getImei() + new Date().getTime() + “.xlsx” 为文件名
wb为生成的Excel