Comma converted to period using "type into"


#1

I have an issue where i am reading a range of values from excel which is “1000,12”. However when the robot types the value into Microsoft Dynamics Nav it comes out as “1000.12”. I have tried to change the regional settings in windows, decimal settings etc. but still not working. Anyone had this problem before?


#2

Have you tried:
yourDecVar.ToString(CultureInfo.CreateSpecificCulture("pl-PL"))
(use your culture specifier of course). Works fine for me.


#3

I just tried: row(“Value”).toString(culture.CreateSpecificCulture(“no-NO”)), however i get an compiler error. Is the syntax wrong?


#4

Try with CultureInfo instead of culture. CreateSpecificCulture is a static method, it should work without having an instance and it would rule out incorrect/missing initialization.
Make sure you have System.Globalization namespace imported.
Post your exact error.


#5

Here is a screenshot of the error:


#6

That’s interesting…
What is the column type and stored value type?
If it would be decimal, as one would expect from having that value and original issue with incorrect decimal separator, this should work.
What does
row("Belop").GetType.ToString
and
row("Belop").GetTypeCode.ToString
show in console? By logic you should get Object or GenericValue from first, Decimal from second. But that would give correct overload with CultureInfo.


#7

The first one gives “System.Double”

However, i get an error with the GetTypeCode - “Option Strict On dissalows late binding” :confused:

Edit: GetTypeCode gives me “String”


#8

Got a repro.

It should work with:
Convert.ToDouble(row("Belop")).ToString(CultureInfo.CreateSpecificCulture("no-NO"))
Compiler check goes for a .ToString call on Object type, hence the overload confusion.


#9

Perfect! That worked :slight_smile:

Thanks so much for your help!