Reputation: 11
While formatting data for excel in C#, I am using this line of code
myValue.Style.Numberformat.Format = "$#,##0.00"
It output this: $1,234.00
But I want to also display the currency code, like this: $1,234 USD
or $1,234 MXN
Is there an option for currency code in string format?
Upvotes: 0
Views: 397
Reputation: 8359
I'm not aware of the logic behind the Style
property (ie: what is the type of myValue
), but you can probably just put the currency code in the string format:
myValue.Style.Numberformat.Format = "$#,##0.00 USD";
Lookalike demo here.
Upvotes: 0
Reputation: 2346
Dropping the .00
part from your number format should eliminate the decimal portion:
myValue.Style.Numberformat.Format = "$#,##0"
As far as the units themselves (USD vs MXN) I think that's probably logic you'll need to maintain outside of the NumberFormat method call.
Upvotes: 0