Flexcel Reporting with locale numbers are text

When I run a report:

lReport.AddTable('OSTO', lReportStockQuantities);
lReport.Run

It runs the report fine, but if some of the data are floating points, it adds the values as strings in the Resulting XLSX file.

I am assuming that it has something to do with locale.

TReportStockQuantity.SalesValue is for example a double and could have the value 3,5
Note, that in this country we use komma (',') as decimal separator, and I assume that this is the problem.
If I in excel manually enter 3,5 in a cell, it correctly treats this as a number. Displays it according to locale, and I can sum() it.

How can I tell Flexcel that this is supposed to be a number?

Thanks
Jens Fudge

Hi,

FlexCel by default uses whatever DataType the field in the database (TReportStockQuantity.SalesValue) has. If the field is a number, it will be entered as a number. If it is a string, even if it is a string like "1", it will be entered as a string.

This is normally what you want, as some data (like serial numbers) even if they only have numbers, are supposed to be treated as strings.

What datatype is TReportStockQuantity.SalesValue ? If it is a string, the simplest solution might be to change it to be a double. If the field is a double, FlexCel will enter it as a number.

If you can't change the datatype, then you can use:

IReport.TryToConvertStrings := true;

(see TFlexCelReport.TryToConvertStrings Property | FlexCel Studio for VCL and FireMonkey documentation )

Or, as shown in the page above, if the problem is only for SalesValue, and the rest of the database is ok, you can write in the cell:

<#evaluate(VALUE(<#OSTO.SalesValue>))>

This will make sure that the column SalesValue is converted to numbers (if possible), but the rest of columns behave normally.

Ps: FlexCel fully supports "," and "." as decimal separators (Personally, I also live in a country where , is the decimal separator). The problem here is that by default, if you pass a string, FlexCel won't try to convert it to a number by default. Excel will try to convert it, but because it has a different use case because you are typing numbers in a screen.

Thanks for the reply
Sorry for getting back so late, but now I'm finally on this project again.
It does seem I had made an error. I have by accident converted the values to strings in the object that I am passing in with AddTable.
Changing the values to double made it work

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.