| | |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.*; |
| | | import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.math.BigInteger; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | String selectedPic = EssConfig.getReportTemplates()+"apifanSelected.png"; |
| | | String defaultPic =EssConfig.getReportTemplates()+"apifanDefalut.png"; |
| | | |
| | | //测试用的 |
| | | // String selectedPic = "C:\\测评系统\\home\\reportTemplates\\apifanSelected.png"; |
| | | // String defaultPic ="C:\\测评系统\\home\\reportTemplates\\apifanDefalut.png"; |
| | | |
| | | |
| | | // 遍历段落进行替换操作 |
| | | synchronized (paragraphs) { |
| | | for (XWPFParagraph paragraph : paragraphs) { |
| | |
| | | int width = Units.toEMU(20); // 图片宽度 |
| | | int height = Units.toEMU(20); // 图片高度 |
| | | run.addPicture(new FileInputStream(picturePath), pictureType, "image.png", width, height); |
| | | |
| | | // 添加空格或制表符,使文本居中对齐 |
| | | int numberOfSpaces = 3; |
| | | for (int i = 0; i < numberOfSpaces; i++) { |
| | | run.setText(" "); |
| | | } |
| | | // 设置字符间距为居中对齐 |
| | | paragraph.setVerticalAlignment(TextAlignment.CENTER); |
| | | run.setText("结果可信,可以直接解读(测试中未发现明显的“伪装好”倾向)"); |
| | | |
| | | } |
| | |
| | | int width = Units.toEMU(20); // 图片宽度 |
| | | int height = Units.toEMU(20); // 图片高度 |
| | | run.addPicture(new FileInputStream(picturePath), pictureType, "image.png", width, height); |
| | | // 添加空格或制表符,使文本居中对齐 |
| | | int numberOfSpaces = 3; |
| | | for (int i = 0; i < numberOfSpaces; i++) { |
| | | run.setText(" "); |
| | | } |
| | | // 设置字符间距为居中对齐 |
| | | paragraph.setVerticalAlignment(TextAlignment.CENTER); |
| | | run.setText("结果不可信(测试中有明显的“伪装好”倾向)"); |
| | | |
| | | } |
| | |
| | | int width = Units.toEMU(20); // 图片宽度 |
| | | int height = Units.toEMU(20); // 图片高度 |
| | | run.addPicture(new FileInputStream(picturePath), pictureType, "image.png", width, height); |
| | | // 添加空格或制表符,使文本居中对齐 |
| | | int numberOfSpaces = 3; |
| | | for (int i = 0; i < numberOfSpaces; i++) { |
| | | run.setText(" "); |
| | | } |
| | | // 设置字符间距为居中对齐 |
| | | paragraph.setVerticalAlignment(TextAlignment.CENTER); |
| | | run.setText("结果可能可信,解读时要谨慎(测试中有一定的“伪装好倾向”)"); |
| | | |
| | | } |