1 public class WordTest2 {
 2     public static void main(String[] args) {
 3 
 4         /** 此Map存放动态替换的内容,key-Word中定义的变量,value-要替换的内容 **/
 5         Map map = Maps.newHashMap();
 6         map.put("CL_XT_zlContractNo", "55555556444444888544");
 7         map.put("LOAN_memberName", "小赵");
 8         map.put("LOAN_certNo", "1234568524545");
 9         map.put("LOAN_address", "重庆市沙坪坝积极");
10         map.put("LOAN_mobileNo", "110110110");
11         map.put("LOAN_memberName", "张三");
12         map.put("LOAN_certNo", "510254545488445");
13         map.put("LOAN_address", "四川省锦州达到");
14         map.put("LOAN_mobileNo", "023-5854555");
15         map.put("GUARANTEE_guaPersonName", "李四");
16 
17         /** 此Map存放动态 批量生产Word中表格的内容 **/
18         List<String[]> tableDataList = new ArrayList<String[]>();
19         tableDataList.add(new String[] { "应还款日", "应还本金", "应付利息", "应还(付)总额" });
20         tableDataList.add(new String[] { "2018-01-01", "23", "0.2", "111" });
21         tableDataList.add(new String[] { "2018-01-02", "233", "0.2", "123" });
22         tableDataList.add(new String[] { "2018-01-03", "2333", "0.2", "321" });
23         tableDataList.add(new String[] { "2018-01-04", "2333", "0.2", "321" });
24         tableDataList.add(new String[] { "2018-01-05", "2333", "0.2", "321" });
25         tableDataList.add(new String[] { "2018-01-06", "2333", "0.2", "321" });
26         tableDataList.add(new String[] { "2018-01-07", "2333", "0.2", "321" });
27 
28         String localTemplateTmpPath = "E:\\new\\TestWord.docx";
29         String newContractLocalPath = "E:\\new\\TestWord2.docx";
30 
31         WordUtil.changWord(localTemplateTmpPath, newContractLocalPath, map, tableDataList);
32 
33     }
34 }
View Code

相关文章: