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
  • 相关阅读:
    Ubuntu 18.04 LTS 启用BBR
    MySQL with JDBC <一>
    HTML 实录 <一>
    Nginx CloudFlare 客户端真实IP
    Ubuntu 16.04 释放升级到 18.04 后, man: command exited with status 4
    JSP 从入门到精通 <一>
    Nginx URL重写
    JavaScript 修改 CSS 伪类属性
    i-83.net quadhost子产品
    HTML 重定向 页面跳转
  • 原文地址:https://www.cnblogs.com/xyzxy/p/12590214.html
Copyright © 2011-2022 走看看