//导出客户列表 @RequestMapping(value = "exportCustomerInfoList") @RequiresPermissions("customerInfo:show") public void exportCustomerInfoList(JpCustomerInfo customerInfo, HttpServletResponse response) { OutputStream outputStream=null; try { HSSFWorkbook workbook= jpCustomerInfoService.exportCustomerInfoExcel(customerInfo); outputStream = response.getOutputStream(); response.reset(); response.setContentType("application/msexcel"); // response.setCharacterEncoding("utf-8"); //设置浏览器响应头对应的Content-disposition 解决中文名字乱码 String filename = "客户管理"; response.setHeader("Content-disposition", "attachment;filename="+new String(filename.getBytes("gbk"), "iso8859-1")+".xls"); workbook.write(outputStream); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { try { outputStream.flush(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } }
java 将数据导出到excel 文件
猜你喜欢
转载自blog.csdn.net/shixiansen6535/article/details/85624480
今日推荐
周排行