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?
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 Technology NinjaCommented:
Hi Camillia,

Get rid of the space and comma and try.

Ryan ChongSoftware Team LeadCommented:
what's the value represented by "4 488,67" ?? you're using comma "," not really a decimal point there.

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.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Chinmay PatelChief Technology 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.

CamilliaAuthor Commented:
Thanks, let me see. I'll post back.
CamilliaAuthor Commented:
As always, thanks.
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

From novice to tech pro — start learning today.