Hi,
I’m currently facing a problem in which I have a generated field on a table (‘lastUsage’) to which I added the printable, so it can be exported with the excel on command. For the app it is working ok, the format appears as desired, however on the excel, the value shows as the Timestamp for the date, but without the proper format.
Here is the code with which we add the generated column (which is called on init for the screen with the table) and a screenshot of the excel.
private void addLastUsageColumn() {
hplcColumnsTable.addGeneratedColumn("lastUsage", hplcColumn -> {
Date lastUsage = hplcColumnService.getLastUsageDate(hplcColumn);
DateFormat dateFormat = new SimpleDateFormat(messageBundle.getMessage("batchDateFormat"));
return new Table.PlainTextCell(lastUsage != null ? dateFormat.format(lastUsage) : "");
});
hplcColumnsTable.addPrintable("lastUsage", new Table.Printable<HplcColumn, Date>() {
@Override
public Date getValue(HplcColumn item) {
return hplcColumnService.getLastUsageDate(item);
}
});
hplcColumnsTable.getColumn("lastUsage").setCaption(messageBundle.getMessage("lastUsage"));
}
(‘último uso’ == ‘last usage’ in spanish)
And a screenshot from the app
hplcColumnService.getLastUsageDate(item)
returns the desired date, the value cannot be obtained by any other attribute of the HplcColumn entity.
Converting the printable to LocalDate does not fix the problem, as we need this specific format for the column (dd-MM-yyyy).
What could be the problem?
Thanks beforehand,
Regards,
T.