| | |
| | | */ |
| | | public class WordUtil { |
| | | |
| | | public static byte[] compileTemplateAndRenderData(TbWordVO tbWordVO) throws Exception { |
| | | public static byte[] compileTemplateAndRenderData(TbWordVO tbWordVO,Map<String,Object> tableMap) throws Exception { |
| | | InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/doc/skcgmb.docx"); |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream).render(createParams(tbWordVO)); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream).render(createParams(tbWordVO,tableMap)); |
| | | template.write(outputStream); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | private static Map<String, Object> createParams(TbWordVO tbWordVO) { |
| | | private static Map<String, Object> createParams(TbWordVO tbWordVO,Map<String,Object> tableMap) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("水库名称", tbWordVO.getResName()); |
| | | params.put("市", tbWordVO.getCityName()); |
| | |
| | | params.put("主管部门责任人", tbWordVO.getCompetentDepartmentInfo()); // 责任人信息表,不是填报表 |
| | | params.put("行政主管单位", tbWordVO.getAdministrativeUnit()); |
| | | params.put("行政责任人职务手机号码", tbWordVO.getAdministrativeInfo()); // 责任人信息表,不是填报表 |
| | | |
| | | |
| | | params.putAll(tableMap); |
| | | |
| | | return params; |
| | | } |
| | | |