| | |
| | | import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.*; |
| | | import java.nio.file.Files; |
| | |
| | | lable.getAndIncrement(); |
| | | }); |
| | | }); |
| | | String url; |
| | | try { |
| | | ZipSecureFile.setMinInflateRatio(0.0001); |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/word1.docx"); |
| | | File file = File.createTempFile("temp", ".tmp"); |
| | | OutputStream outputStream = new FileOutputStream(file); |
| | | IOUtils.copy(inputStream, outputStream); |
| | | url = file.getAbsolutePath(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new ErrorException("找不到模板文件"); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | ZipSecureFile.setMinInflateRatio(0.0001); |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/word1.docx"); |
| | | |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("title", title); |
| | | put("tables", tables); |
| | |
| | | getWord1(insOrderUser.getTerm(), orderState, insSamples, tables2); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | } else { |
| | | //如果只有环境试验没有电路试验 |
| | | strings.remove("近场"); |
| | | strings.remove("远场"); |
| | |
| | | tables4.add(table4); |
| | | } |
| | | } |
| | | |
| | | String url; |
| | | try { |
| | | ZipSecureFile.setMinInflateRatio(0.0001); |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx"); |
| | | File file = File.createTempFile("temp", ".tmp"); |
| | | OutputStream outputStream = new FileOutputStream(file); |
| | | IOUtils.copy(inputStream, outputStream); |
| | | url = file.getAbsolutePath(); |
| | | } catch (FileNotFoundException e) { |
| | | throw new ErrorException("找不到模板文件"); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | ZipSecureFile.setMinInflateRatio(0.0001); |
| | | InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx"); |
| | | StringBuilder standardMethod2 = new StringBuilder(); |
| | | for (String s : standardMethod) { |
| | | standardMethod2.append(";\n").append(s); |
| | |
| | | title3 = "辐射方向图参数"; |
| | | } |
| | | String finalTitle = title3; |
| | | XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("order", insOrder); |
| | | put("report", insReport); |