| | |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | | public static byte[] GetEightFloodInfo() throws Exception{ |
| | | String templatePath = "word/doc/eightFloodInfoTemplate.docx"; |
| | | HashMap<String,Object> map = new HashMap<>(); |
| | | byte[] bytes = GenerateWord(templatePath, map); |
| | | return bytes; |
| | | } |
| | | |
| | | private static byte[] GenerateWord(String templatePath,Object object) throws Exception { |
| | | InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream(templatePath); |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream).render(object); |
| | | template.write(outputStream); |
| | | outputStream.flush(); |
| | | outputStream.close(); |
| | | return outputStream.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * 根据水库id获取数据 |
| | | * @return |