<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.5.0</version>
</dependency>
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.PictureRenderData;
import com.deepoove.poi.util.BytePictureUtils;
private File getBeforeSignTemplate() throws Exception {
String fileName = "template/人脸证明报告.docx";
String outFileName = "d://out.docx";
// 填充数据
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("curdate", "2023-09-05");
dataMap.put("fininstName", "网商");
dataMap.put("pic1", new PictureRenderData(120, 130, ".jpg", BytePictureUtils.getLocalByteArray(picMap.get(record.getCollectpicmd5()))));
XWPFTemplate template = XWPFTemplate.compile(new ClassPathResource(fileName).getFile()).render(dataMap);
FileOutputStream os = new FileOutputStream(outFileName);
template.write(os);
os.flush();
os.close();
template.close();
return new File(outFileName);
}
标签:word,XWPFTemplate,模版,template,poi,new,os,dataMap
From: https://www.cnblogs.com/lovedaodao/p/17932757.html