Excel注解新增 height/width/suffix/defaultValue

master
RuoYi 6 years ago committed by Limy
parent 95d4b99e2a
commit e2264d5a7d

@ -19,5 +19,5 @@ public @interface DataScope
/** /**
* *
*/ */
String tableAlias() default ""; public String tableAlias() default "";
} }

@ -17,30 +17,50 @@ public @interface Excel
/** /**
* Excel. * Excel.
*/ */
public abstract String name(); public String name();
/** /**
* , : yyyy-MM-dd * , : yyyy-MM-dd
*/ */
public abstract String dateFormat() default ""; public String dateFormat() default "";
/** /**
* (: 0=,1=,2=) * (: 0=,1=,2=)
*/ */
public abstract String readConverterExp() default ""; public String readConverterExp() default "";
/**
* excel
*/
public double height() default 14;
/**
* excel
*/
public double width() default 20;
/**
* ,% 90 90%
*/
public String suffix() default "";
/**
* ,
*/
public String defaultValue() default "";
/** /**
* *
*/ */
public abstract String prompt() default ""; public String prompt() default "";
/** /**
* . * .
*/ */
public abstract String[] combo() default {}; public String[] combo() default {};
/** /**
* ,:,. * ,:,.
*/ */
public abstract boolean isExport() default true; public boolean isExport() default true;
} }

@ -21,20 +21,20 @@ public @interface Log
/** /**
* *
*/ */
String title() default ""; public String title() default "";
/** /**
* *
*/ */
BusinessType businessType() default BusinessType.OTHER; public BusinessType businessType() default BusinessType.OTHER;
/** /**
* *
*/ */
OperatorType operatorType() default OperatorType.MANAGE; public OperatorType operatorType() default OperatorType.MANAGE;
/** /**
* *
*/ */
boolean isSaveRequestData() default true; public boolean isSaveRequestData() default true;
} }

@ -284,7 +284,8 @@ public class ExcelUtil<T>
cellStyle.setFont(font); cellStyle.setFont(font);
cellStyle.setFillForegroundColor(HSSFColorPredefined.LIGHT_YELLOW.getIndex()); cellStyle.setFillForegroundColor(HSSFColorPredefined.LIGHT_YELLOW.getIndex());
// 设置列宽 // 设置列宽
sheet.setColumnWidth(i, 3766); sheet.setColumnWidth(i, (int) ((attr.width() + 0.72) * 256));
row.setHeight((short) (attr.height() * 20));
} }
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellStyle.setWrapText(true); cellStyle.setWrapText(true);
@ -327,6 +328,8 @@ public class ExcelUtil<T>
Excel attr = field.getAnnotation(Excel.class); Excel attr = field.getAnnotation(Excel.class);
try try
{ {
// 设置行高
row.setHeight((short) (attr.height() * 20));
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列. // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
if (attr.isExport()) if (attr.isExport())
{ {
@ -354,7 +357,7 @@ public class ExcelUtil<T>
{ {
cell.setCellType(CellType.STRING); cell.setCellType(CellType.STRING);
// 如果数据存在就填入,不存在填入空格. // 如果数据存在就填入,不存在填入空格.
cell.setCellValue(field.get(vo) == null ? "" : String.valueOf(field.get(vo))); cell.setCellValue(StringUtils.isNull(field.get(vo)) ? attr.defaultValue() : field.get(vo) + attr.suffix());
} }
} }
} }

@ -48,7 +48,7 @@ public class SysLogininfor extends BaseEntity
private String msg; private String msg;
/** 访问时间 */ /** 访问时间 */
@Excel(name = "访问时间", dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "访问时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date loginTime; private Date loginTime;
public Long getInfoId() public Long getInfoId()

@ -68,7 +68,7 @@ public class SysOperLog extends BaseEntity
private String errorMsg; private String errorMsg;
/** 操作时间 */ /** 操作时间 */
@Excel(name = "操作时间", dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date operTime; private Date operTime;
public Long getOperId() public Long getOperId()

@ -67,7 +67,7 @@ public class SysUser extends BaseEntity
private String loginIp; private String loginIp;
/** 最后登陆时间 */ /** 最后登陆时间 */
@Excel(name = "最后登陆时间", dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date loginDate; private Date loginDate;
/** 部门对象 */ /** 部门对象 */

Loading…
Cancel
Save