You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
681 B
20 lines
681 B
3 weeks ago
|
import com.deepoove.poi.XWPFTemplate;
|
||
|
|
||
|
import java.io.FileNotFoundException;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.util.Date;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
public class WordTest {
|
||
|
public static void main(String[] args) throws IOException {
|
||
|
Map<String,Object> context =new HashMap<>();
|
||
|
context.put("title", "Hi, poi-tl Word模板引擎");
|
||
|
context.put("date", new Date());
|
||
|
|
||
|
XWPFTemplate template = XWPFTemplate.compile("/Users/wangshaoping/Desktop/test/template.docx").render(context);
|
||
|
template.writeAndClose(new FileOutputStream("/Users/wangshaoping/Desktop/test/out.docx"));
|
||
|
}
|
||
|
}
|