后台导出方法:
1 /** 2 * 后台导出方法 3 * 利用POI实现数据的批量导出 4 */ 5 public String export() throws Exception{ 6 Connection con = null; 7 try{ 8 con = dbUtil.getCon(); 9 Workbook wb = new HSSFWorkbook(); 10 String headers[] = {"编号", "姓名", "电话", "Email", "QQ"}; 11 ResultSet rs = userDao.userList(con, null); 12 ExcelUtil.fillExcelData(rs, wb, headers); 13 14 //把wb以流的形式输出 15 ResponseUtil.export(ServletActionContext.getResponse(), wb, "导出Excel.xls"); 16 }catch(Exception e){ 17 e.printStackTrace(); 18 }finally{ 19 try{ 20 dbUtil.closeCon(con); 21 dbUtil.closeRs(rs); 22 }catch(Exception e){ 23 e.printStackTrace(); 24 } 25 } 26 27 return null; 28 }