| | |
| | | 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; |
| | | |
| | | |
| | |
| | | |
| | | @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) { |