ExcelAction not returning all decimal places on columns

I have Latitude/Longitude columns that I have given the number format of ###.###### in the data model. They show up correctly in the table but when I use the ExcelAction to export the table to excel I only get 4 decimal places instead of the 6 that are needed.

Is there something I can do to quickly fix this? Thoughts?

Thank You.

Hi,

Please check the output documents. It should be the default Excel number format that prints only 4 decimal places. ExcelAction exports all data to XLS without additional formatting.

The output Excel documents only have four decimal places. If I format them in excel with six decimal numbers then decimals 5 and 6 are always zero.

I dug into the Cuba platform code and there is formatting happening at ExcelExporter.java line 699 for version 6.10.1 (str = datatype.format(n);). The datatype object here is BigDecimalDataType and it has a format pattern of 0.####. This is where I am losing my two decimal places. Is this a setting somewhere that I can set? Where is it getting this pattern? Thanks.

Thanks for investigating this.

Unfortunately, for now I do not know how to change this behavior only for Excel export, but you can change decimal places number for entity attribute if you create custom datatype extending BigDecimalDatatype and use it in @MetaProperty annotation: Datatype - CUBA Platform. Developer’s Manual

This approach still doesn’t work as the Excel Export only uses the default datatype for the JavaClass. It has nothing to do with the settings against the column. I was able to get this to work though by creating my own data type and extending the AppMainWindow and explicitly setting it as the default type.

<datatype id="BigDecimal6" class="com.haulmont.chile.core.datatypes.impl.BigDecimalDatatype"
default="true"
format="###.######" decimalSeparator="." groupingSeparator=""/>

Here is the code in the extended main window. Fortunately for me that the only decimal types that I need for the Excel Export is the lat long.

DatatypeRegistry registry = AppBeans.get(DatatypeRegistry.class);
Datatype dt = registry.get("BigDecimal6");
registry.register(dt, "BigDecimal6", true);
1 Like

Thank you for reporting this, it is definitely should be fixed.

I’ve filed the issue: ExcelAction does not use datatype from MetaProperty · Issue #1459 · cuba-platform/cuba · GitHub