maven
<dependency> ??? <groupId>com.deepoove</groupId> ??? <artifactId>poi-tl</artifactId> ??? <version>1.10.0</version> </dependency>
Poi-tl 实现效果
{{@}}? 标签才能识别
?代码
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.PictureType;
import com.deepoove.poi.data.Pictures;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
public class Test {
public static void main(String[] args) throws IOException {
XWPFTemplate template = XWPFTemplate.compile("E:\\SHIFAN\\test\\YCXZQZCSQXSPB.docx").render(
new HashMap<String, Object>(){{
put("处理人1签名", Pictures.ofStream(new FileInputStream("E:\\SHIFAN\\test\\勇.png"), PictureType.PNG)
.size(50, 25).create());
put("处理人2签名", Pictures.ofStream(new FileInputStream("E:\\SHIFAN\\test\\江.png"), PictureType.PNG)
.size(50, 25).create());
put("执法机关签名", Pictures.ofStream(new FileInputStream("E:\\SHIFAN\\test\\强.png"), PictureType.PNG)
.size(50, 25).create());
}});
template.write(new FileOutputStream("E:\\SHIFAN\\test\\YCXZQZCSQXSPBs.docx"));
}
}
|