Enum attribute in excel report doesn't show the corresponding caption

Hi Cuba Team,

In reports where there is an enum attribute the data shown is the ordinal value of the enumeration instead of the caption assigned to this value.

For example, next enumeration is defined:

public enum FacProvEstatEnum implements EnumClass<Integer> {

    Pendent(10),
    Debit_Note(40),
    Reclamada(20),
    Cobrada(30);

    private Integer id;

    FacProvEstatEnum(Integer value) {
        this.id = value;
    }

    public Integer getId() {
        return id;
    }

    @Nullable
    public static FacProvEstatEnum fromId(Integer id) {
        for (FacProvEstatEnum at : FacProvEstatEnum.values()) {
            if (at.getId().equals(id)) {
                return at;
            }
        }
        return null;
    }
}

Here it is the Excel template:

  • On the header section the first ${estat} is the value of the enum attribute choosen through parameters of the report.

image

The dataset is obtained with next JJPQL query:

select
e.numFactura as "numFactura",
e.dataFactura as "dataFactura",
proveidor.proNom as "proveidor.proNom",
e.estat as "estat",
e.importTotal as "importTotal",
e.percComissio as "percComissio",
e.importComissio as "importComissio",
e.importFob as "importFob",
e.venciment as "venciment",
e.dataCobrament as "dataCobrament",
e.dataReclamacio as "dataReclamacio"
from logis$FacturaProv e
left join e.proveidor proveidor 
where (e.estat = ${estat} and e.proveidor.id = ${proveidor1})

When the report is executed, first ask for parameters and the caption corresponding to the different enum attribute values are shown correctly:
image

The generated report doesn’t show the caption of the enum attribute values in the data section:
image

How should the caption of the enum attribute value be obtained on the data section?

Since you are using native SQL query you have to convert codes of the enumeration to caption string manually.

Hello @xlorentep,

Yuriy correctly said, you need to manually convert the data. You can use the groovy-script in “Value formats” for this.

Regards,
Nikita

Thanks, Yuriy and Nikita, for your comments to guide me finding the solution.