org.jeecgframework.poi.excel.entity.ExportParams Java Examples

The following examples show how to use org.jeecgframework.poi.excel.entity.ExportParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysUserAgentController.java    From jeecg-cloud with Apache License 2.0 8 votes vote down vote up
/**
    * 导出excel
 *
 * @param sysUserAgent
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
    mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 ExportParams exportParams = new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息");
 exportParams.setImageBasePath(upLoadPath);
    mv.addObject(NormalExcelConstants.PARAMS, exportParams);
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #2
Source File: ExcelExportServer.java    From autopoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建 表头改变
 * 
 * @param entity
 * @param sheet
 * @param workbook
 * @param feildWidth
 */
public int createHeaderRow(ExportParams entity, Sheet sheet, Workbook workbook, int feildWidth) {
	Row row = sheet.createRow(0);
	row.setHeight(entity.getTitleHeight());
	createStringCell(row, 0, entity.getTitle(), getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
	for (int i = 1; i <= feildWidth; i++) {
		createStringCell(row, i, "", getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
	}
	sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, feildWidth));
	if (entity.getSecondTitle() != null) {
		row = sheet.createRow(1);
		row.setHeight(entity.getSecondTitleHeight());
		CellStyle style = workbook.createCellStyle();
		style.setAlignment(CellStyle.ALIGN_RIGHT);
		createStringCell(row, 0, entity.getSecondTitle(), style, null);
		for (int i = 1; i <= feildWidth; i++) {
			createStringCell(row, i, "", getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
		}
		sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, feildWidth));
		return 2;
	}
	return 1;
}
 
Example #3
Source File: SysPositionController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
    // Step.1 组装查询条件
    QueryWrapper<SysPosition> queryWrapper = null;
    try {
        String paramsStr = request.getParameter("paramsStr");
        if (oConvertUtils.isNotEmpty(paramsStr)) {
            String deString = URLDecoder.decode(paramsStr, "UTF-8");
            SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
            queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysPosition> pageList = sysPositionService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
    mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:Jeecg", "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #4
Source File: SysUserAgentController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
    * 导出excel
 *
 * @param sysUserAgent
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
    mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 ExportParams exportParams = new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息");
 exportParams.setImageBasePath(upLoadPath);
    mv.addObject(NormalExcelConstants.PARAMS, exportParams);
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #5
Source File: JoaDemoController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
    * 导出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;
}
 
Example #6
Source File: SysPositionController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
    // Step.1 组装查询条件
    QueryWrapper<SysPosition> queryWrapper = null;
    try {
        String paramsStr = request.getParameter("paramsStr");
        if (oConvertUtils.isNotEmpty(paramsStr)) {
            String deString = URLDecoder.decode(paramsStr, "UTF-8");
            SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
            queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysPosition> pageList = sysPositionService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
    mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:Jeecg", "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #7
Source File: SysCategoryController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
    * 导出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;
}
 
Example #8
Source File: JformGraphreportHeadController.java    From jeecg with Apache License 2.0 6 votes vote down vote up
@RequestMapping(params = "exportXls")
public String  exportXls(JformGraphreportHeadEntity jformGraphreportHead,HttpServletRequest request,HttpServletResponse response
		, DataGrid dataGrid,ModelMap map) {
	CriteriaQuery cq = new CriteriaQuery(JformGraphreportHeadEntity.class, dataGrid);
	//查询条件组装器
	org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, jformGraphreportHead);

	List<JformGraphreportHeadEntity> dataList= this.jformGraphreportHeadService.getListByCriteriaQuery(cq,false);
	List<JformGraphreportHeadPage> pageList=new ArrayList<JformGraphreportHeadPage>();
	if(dataList!=null&&dataList.size()>0){
		String hql0 = "from JformGraphreportItemEntity where 1 = 1 AND cGREPORT_HEAD_ID = ? ";
		for(JformGraphreportHeadEntity headEntity:dataList){
			List<JformGraphreportItemEntity> itemEntities = systemService.findHql(hql0,headEntity.getId());
			pageList.add(new JformGraphreportHeadPage(itemEntities,headEntity));
		}
	}

	map.put(NormalExcelConstants.FILE_NAME,"图表配置");
	map.put(NormalExcelConstants.CLASS,JformGraphreportHeadPage.class);
	map.put(NormalExcelConstants.PARAMS,new ExportParams("图表配置","导出信息"));
	map.put(NormalExcelConstants.DATA_LIST, pageList);
	return NormalExcelConstants.JEECG_EXCEL_VIEW;
}
 
Example #9
Source File: SysAnnouncementController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysAnnouncement sysAnnouncement,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysAnnouncement> queryWrapper = QueryGenerator.initQueryWrapper(sysAnnouncement, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
    mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #10
Source File: SysRoleController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
	// Step.1 组装查询条件
	QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
	//Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<SysRole> pageList = sysRoleService.list(queryWrapper);
	//导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表");
	mv.addObject(NormalExcelConstants.CLASS,SysRole.class);
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息"));
	mv.addObject(NormalExcelConstants.DATA_LIST,pageList);
	return mv;
}
 
Example #11
Source File: SysDepartController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
  * 导出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;
 }
 
Example #12
Source File: SysDepartController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
  * 导出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;
 }
 
Example #13
Source File: JoaDemoController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
    * 导出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;
}
 
Example #14
Source File: SysDepartController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
  * 导出excel
  *
  * @param request
  * @param response
  */
 @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;
 }
 
Example #15
Source File: SysAnnouncementController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysAnnouncement sysAnnouncement,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysAnnouncement> queryWrapper = QueryGenerator.initQueryWrapper(sysAnnouncement, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
    mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #16
Source File: SysUserController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @RequestMapping(value = "/exportXls")
  public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
      // Step.1 组装查询条件
      QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap());
      //Step.2 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      //update-begin--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
      String selections = request.getParameter("selections");
     if(!oConvertUtils.isEmpty(selections)){
         queryWrapper.in("id",selections.split(","));
     }
      //update-end--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
      List<SysUser> pageList = sysUserService.list(queryWrapper);

      //导出文件名称
      mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
      mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"));
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
  }
 
Example #17
Source File: SysRoleController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 导出excel
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
	// Step.1 组装查询条件
	QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
	//Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<SysRole> pageList = sysRoleService.list(queryWrapper);
	//导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表");
	mv.addObject(NormalExcelConstants.CLASS,SysRole.class);
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息"));
	mv.addObject(NormalExcelConstants.DATA_LIST,pageList);
	return mv;
}
 
Example #18
Source File: SysPositionController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
    // Step.1 组装查询条件
    QueryWrapper<SysPosition> queryWrapper = null;
    try {
        String paramsStr = request.getParameter("paramsStr");
        if (oConvertUtils.isNotEmpty(paramsStr)) {
            String deString = URLDecoder.decode(paramsStr, "UTF-8");
            SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
            queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysPosition> pageList = sysPositionService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
    mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:Jeecg", "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #19
Source File: SysUserAgentController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
    * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
    mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #20
Source File: JeecgMapExcelView.java    From easypoi with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
                                       HttpServletResponse response) throws Exception {
    String codedFileName = "临时文件";
    Workbook workbook = ExcelExportUtil.exportExcel(
        (ExportParams) model.get(MapExcelConstants.PARAMS),
        (List<ExcelExportEntity>) model.get(MapExcelConstants.ENTITY_LIST),
        (Collection<? extends Map<?, ?>>) model.get(MapExcelConstants.MAP_LIST));
    if (model.containsKey(MapExcelConstants.FILE_NAME)) {
        codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
    }
    if (workbook instanceof HSSFWorkbook) {
        codedFileName += HSSF;
    } else {
        codedFileName += XSSF;
    }
    if (isIE(request)) {
        codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
    } else {
        codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
    }
    response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
    ServletOutputStream out = response.getOutputStream();
    workbook.write(out);
    out.flush();
}
 
Example #21
Source File: ExcelExportServer.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建 表头改变
 * 
 * @param entity
 * @param sheet
 * @param workbook
 * @param feildWidth
 */
public int createHeaderRow(ExportParams entity, Sheet sheet, Workbook workbook, int feildWidth) {
	Row row = sheet.createRow(0);
	row.setHeight(entity.getTitleHeight());
	createStringCell(row, 0, entity.getTitle(), getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
	for (int i = 1; i <= feildWidth; i++) {
		createStringCell(row, i, "", getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
	}
	sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, feildWidth));
	if (entity.getSecondTitle() != null) {
		row = sheet.createRow(1);
		row.setHeight(entity.getSecondTitleHeight());
		CellStyle style = workbook.createCellStyle();
		style.setAlignment(CellStyle.ALIGN_RIGHT);
		createStringCell(row, 0, entity.getSecondTitle(), style, null);
		for (int i = 1; i <= feildWidth; i++) {
			createStringCell(row, i, "", getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
		}
		sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, feildWidth));
		return 2;
	}
	return 1;
}
 
Example #22
Source File: ExcelExportServer.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建 表头改变
 * 
 * @param entity
 * @param sheet
 * @param workbook
 * @param feildWidth
 */
public int createHeaderRow(ExportParams entity, Sheet sheet, Workbook workbook, int feildWidth) {
    Row row = sheet.createRow(0);
    row.setHeight(entity.getTitleHeight());
    createStringCell(row, 0, entity.getTitle(),
        getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
    for (int i = 1; i <= feildWidth; i++) {
        createStringCell(row, i, "",
            getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
    }
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, feildWidth));
    if (entity.getSecondTitle() != null) {
        row = sheet.createRow(1);
        row.setHeight(entity.getSecondTitleHeight());
        CellStyle style = workbook.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        createStringCell(row, 0, entity.getSecondTitle(), style, null);
        for (int i = 1; i <= feildWidth; i++) {
            createStringCell(row, i, "",
                getExcelExportStyler().getHeaderStyle(entity.getHeaderColor()), null);
        }
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, feildWidth));
        return 2;
    }
    return 1;
}
 
Example #23
Source File: JeecgMapExcelView.java    From autopoi with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
	String codedFileName = "临时文件";
	Workbook workbook = ExcelExportUtil.exportExcel((ExportParams) model.get(MapExcelConstants.PARAMS), (List<ExcelExportEntity>) model.get(MapExcelConstants.ENTITY_LIST), (Collection<? extends Map<?, ?>>) model.get(MapExcelConstants.MAP_LIST));
	if (model.containsKey(MapExcelConstants.FILE_NAME)) {
		codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
	}
	if (workbook instanceof HSSFWorkbook) {
		codedFileName += HSSF;
	} else {
		codedFileName += XSSF;
	}
	if (isIE(request)) {
		codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
	} else {
		codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
	}
	response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
	ServletOutputStream out = response.getOutputStream();
	workbook.write(out);
	out.flush();
}
 
Example #24
Source File: JeecgMapExcelView.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
	String codedFileName = "临时文件";
	Workbook workbook = ExcelExportUtil.exportExcel((ExportParams) model.get(MapExcelConstants.PARAMS), (List<ExcelExportEntity>) model.get(MapExcelConstants.ENTITY_LIST), (Collection<? extends Map<?, ?>>) model.get(MapExcelConstants.MAP_LIST));
	if (model.containsKey(MapExcelConstants.FILE_NAME)) {
		codedFileName = (String) model.get(MapExcelConstants.FILE_NAME);
	}
	if (workbook instanceof HSSFWorkbook) {
		codedFileName += HSSF;
	} else {
		codedFileName += XSSF;
	}
	if (isIE(request)) {
		codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
	} else {
		codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
	}
	response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
	ServletOutputStream out = response.getOutputStream();
	workbook.write(out);
	out.flush();
}
 
Example #25
Source File: SysDepartController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
  * 导出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;
 }
 
Example #26
Source File: SysRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 * @param request
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
	// Step.1 组装查询条件
	QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
	//Step.2 AutoPoi 导出Excel
	ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
	List<SysRole> pageList = sysRoleService.list(queryWrapper);
	//导出文件名称
	mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表");
	mv.addObject(NormalExcelConstants.CLASS,SysRole.class);
	LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
	mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息"));
	mv.addObject(NormalExcelConstants.DATA_LIST,pageList);
	return mv;
}
 
Example #27
Source File: SysUserController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @RequestMapping(value = "/exportXls")
  public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
      // Step.1 组装查询条件
      QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap());
      //Step.2 AutoPoi 导出Excel
      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
      //update-begin--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据--------------------
      String selections = request.getParameter("selections");
     if(!oConvertUtils.isEmpty(selections)){
         queryWrapper.in("id",selections.split(","));
     }
      //update-end--Author:kangxiaolin  Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据----------------------
      List<SysUser> pageList = sysUserService.list(queryWrapper);

      //导出文件名称
      mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
      mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"));
      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
      return mv;
  }
 
Example #28
Source File: SysCategoryController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
    * 导出excel
 *
 * @param request
 * @param response
 */
@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;
}
 
Example #29
Source File: SysPositionController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
    // Step.1 组装查询条件
    QueryWrapper<SysPosition> queryWrapper = null;
    try {
        String paramsStr = request.getParameter("paramsStr");
        if (oConvertUtils.isNotEmpty(paramsStr)) {
            String deString = URLDecoder.decode(paramsStr, "UTF-8");
            SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
            queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysPosition> pageList = sysPositionService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表");
    mv.addObject(NormalExcelConstants.CLASS, SysPosition.class);
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:Jeecg", "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}
 
Example #30
Source File: SysUserAgentController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
    * 导出excel
 *
 * @param request
 * @param response
 */
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) {
    // Step.1 组装查询条件
    QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap());
    //Step.2 AutoPoi 导出Excel
    ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
    List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper);
    //导出文件名称
    mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
    mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
    LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
    mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息"));
    mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
    return mv;
}