修复问题
This commit is contained in:
@@ -8,7 +8,6 @@ import freemarker.template.Template;
|
||||
import freemarker.template.Version;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -51,6 +50,32 @@ public class WordConvertUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void creatWord1(Map<String, Object> map, File file, String targetPath, String fileName, File dir) {
|
||||
// String curDate = DateUtils.dateConvertStr(new Date(), "yyyy年MM月dd日");
|
||||
try {
|
||||
//Configuration 用于读取ftl文件
|
||||
Configuration configuration = new Configuration(new Version("2.3.0"));
|
||||
configuration.setDefaultEncoding("utf-8");
|
||||
//指定路径的第二种方式
|
||||
configuration.setDirectoryForTemplateLoading(dir);
|
||||
//输出文档路径及名称
|
||||
File targetFile = new File(targetPath);
|
||||
if (!targetFile.exists()) {
|
||||
targetFile.mkdirs();
|
||||
}
|
||||
targetPath = targetPath + fileName;
|
||||
File outFile = new File(targetPath);
|
||||
//以utf-8的编码读取ftl文件
|
||||
Template template = configuration.getTemplate(file.getName(), "utf-8");
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "utf-8"), 10240);
|
||||
template.process(map, out);
|
||||
file.delete();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void inputStreamToFile(InputStream ins, File file) {
|
||||
OutputStream os = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user