use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kms by mahonelau.
the class SysCategoryController method exportXls.
/**
* 导出excel
*
* @param request
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
// Step.1 组装查询条件查询数据
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
// Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isEmpty(selections)) {
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
} else {
List<String> selectionList = Arrays.asList(selections.split(","));
List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
}
// 导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:" + user.getRealname(), "导出信息"));
return mv;
}
use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kms by mahonelau.
the class SysDepartController method exportXls.
/**
* 导出excel
*
* @param request
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDepart sysDepart, HttpServletRequest request) {
// Step.1 组装查询条件
QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
// Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<SysDepart> pageList = sysDepartService.list(queryWrapper);
// 按字典排序
Collections.sort(pageList, new Comparator<SysDepart>() {
@Override
public int compare(SysDepart arg0, SysDepart arg1) {
return arg0.getOrgCode().compareTo(arg1.getOrgCode());
}
});
// 导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:" + user.getRealname(), "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project kms by mahonelau.
the class SysDictController method exportXls.
/**
* 导出excel
*
* @param request
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDict sysDict, HttpServletRequest request) {
// Step.1 组装查询条件
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
// Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<SysDictPage> pageList = new ArrayList<SysDictPage>();
List<SysDict> sysDictList = sysDictService.list(queryWrapper);
for (SysDict dictMain : sysDictList) {
SysDictPage vo = new SysDictPage();
BeanUtils.copyProperties(dictMain, vo);
// 查询机票
List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByMainId(dictMain.getId());
vo.setSysDictItemList(sysDictItemList);
pageList.add(vo);
}
// 导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "数据字典");
// 注解对象Class
mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
// 自定义表格参数
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:" + user.getRealname(), "数据字典"));
// 导出数据列表
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project jeecg-boot by jeecgboot.
the class JeecgOrderMainController method exportXls.
/**
* 导出excel
*
* @param request
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, JeecgOrderMain jeecgOrderMain) {
// Step.1 组装查询条件
QueryWrapper<JeecgOrderMain> queryWrapper = QueryGenerator.initQueryWrapper(jeecgOrderMain, request.getParameterMap());
// Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
// 获取当前用户
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<JeecgOrderMainPage> pageList = new ArrayList<JeecgOrderMainPage>();
List<JeecgOrderMain> jeecgOrderMainList = jeecgOrderMainService.list(queryWrapper);
for (JeecgOrderMain orderMain : jeecgOrderMainList) {
JeecgOrderMainPage vo = new JeecgOrderMainPage();
BeanUtils.copyProperties(orderMain, vo);
// 查询机票
List<JeecgOrderTicket> jeecgOrderTicketList = jeecgOrderTicketService.selectTicketsByMainId(orderMain.getId());
vo.setJeecgOrderTicketList(jeecgOrderTicketList);
// 查询客户
List<JeecgOrderCustomer> jeecgOrderCustomerList = jeecgOrderCustomerService.selectCustomersByMainId(orderMain.getId());
vo.setJeecgOrderCustomerList(jeecgOrderCustomerList);
pageList.add(vo);
}
// 导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "一对多订单示例");
// 注解对象Class
mv.addObject(NormalExcelConstants.CLASS, JeecgOrderMainPage.class);
// 自定义表格参数
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("自定义导出Excel内容标题", "导出人:" + sysUser.getRealname(), "自定义Sheet名字"));
// 导出数据列表
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
use of org.jeecgframework.poi.excel.view.JeecgEntityExcelView in project jeecg-boot by jeecgboot.
the class JoaDemoController method exportXls.
/**
* 导出excel
*
* @param request
* @param response
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
QueryWrapper<JoaDemo> queryWrapper = null;
try {
String paramsStr = request.getParameter("paramsStr");
if (oConvertUtils.isNotEmpty(paramsStr)) {
String deString = URLDecoder.decode(paramsStr, "UTF-8");
JoaDemo joaDemo = JSON.parseObject(deString, JoaDemo.class);
queryWrapper = QueryGenerator.initQueryWrapper(joaDemo, request.getParameterMap());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<JoaDemo> pageList = joaDemoService.list(queryWrapper);
// 导出文件名称
mv.addObject(NormalExcelConstants.FILE_NAME, "流程测试列表");
mv.addObject(NormalExcelConstants.CLASS, JoaDemo.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("流程测试列表数据", "导出人:Jeecg", "导出信息"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
Aggregations