
官方文档
旧地址:/
新地址:/
依赖
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-base</artifactId><version>3.0.3</version></dependency><dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-web</artifactId><version>3.0.3</version></dependency><dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-annotation</artifactId><version>3.0.3</version></dependency>
导出模板
导出接口
@RequestMapping("wordExport")public void wordExport(HttpServletResponse response) {Map<String, Object> map = new HashMap<String, Object>();map.put("university", "北京大学");map.put("studentName", "JueYue");map.put("AdmissionTime","2021年9月1日上午8点");map.put("writingDate","2021年8月1日");try {XWPFDocument doc = portWord07("/excel/通知书.docx", map);String fileName= "通知书-"+new Date().getTime()+".docx";downLoadExcel(fileName,response,doc);} catch (Exception e) {e.printStackTrace();}}//下载到页面public static void downLoadExcel(String fileName, HttpServletResponse response, XWPFDocument doc) {try {response.setCharacterEncoding("UTF-8");response.setHeader("content-Type", "application/vnd.ms-excel");response.setHeader("Content-Disposition","attachment;filename=" + de(fileName, "UTF-8"));doc.OutputStream());} catch (IOException e) {System.out.println("导出异常");}}
访问localhost:8080/importExcelwordExport
本文发布于:2024-03-05 00:51:49,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1709616525120780.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
| 留言与评论(共有 0 条评论) |