- 1、本文档共14页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
word的x中的文字图片替换说明
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);
// ArrayListString replaceEles =wordDocxUtil.getReplaceElements(\\$\\{[^{}]+\\});
// for(String replaceEle:replaceEles){
// System.out.println(replaceEle);
// }
//替换文字
// MapString, String map = new HashMapString, String();
// 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\\}, [-_-]);
//替换图片
// MapString, Object imageMap = new HashMapString, Object();
// 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 HashMapString, Object();
// 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);
// setComboboxValue(paytype, 1,3,5,6);
// setComboboxValue(makeType, aa,vv);
wordDocxUtil.save(savePath);
} catch (Exception e) {
e.printStackTrace();
}
}
}
2,导入docx文档的操作帮助类
package com
您可能关注的文档
- The ELODIE Planet Search Synthetic View of the Survey and its Global Detection Threshold.pdf
- The Environment Factors Analysis of Electronic Commerce Credit System in China.pdf
- The EndtoEnd Effects of Internet Path Selection.pdf
- The Effects of Voluntary, Involuntary, and Forced Exercises.pdf
- The Fusion ObjectOriented Method an Evaluation (Extended Abstract).pdf
- The Extension of RodCoil Multiblock Copolymers and the Effect of the HelixCoil Transition.pdf
- The Future of Interior Design.ppt
- The Feedback Effect of Hedging in Portfolio Optimization.pdf
- The Global Convergence of Selfscale BFGS Algorithm with Nonmonotone Line Search for Uncons.pdf
- The Global Convergence of SelfScaling BFGS Algorithm with Nonmonotone Line Search for Unco.pdf
- word打开出错解决方法.doc
- Workjob及其他.pdf
- word老出现安全模式的处理方法.doc
- word错误打不开的解决办法.doc
- Worklist的基本概念和工作原理.docx
- WorstCase Performance Analysis of Parallel, Communicating Software Processes.pdf
- World Journal of Modelling and Simulation.pdf
- Work_Life_Balance工作与生活的平衡.ppt
- Writing Tips For Economics Research Pap ers.pdf
- WSockExpert使用方法 教程.doc
最近下载
- 合作开发农贸市场项目协议书7篇.docx
- BS EN 28510-1-2014 胶粘剂 柔性粘结刚性试件组件的剥离试验 90°剥离.pdf VIP
- 2023-2024学年五年级下册数学冀教版 期中测试卷(含答案) .pdf VIP
- 机器学习_聚类.ppt VIP
- (安装工程)广联达BIM5D软件教程-学习课件.ppt VIP
- 采暖系统施工方案.doc VIP
- 最新2023版知识产权贯标GBT29490表单 知识产权法律法规及其他要求合规性评价表[知识产权合规管理体系文件].docx
- 一种铁路车辆能量回收装置和铁路车辆.pdf VIP
- 最新2023版知识产权贯标GBT29490表单 知识产权风险和机遇识别评价清单[知识产权合规管理体系文件].docx
- 加热炉专利申说明书.pdf VIP
文档评论(0)