文档没有导出word的具体描述,所以记录一下查找后的使用记录:
直接使用JeecgWordView ,传路径URL过去会存在问题,会默认在路径那里多加一个spliter(/),看了下github的源码,官方一直没有修改;
所以直接使用redirect跳转的方式访问下载链接即可.
后端代码如下:
controller部分:
Map<String, Object> map = new HashMap();
map.put("like",person.getLike()+"");
map.put("name",person.getName()+"");
//
SimpleDateFormat format0 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
map.put("startTime",format0.format(relation.getBeginDate()));
map.put("endTime",format0.format(relation.getEndDate()));
InputStream is = currentController.class.getClass().getResourceAsStream("/templates/workexport.docx");
ExportWordUtils.exportWord(is,"/tmp/wordExportTemp","导出表.docx",map,request,response);
后端controller返回void,接收get方法;
ExportWordUtils代码可见 我分享的 gist文件
至于前端,可以直接使用路径跳转来访问:
handleExportWord2(id){
let url = `${window._CONFIG['domianURL']}${this.url.exportWord2}?id=${id}`
window.location.href = url
},
this.url.exportWord2 的值即为后端api路径,使用href 进行跳转即可.