咱们清楚,jeecg 导出 excel 采用的是 easypoi,不知道是否遇到过这种状况:java
咱们以一个实体属性为例:app
@Excel(name="问题分类",dicCode="xx")
private java.lang.String mwoQuestionCategory;
Easypoi 在 @Excel 基础注解里提供了 exportConvert 属性:spa
@Excel(name="问题分类",width=15,dicCode="mwo_question_type",exportConvert=true)
private java.lang.String mwoQuestionCategory;
get...
set...
public java.lang.String convertgetMwoQuestionCategory()
{
return mwoQuestionCategory == null ? "" : mwoQuestionCategory;
}
该方法为新加入的,跟 get set 方法没交叉,书写规则为 convert + 实体 get方法名称。excel
如上方实例,mwoQuestionCategory,拼接获得的判空方法为:convert + getMwoQuestionCategory = convertgetMwoQuestionCategory()。code
有小伙伴提议,为什么不直接在实体 get 方法里作三目运算呢。其实那样作会入侵实体对象,改变本来不须要赋值为空串的空值,固然,若是你的实体仅仅是为了提供给导出 Excel 使用,那么答案也是能够的。orm