...
This commit is contained in:
@@ -3,6 +3,7 @@ package com.njcn.harmonic.utils;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -20,12 +21,12 @@ public class WordUtil2 {
|
||||
public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response)
|
||||
throws Exception {
|
||||
path = ClearPathUtil.cleanString(path);
|
||||
File file = new File(path);
|
||||
// File file = new File(path);
|
||||
InputStream inStream = null;
|
||||
CustomXWPFDocument doc = null;
|
||||
//读取报告模板
|
||||
try {
|
||||
inStream = new FileInputStream(file);
|
||||
inStream = new ClassPathResource(path).getInputStream();;
|
||||
doc = new CustomXWPFDocument(inStream);
|
||||
this.replaceInTable(doc, params); // 替换表格里面的变量
|
||||
this.replaceInPara(doc, params); // 替换文本里面的变量
|
||||
|
||||
Reference in New Issue
Block a user