zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    一、链式
    C#链式编程
    五、通过密码访问API
    四.二、控制台
    一、bootstrap-datepicker
    悔录
    四、IDS4建立Authorization server和Client
    三、IDS4建立authorization server
    一、前端请求后台方式
    【2019-10-09】思想是为了克服不懂而存在的
  • 原文地址:https://www.cnblogs.com/xyzxy/p/12590214.html
Copyright © 2011-2022 走看看