poi导出后台提示报错,Minimum column number is 0!
来源:互联网 发布:python字典iteritems 编辑:程序博客网 时间:2024/06/04 19:21
参考:
http://ask.csdn.net/questions/217353
解决方案:
实体类里没加注解。在需要打印出来的实体类的get方法加上注解@ExcelField
如一张用户表:
/** * Excel注解定义 * * @version 2013-03-10 */@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})@Retention(RetentionPolicy.RUNTIME)public @interface ExcelField { /** * 导出字段名(默认调用当前字段的“get”方法,如指定导出字段为对象,请填写“对象名.对象属性”,例:“area.name”、“office.name”) */ String value() default ""; /** * 导出字段标题(需要添加批注请用“**”分隔,标题**批注,仅对导出模板有效) */ String title(); /** * 字段类型(0:导出导入;1:仅导出;2:仅导入) */ int type() default 0; /** * 导出字段对齐方式(0:自动;1:靠左;2:居中;3:靠右) */ int align() default 0; /** * 导出字段字段排序(升序) */ int sort() default 0; /** * 如果是字典类型,请设置字典的type值 */ String dictType() default ""; /** * 反射类型 */ Class<?> fieldType() default Class.class; /** * 字段归属组(根据分组导出导入) */ int[] groups() default {};}
public class User{ private static final long serialVersionUID = 1L; private Office company; // 归属公司 private Office office; // 归属部门 private String loginName;// 登录名 private String password;// 密码 private String no; // 工号 private String name; // 姓名 private String email; // 邮箱 private String phone; // 电话 private String mobile; // 手机 private String userType;// 用户类型 private String loginIp; // 最后登陆IP private Date loginDate; // 最后登陆日期 private String loginFlag; // 是否允许登陆 private String photo; // 头像 private String oldLoginName;// 原登录名 private String newPassword; // 新密码 private String oldLoginIp; // 上次登陆IP private Date oldLoginDate; // 上次登陆日期 private Role role; // 根据角色查询用户条件 private List<Role> roleList = Lists.newArrayList(); // 拥有角色列表 public User() { super(); this.loginFlag = Global.YES; } public User(String id){ super(id); } public User(String id, String loginName){ super(id); this.loginName = loginName; } public User(Role role){ super(); this.role = role; } public String getPhoto() { return photo; } public void setPhoto(String photo) { this.photo = photo; } public String getLoginFlag() { return loginFlag; } public void setLoginFlag(String loginFlag) { this.loginFlag = loginFlag; } @SupCol(isUnique="true", isHide="true") @ExcelField(title="ID", type=1, align=2, sort=1) public String getId() { return id; } @JsonIgnore @NotNull(message="归属公司不能为空") @ExcelField(title="归属公司", align=2, sort=20) public Office getCompany() { return company; } public void setCompany(Office company) { this.company = company; } @JsonIgnore @NotNull(message="归属部门不能为空") @ExcelField(title="归属部门", align=2, sort=25) public Office getOffice() { return office; } public void setOffice(Office office) { this.office = office; } @Length(min=1, max=100, message="登录名长度必须介于 1 和 100 之间") @ExcelField(title="登录名", align=2, sort=30) public String getLoginName() { return loginName; } public void setLoginName(String loginName) { this.loginName = loginName; } @JsonIgnore @Length(min=1, max=100, message="密码长度必须介于 1 和 100 之间") public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Length(min=1, max=100, message="姓名长度必须介于 1 和 100 之间") @ExcelField(title="姓名", align=2, sort=40) public String getName() { return name; } @Length(min=1, max=100, message="工号长度必须介于 1 和 100 之间") @ExcelField(title="工号", align=2, sort=45) public String getNo() { return no; } public void setNo(String no) { this.no = no; } public void setName(String name) { this.name = name; } @Email(message="邮箱格式不正确") @Length(min=0, max=200, message="邮箱长度必须介于 1 和 200 之间") @ExcelField(title="邮箱", align=1, sort=50) public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Length(min=0, max=200, message="电话长度必须介于 1 和 200 之间") @ExcelField(title="电话", align=2, sort=60) public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } @Length(min=0, max=200, message="手机长度必须介于 1 和 200 之间") @ExcelField(title="手机", align=2, sort=70) public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } @ExcelField(title="备注", align=1, sort=900) public String getRemarks() { return remarks; } @Length(min=0, max=100, message="用户类型长度必须介于 1 和 100 之间") @ExcelField(title="用户类型", align=2, sort=80, dictType="sys_user_type") public String getUserType() { return userType; } public void setUserType(String userType) { this.userType = userType; } @ExcelField(title="创建时间", type=0, align=1, sort=90) public Date getCreateDate() { return createDate; } @ExcelField(title="最后登录IP", type=1, align=1, sort=100) public String getLoginIp() { return loginIp; } public void setLoginIp(String loginIp) { this.loginIp = loginIp; } @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ExcelField(title="最后登录日期", type=1, align=1, sort=110) public Date getLoginDate() { return loginDate; } public void setLoginDate(Date loginDate) { this.loginDate = loginDate; } public String getOldLoginName() { return oldLoginName; } public void setOldLoginName(String oldLoginName) { this.oldLoginName = oldLoginName; } public String getNewPassword() { return newPassword; } public void setNewPassword(String newPassword) { this.newPassword = newPassword; } public String getOldLoginIp() { if (oldLoginIp == null){ return loginIp; } return oldLoginIp; } public void setOldLoginIp(String oldLoginIp) { this.oldLoginIp = oldLoginIp; } @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") public Date getOldLoginDate() { if (oldLoginDate == null){ return loginDate; } return oldLoginDate; } public void setOldLoginDate(Date oldLoginDate) { this.oldLoginDate = oldLoginDate; } public Role getRole() { return role; } public void setRole(Role role) { this.role = role; } @JsonIgnore @ExcelField(title="拥有角色", align=1, sort=800, fieldType=RoleListType.class) public List<Role> getRoleList() { return roleList; } public void setRoleList(List<Role> roleList) { this.roleList = roleList; } @JsonIgnore public List<String> getRoleIdList() { List<String> roleIdList = Lists.newArrayList(); for (Role role : roleList) { roleIdList.add(role.getId()); } return roleIdList; } public void setRoleIdList(List<String> roleIdList) { roleList = Lists.newArrayList(); for (String roleId : roleIdList) { Role role = new Role(); role.setId(roleId); roleList.add(role); } } /** * 用户拥有的角色名称字符串, 多个角色名称用','分隔. */ public String getRoleNames() { return Collections3.extractToString(roleList, "name", ","); } public boolean isAdmin(){ return isAdmin(this.id); } public static boolean isAdmin(String id){ return id != null && "1".equals(id); } @Override public String toString() { return id; }}
阅读全文
0 0
- poi导出后台提示报错,Minimum column number is 0!
- poi导出报错java.lang.IllegalArgumentException: Minimum column number is 0
- jeesite导出Excel Minimum column number is 0
- jeesite导出Excel Minimum column number is 0
- jeesite导出Excel Minimum column number is 0
- 导出报表时:java.lang.IllegalArgumentException: Minimum column number is 0
- Extjs4---后台导出excel poi
- java后台报错:Unknown column 'xxx' in 'field list'
- 执行mysql添加权限语法,报错提示:ERROR 1558 (HY000): Column count of mysql.user is wrong. Expected 42, found 39. C
- Android Studio报错之Error:(1, 0) Minimum supported Gradle version is 3.3. Current version is 2.10. Ple
- poi导出excel后台代码示例
- 报错 argument #3 is 'nil' 'number' expected
- 执行 smitty 报错 "1800-005 SMIT requires a minimum of 24 line by 80 column output display."
- Yii报错:SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in order clause is ambiguous
- What Column Number Is It in the EXCEL?
- ext treepanel报错,提示:b is null
- POI导出文件报错 java.lang.RuntimeException: java.io.IOException: 系统找不到指定的路径。
- poi导出excel报The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xl
- 查找
- Dubbo异步方法调用里的问题
- COJ1911-Card Game
- Java内部类的使用小结
- C++预科——C语言指针回顾(三) 指针的运算
- poi导出后台提示报错,Minimum column number is 0!
- Websocket个人初见解
- selenium unittest
- hihocoder第九十四周 数论三·约瑟夫问题
- 微服务之微服务架构的优势与不足(一)
- Ubuntu16.04+Anaconda环境下dlib库无法导入解决方法
- Oracle性能优化读书笔记(1)-SQL执行计划分析工具
- Js快速入门
- 讨论 PHP 中不同运算符的应用