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 }
相关文章:
- C# 在word中查找及替换文本 2021-12-19
- 动态替换fragment 2021-06-06
- Word文档模板替换 2021-12-31
- 替换word文件内容 2021-05-22
- Java Word中的文本、图片替换功能 2021-10-26
- Word文字替换为图片 2021-07-11
- 批量删除文本空行/批量替换文本-word¬epad++ 2021-07-17
- java处理word文档 替换文本 水印 页眉 2021-10-13