feat(generateDocx): 优化 generateSpider4 方法
- 添加返回值,返回生成文档的 UUID- 修改目标文件路径为动态生成的临时文件
This commit is contained in:
parent
c9e660af13
commit
26348be0ad
@ -7,14 +7,17 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Ding
|
||||
*/
|
||||
public class generateDocx {
|
||||
void generateSpider4(List<Map<String, Object>> rawData) {
|
||||
public String generateSpider4(List<Map<String, Object>> rawData) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
String target = "storage/temp/" + uuid + ".docx";
|
||||
String resource = "src/main/resources/docxTemplate/model.docx";
|
||||
String target = "src/main/resources/docxTemplate/resultDocx.docx";
|
||||
String back = uuid + ".docx";
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
@ -24,6 +27,7 @@ public class generateDocx {
|
||||
|
||||
try (XWPFTemplate template = XWPFTemplate.compile(resource).render(data)) {
|
||||
template.writeToFile(target);
|
||||
return back;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user