The export function is also simple. You only need to check the database to get the data collection you want to export, and then pass the object type corresponding to the collection. The front end only needs to access /exportXls to get an excel file.
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(FactoryOutPersonEntity fope) {
log.info("导出厂外人员信息");
//组建查询条件
QueryWrapper<FactoryOutPersonEntity> wrapper = new QueryWrapper<>();
if (!StringUtil.isEmpty(fope.getCertificateNum())) {
wrapper.eq("CERTIFICATE_NUM", fope.getCertificateNum());
}
if (!StringUtil.isEmpty(fope.getPersonName())) {
wrapper.eq("PERSON_NAME", fope.getPersonName());
}
if (!StringUtil.isEmpty(fope.getWorkProject())) {
wrapper.eq("WORK_PROJECT", fope.getWorkProject());
}
List<FactoryOutPersonEntity> factoryOutPersonEntities = factoryOutPersonService.getFactoryOutPersonEntities(wrapper);
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "厂外人员信息表");
//注解对象Class
mv.addObject(NormalExcelConstants.CLASS, FactoryOutPersonEntity.class);
//自定义导出字段
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams());
//导出数据列表
mv.addObject(NormalExcelConstants.DATA_LIST, factoryOutPersonEntities);
return mv;
}