zzw
2023-12-01 e023474fc9bcc726ed558a0623f1316dddc13152
core/src/main/java/com/zt/life/export/service/WordFileService.java
@@ -8,6 +8,7 @@
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
import com.zt.life.export.dto.WordFile;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -19,16 +20,19 @@
@Service
public class WordFileService {
    @Value("${zt.oss.local-path}")
    private String localPath;
    public void exportWordFile(HttpServletRequest request, Object dataObj, WordFile wordFile, HttpServletResponse response) throws UnsupportedEncodingException, FileNotFoundException {
        // 数据map集合
        Map<String, Object> wordData = new HashMap<>();
        //HackLoopTableRenderPolicy hackLoopTableRenderPolicy = new HackLoopTableRenderPolicy();
        Configure config = null;
        ConfigureBuilder builder = Configure.newBuilder();
        this.formatWordData(wordFile, wordData, builder);
        this.formatWordData(dataObj, wordData, builder);
        config = builder.build();
        File fl = new File(wordFile.getModulePath());
        File fl = new File(localPath+"/template/"+wordFile.getModulePath());
        FileInputStream fs = new FileInputStream(fl);
        XWPFTemplate template;
        if (config != null) {
@@ -51,7 +55,7 @@
                formatWordData(staticFieldValue, wordData, builder);
            } else {
                if (field.getType().getName().equals("java.util.List")) {
                    builder.bind(fieldName, new HackLoopTableRenderPolicy());
                   builder.bind(fieldName, new HackLoopTableRenderPolicy());
                } else if (staticFieldValue != null) {
                    String valStr = staticFieldValue.toString();
                    if (valStr.contains("签名图片:")) {