Can this value be converted to Decimal?

We have a multilingual application. One is Polish and we want to export data to excel. We get this error

System.ArgumentException: Input string was not in a correct format.Couldn't store <4 488,67> in 2 Column. Expected type is Decimal. ---> System.FormatException: Input string was not in a correct format

I tried this
var test = Convert.ToDecimal("4 488,67");

Open in new window


But still get an error....same one.

Anyway to convert a value like that to Decimal?
LVL 8
CamilliaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
Hi Camillia,

Get rid of the space and comma and try.

Regards,
Chinmay.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
what's the value represented by "4 488,67" ?? you're using comma "," not really a decimal point there.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CamilliaAuthor Commented:
I think the comma is decimal point in Polish. I'll ask my manager.
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Chinmay PatelChief Technical NinjaCommented:
Hi Camillia,

You are right. i just did a quick check and the comma is infact a decimal point.

Try this code:

  string culture = "pl-PL"; // Culture Code for Polish
            string value = "4 488,67"; 
            Console.WriteLine(Convert.ToDecimal("4 488,67", new CultureInfo(culture)));

Open in new window


Let me know if you need further help.

Regards,
Chinmay.
0
CamilliaAuthor Commented:
Thanks, let me see. I'll post back.
0
CamilliaAuthor Commented:
As always, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.