一、接口
@RequestMapping("/export")
public void exportPdf(@RequestParam String tId, HttpServletResponse response) throws Exception {
System.out.println("==================开始导出======================");
ByteArrayOutputStream baos = null;
OutputStream out = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
try {
// 模板中的数据,实际运用从数据库中查询
Map<String, Object> data = new HashMap<>();
//查询人才信息 并且添加到集合中
List<RlTalentEntity> talentEntityList = rlTalentService.list(new QueryWrapper<RlTalentEntity>().eq("t_id", tId));
List<Map<String, String>> mapListTalent = new ArrayList<>();
Map<String, String> mapTalent;
for (RlTalentEntity dict : talentEntityList) {
String gender = dict.getGender();
if (gender.equals("44")) {
gender = "男";
} else if (gender.equals("45")) {
gender = "女";
} else {
gender = "保密";
}
// 转换日期格式
String bornDate = sdf.format(dict.getBornDate());
mapTalent = new HashMap<>();
mapTalent.put("name", dict.getName());
mapTalent.put("Contact", dict.getContact());
mapTalent.put("EmailAddress", dict.getEmailAddress());
mapTalent.put("Gender", gender);
mapTalent.put("BornDate", bornDate);
mapTalent.put("WorkExperience", dict.getWorkExperience());
mapTalent.put("ExpectedPosition", dict.getExpectedPosition());
mapTalent.put("ExpectedSalary", dict.getEx

本文介绍了一个使用Vue.js和Java结合模板文件实现批量和单个导出PDF的方法。内容涉及后端接口设计和PDF工具类的使用,其中模板文件代码和Vue前端代码也进行了说明。
最低0.47元/天 解锁文章
1519

被折叠的 条评论
为什么被折叠?



