java ~ word模板填充字符后输出到指定目录

word文件格式:

jar包:

复制代码
	<dependency>
		<groupId>com.deepoove</groupId>
		<artifactId>poi-tl</artifactId>
		<version>1.10.0</version>
	</dependency>

样例代码:

复制代码
	// 封装参数集合
	Map<String, Object> data = new HashMap<String, Object>() {{
         put("date", DateUtil.format("yyyy年MM月dd日", new Date()));
     }};

	try (InputStream is = new ClassPathResource("file/path/fileName.docx").getInputStream()) {
	ConfigureBuilder builder = Configure.builder();
	    XWPFTemplate template = XWPFTemplate.compile(is, builder.build()).render(data);
	    String wordPath = "E:\\newFileName.docx";
	    template.writeAndClose(Files.newOutputStream(Paths.get(wordPath)));
	} catch (IOException e) {
	    throw new RuntimeException(e);
	}
相关推荐
ytttr8731 分钟前
地震数据频率波数域变换与去噪的MATLAB实现
开发语言·matlab
若鱼19191 分钟前
SpringBoot4.0新特性-BeanRegistrar
java·spring
墨瑾轩21 分钟前
C# PictureBox:5个技巧,从“普通控件“到“图像大师“的蜕变!
开发语言·c#·swift
墨瑾轩29 分钟前
WinForm PictureBox控件:3个让图片“活“起来的骚操作,90%的开发者都踩过坑!
开发语言·c#
Ethernet_Comm44 分钟前
从 C 转向 C++ 的过程
c语言·开发语言·c++
难得的我们1 小时前
C++与区块链智能合约
开发语言·c++·算法
好好研究1 小时前
SpringBoot - yml配置文件
java·spring boot·spring
jllllyuz1 小时前
基于MATLAB的D2D通信模式选择仿真
开发语言·网络·matlab
kaikaile19951 小时前
基于ADMM的TV正则化稀疏重建MATLAB实现
开发语言·matlab
diediedei1 小时前
C++编译期正则表达式
开发语言·c++·算法