ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
Date today = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String todayValue = sdf.format(today);
String fileName = todayValue + "生产报表";
List<IbatteryProductionReportExportVo> productionReportList = productionSiteService.getProductionReportExport(productionReportDto);
mv.addObject(NormalExcelConstants.FILE_NAME, fileName);
mv.addObject(NormalExcelConstants.CLASS, IbatteryProductionReportExportVo.class);
LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal();
ExportParams exportParams = new ExportParams(todayValue + "生产报表数据", "导出人:" + principal.getRealname(), "生产报表");
exportParams.setImageBasePath(upLoadPath);
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
if (CollectionUtils.isEmpty(productionReportList)) {
productionReportList = new ArrayList<>();
}
mv.addObject(NormalExcelConstants.DATA_LIST, productionReportList);
return mv;
步骤
- 查询所有的数据
- 在返回时实体上面加@excel注解