public ModelAndView exportXls(HttpServletRequest request, MeetingEnter meetingEnter,String meetingId) {//导出相同会议下的报名名单
Map<String, String[]> parameterMap = request.getParameterMap();
Map<String, String[]> map = new HashMap<>();
List<MeetingEnter> meetingEnterList= meetingEnterService.selectByMeetingId(meetingId);
Iterator<Map.Entry<String, String[]>> iterator = map.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<String, String[]> next = iterator.next();
String key = next.getKey();
next.setValue(meetingEnterList.toArray(new String[]{}));
if (key!=null&&map.get(key)!=null){
parameterMap.put(key.toString(),map.get(key));
}
}
return super.exportXls(request,meetingEnter,MeetingEnter.class, "会议报名管理");
}
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title) {
// Step.1 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 获取导出数据
List<T> pageList = service.list(queryWrapper);
List<T> exportList = null;
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = pageList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
} else {
exportList = pageList;
}
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.CLASS, clazz);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title));
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
Java导出excel表
点赞
收藏