| | |
| | | Map dataMap = new HashMap(); |
| | | String dataYX = getDataYX(dataMap, id); |
| | | String filePath = getClass().getResource("/template/").getPath(); |
| | | log.info("filePath的值为:{}", filePath); |
| | | System.out.println(filePath); |
| | | //设置模本装置方法和路径,FreeMarker支持多种模板装载方法。可以重servlet,classpath,数据库教程装载, |
| | | configuration.setDirectoryForTemplateLoading(new File(filePath)); |
| | |
| | | //输出文档路径及名称 |
| | | File outFile = new File(RuoYiConfig.getProfile() + "/download/wordtemplate/" + name + ".doc"); |
| | | Writer out = null; |
| | | |
| | | try { |
| | | out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8")); |
| | | |
| | | } catch (FileNotFoundException e1) { |
| | | e1.printStackTrace(); |
| | | log.error("FileNotFoundException报错信息是:{}",e1.getMessage()); |
| | | // e1.printStackTrace(); |
| | | } |
| | | try { |
| | | |
| | | t.process(dataMap, out); |
| | | } catch (TemplateException e) { |
| | | e.printStackTrace(); |
| | | log.error("TemplateException报错信自是:{}",e.getMessage()); |
| | | e.getMessage(); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("downloadUrl", "/profile/download/wordtemplate/" + name + ".doc"); |
| | |
| | | dataMap.put("CWSH", serviceFund.getFinancechecher() == null ? "" : serviceFund.getFinancechecher()); |
| | | |
| | | dataMap.put("YYMMDD", time); |
| | | dataMap.put("XM", serviceFund.getDonorname() == null ? "" : serviceFund.getDonorname()); |
| | | dataMap.put("XM", serviceFund.getDonorname() == null ? "" : serviceFund.getDonorname().trim()); |
| | | dataMap.put("GZRY", serviceFund.getUsername() == null ? "" : serviceFund.getUsername()); |
| | | dataMap.put("ZZ", serviceFund.getManagername() == null ? "" : serviceFund.getManagername()); |
| | | |