后台导出方法:

 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 }
View Code

相关文章:

  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-08-26
  • 2021-12-01
  • 2021-09-01
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2022-02-12
  • 2021-12-31
  • 2021-08-26
  • 2022-12-23
  • 2021-08-18
  • 2021-12-22
  • 2022-03-09
相关资源
相似解决方案