poi--1.导出路径

来源:互联网 发布:java打包成exe 编辑:程序博客网 时间:2024/06/06 00:21

1      所需jar包

1.1  Jar

由于jar不多,可以直接导入所有,不必区分

 

1.2  pom.xml

 

 

2      导出自动展示

2.1  默认地址

C:\Users\Administrator.LS--20161013LKV\Downloads

 

2.2  后台:controller

@RequestMapping("/exportWordToHTML")public void exportWordToHTML(String dateKey,HttpServletRequestrequest, HttpServletResponse response){   Map<String, Object> map = new HashMap<String, Object>();   map.put("date_key", dateKey);      XWPFDocument xwpf = null;                      //word总文档   OutputStream os = null;                            //输出流文档   String dateKeybegin = null;      try {      dateKeybegin = dateKey.substring(0, 2);      if ("11".equals(dateKeybegin)) {         xwpf = wdcService.exportWordDay(map); //输出日报      } else if("15".equals(dateKeybegin)) {         xwpf = wdcService.exportWordWeek(map); //输出周报      }      response.setContentType("application/force-download");      response.addHeader("Content-Disposition", "attachment;fileName=" + dateKey + ".docx");              os = response.getOutputStream();      xwpf.write(os);      os.close();               } catch (Exceptione) {      e.printStackTrace();   }}  

2.3  前端

 

 

3      导出下载操作

3.1  前端

         本质就是后台生成了一个word,再去访问一下他,会得到浏览器的默认响应操作

 

 

 

 

 

原创粉丝点击