|
@@ -10,6 +10,7 @@ import org.apache.poi.xwpf.usermodel.XWPFTableCell;
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.apache.poi.util.Units;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -20,8 +21,8 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(EasStuProfileServiceImpl.class);
|
|
|
private static final String TEMPLATE_PATH = "temp/StuRegistTemp.docx";
|
|
|
- private static final String PHOTO_PATH = "temp/kun1.jpeg";
|
|
|
- private static final String OUTPUT_PATH = "D:\\myDesk\\test.docx";
|
|
|
+ private static final String PHOTO_PATH = "temp/kun.jpeg";
|
|
|
+ private static final String OUTPUT_PATH = "C:\\Users\\lc\\Desktop\\test.docx";
|
|
|
|
|
|
@Override
|
|
|
public JsonResult StuProfileDownload(EasArcTlsStudents easArcTlsStudents) {
|
|
@@ -41,6 +42,7 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
|
|
|
map.put("university", easArcTlsStudents.getUniversity());
|
|
|
|
|
|
InputStream photo = getClass().getClassLoader().getResourceAsStream(PHOTO_PATH);
|
|
|
+ System.out.println( photo );
|
|
|
map.put("avatar", photo);
|
|
|
|
|
|
replacePlaceholders(doc, map);
|
|
@@ -76,12 +78,9 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
|
|
|
cell.removeParagraph(0);
|
|
|
if (value instanceof InputStream) {
|
|
|
//如果是放置图片的单元格,在这里添加一个计算图片合适大小的方法,按比例
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 计算合适的宽度和高度
|
|
|
- cell.addParagraph().createRun().addPicture((InputStream) value, XWPFDocument.PICTURE_TYPE_JPEG, "avatar.jpg", 400000, 400000);
|
|
|
+ cell.addParagraph().createRun().addPicture((InputStream) value,
|
|
|
+ XWPFDocument.PICTURE_TYPE_JPEG, "avatar.jpg",
|
|
|
+ Units.pixelToEMU(110), Units.pixelToEMU(140));
|
|
|
} else {
|
|
|
cell.setText(cellText.replace(placeholder, value.toString()));
|
|
|
}
|