电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

word的docx中的文字、图片替换说明VIP免费

word的docx中的文字、图片替换说明_第1页
1/14
word的docx中的文字、图片替换说明_第2页
2/14
word的docx中的文字、图片替换说明_第3页
3/14
1,需要的jar: 2,替换docx 文档的文字、图片实例 * 注意事项: * word 中的替换的文字replaceStr 一定是从普通 txt 文本中粘贴过来的,这样才可以保证这些 replaceStr 的所有属性一致 * 才能保证这些 replaceStr 在同一个 XWPFRun 中。 public class WordTest2 { String templatePathX = "D:/temp/打印样本/poi/打印样本.docx"; String savePath = "D:/temp/打印样本/poi/打印样本-temp.docx"; //image String logoImagePath = "D:/temp/打印样本/forest_logo.png"; String IconImagePath = "D:/temp/打印样本/icon.jpg"; @Test public void testDocx() { try { WordDocxUtil wordDocxUtil=new WordDocxUtil(templatePathX); // ArrayList replaceEles =wordDocxUtil.getReplaceElements("\\$\\{[^{}]+\\}"); // for(String replaceEle:replaceEles){ // System.out.println(replaceEle); // } //替换文字 // Map map = new HashMap(); // map.put("${orderId}", "B123123"); // map.put("${boxName}", "王五"); // map.put("${course-1}", "语文"); // map.put("${score}", "85"); // wordDocxUtil.replaceText(map); //单个文字替换 // wordDocxUtil.replaceText("${course}", "语文"); //正则表达式文字替换 // wordDocxUtil.replaceTextByRegex("\\$\\{course-\\d\\}", "[-_-]"); //替换图片 // Map imageMap = new HashMap(); // imageMap.put("width", "50"); // imageMap.put("height", "50"); // imageMap.put("imageType", WordDocxUtil.getSuffix(logoImagePath)); // imageMap.put("content", WordDocxUtil.inputStream2ByteArray(new FileInputStream(logoImagePath), true)); // wordDocxUtil.replaceImage("${forestLogo}", imageMap); // // imageMap = new HashMap(); // imageMap.put("width", "50"); // imageMap.put("height", "50"); // imageMap.put("imageType", WordDocxUtil.getSuffix(IconImagePath)); // imageMap.put("content", WordDocxUtil.inputStream2ByteArray(new FileInputStream(IconImagePath), true)); // wordDocxUtil.replaceImage("${icon}", imageMap); //...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

word的docx中的文字、图片替换说明

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部