Skip to content

导出excel实体反射,时间格式转换错误 #1573

Closed
@herosql

Description

@herosql
版本号:

autopoi:1.1.1

问题描述:

在实体映射中定义其他@ExcelEntity 实体,普通字段不受影响,时间字段会转换异常

截图&代码:

image

友情提示: 未按格式要求发帖,会直接删掉。

Activity

zhangdaiscott

zhangdaiscott commented on Aug 24, 2020

@zhangdaiscott
Member

请在细化下问题描述

zhangdaiscott

zhangdaiscott commented on Aug 31, 2020

@zhangdaiscott
Member

...
解决方案
autopoi版本 1.2 value为空值时提前 return

org.jeecgframework.poi.excel.export.base.ExportBase#getCellValue

public Object getCellValue(ExcelExportEntity entity, Object obj) throws Exception {
Object value;
if (obj instanceof Map) {
value = ((Map) obj).get(entity.getKey());
} else {
value = entity.getMethods() != null ? getFieldBySomeMethod(entity.getMethods(), obj) : entity.getMethod().invoke(obj, new Object[] {});
}

// +++
value = Optional.ofNullable(value).orElse("");
if (StringUtils.isEmpty(value.toString())) {
    return "";
}
// +++

}

added a commit that references this issue on Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zhangdaiscott@herosql

        Issue actions

          导出excel实体反射,时间格式转换错误 · Issue #1573 · jeecgboot/JeecgBoot