Java+POI+POI-tl模板工具包结合生成Word文档。
String fileEdocTemplate = "D:\\uploadfiles\\word2pdf\\"+formId+".docx";
//创建临时文件夹
String tempDirPath = fromPdfPath + File.separator + dataId+formId;
File tempDirFile = new File(tempDirPath);
boolean mkdir = tempDirFile.mkdir();
//输出的表单Word地址
String fileOut = tempDirPath+File.separator +"formWord.doc";
XWPFTemplate template = XWPFTemplate.compile(fileEdocTemplate).render(map);
FileOutputStream out;
try {
out = new FileOutputStream(fileOut);
template.write(out);
out.flush();
out.close();
template.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}