• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

哆啦C梦

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

java 导出excel4

 1 /**
 2  * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 3  */
 4 package com.newtouch.common.utils.excel.fieldtype;
 5 
 6 import java.util.List;
 7 
 8 import com.google.common.collect.Lists;
 9 import com.newtouch.common.utils.Collections3;
10 import com.newtouch.common.utils.SpringContextHolder;
11 import com.newtouch.common.utils.StringUtils;
12 import com.newtouch.modules.sys.entity.Role;
13 import com.newtouch.modules.sys.service.SystemService;
14 
15 /**
16  * 字段类型转换
17  * @author ThinkGem
18  * @version 2013-5-29
19  */
20 public class RoleListType {
21 
22     private static SystemService systemService = SpringContextHolder.getBean(SystemService.class);
23     
24     /**
25      * 获取对象值(导入)
26      */
27     public static Object getValue(String val) {
28         List<Role> roleList = Lists.newArrayList();
29         List<Role> allRoleList = systemService.findAllRole();
30         for (String s : StringUtils.split(val, ",")){
31             for (Role e : allRoleList){
32                 if (StringUtils.trimToEmpty(s).equals(e.getName())){
33                     roleList.add(e);
34                 }
35             }
36         }
37         return roleList.size()>0?roleList:null;
38     }
39 
40     /**
41      * 设置对象值(导出)
42      */
43     public static String setValue(Object val) {
44         if (val != null){
45             @SuppressWarnings("unchecked")
46             List<Role> roleList = (List<Role>)val;
47             return Collections3.extractToString(roleList, "name", ", ");
48         }
49         return "";
50     }
51     
52 }

 

posted on 2015-08-10 11:29  哆啦C梦  阅读(108)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3