java根據Doc模板填充數據


 <!-- 模版引擎用到的jar包 -->
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.17</version>
    </dependency>
    
    <dependency>
      <groupId>com.deepoove</groupId>
      <artifactId>poi-tl</artifactId>
      <version>1.3.1</version>
    </dependency>

    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>3.17</version>
    </dependency>

    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-scratchpad</artifactId>
      <version>3.17</version>
    </dependency>

    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>ooxml-schemas</artifactId>
      <version>1.3</version>
    </dependency>

 

 1     /**
 2      * 
 3      * @throws Exception 
 4      * @Description 模板導出
 5      * @category
 6      * @author 張銀彪  
 7      * @date 2020年2月19日 下午4:13:46
 8      */
 9     @GetMapping("/test")
10     public void name() throws Exception {
11         XWPFTemplate template = XWPFTemplate.compile(ResourceUtils.getFile("classpath:售后服務表單2.docx").getAbsolutePath()).render(new HashMap<String, Object>(){{  
12             put("title", "Poi-tl 模板引擎");
13     }});
14     FileOutputStream out = new FileOutputStream("out_template.docx");
15     template.write(out); 
16     out.flush();
17     out.close();
18     template.close();
19     }
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM