许鹏程
2023-08-08 a2cfd417f673603633c6d46713d320bb1501f88c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.product.print.util;
 
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.config.ConfigureBuilder;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
 
/**
 * @Author cheng
 * @Date 2023/8/5 14:18
 * @Desc
 */
public class PrintTest {
 
    static String templatePath = "d:\\desktop\\APP_NOTICE_DECIDE.docx";
 
    static String outPath = "d:\\desktop\\APP_NOTICE_DECIDE_out.docx";
 
    public static void main(String[] args) throws IOException {
        Map<String, Object> values = new HashMap<>();
        values.put("name", "许鹏程");
        ConfigureBuilder config = Configure.createDefault().builder();
        JSONArray array = new JSONArray();
        JSONObject object=new JSONObject();
        object.put("node_uuid","flow");
        object.put("node_title","node_title");
        object.put("node_content","node_content");
        object.put("opinion","opinion");
        object.put("sign_attachment_uuid","sign_attachment_uuid");
        array.add(object);
        config.addPlugin('@', new FlowOpinionRenderPolicy(array));
        FileUtil.touch(outPath);
        XWPFTemplate.compile(templatePath, config.build()).render(values).writeToFile(outPath);
    }
}