export data to libreoffice from an application 64 bits build in delphi

Hello, I’m having trouble to export numbers to libreoffice via uno api.
When a build in delphi an application 32 bits its works fine, but 64 bits the numbers turns all to 0 in libreoffice.

The code:
list:= s1.getCellRangeByPosition(x,y,z,w);
list.NumberFormat:= 4;

Ex: 32bits = 3.456 / 64bits = 0

Does anything change in the API between 32 and 64 bits?

thanks in advance

NumberFormat property is of UNO type long (= 32-bit signed integer). This does not change, regardless of what language or architecture you use. However, the language and architecture may define what you are trying to pass there. Remember, that when you pass anything to UNO, it crosses a boundary of a bridge, where it likely converts to an any - meaning that the type that you pass will be kept, until it arrives on the UNO side, where it will be checked if it matches the API requirements.

If Delphi uses 32 bits for an integer literal in 32-bit architecture, and 64 bits for the same literal on 64-bit architecture, then you will be hit (by Delphi / your usage, not by UNO API “changes”). If so, then you will need to cast to 32-bit integer types when passing to UNO’s long.

Note also, that hardcoding number format numeric values is a bad practice. For a code to take the number format code dynamically, see e.g. How to create a Macro to insert the current date in the current language - #7 by mikekaganski

1 Like

Hello,

Thanks for the tips, in fact the problem was in how Delphi was treating the number.
When passing the number to the setvalue property and not in the numberformat propriety.
Not in this code: list.NumberFormat:= x(integer);
But in this code: Cell.setvalue(data.fields[i].Asfloat);

Findings:
in 32bit architecture everything works to export a float number.: field.assingle, asfloat, ascurrency, asvariant, asextended
in 64bit architecture: only works with field.ascurrency and field.asvariant. In other type castings, 0 always appears in libreoffice as a number formatted as required in numberformat: 0,00.

I chose asvariant, problem solved for now.

Thanks again for the explanation.