Skip to content
This repository was archived by the owner on Aug 26, 2022. It is now read-only.

Currency Support #33

Closed
fmillerr opened this issue Mar 29, 2021 · 2 comments
Closed

Currency Support #33

fmillerr opened this issue Mar 29, 2021 · 2 comments

Comments

@fmillerr
Copy link

I see no way in defining a cell as a currency cell. Would be nice if there was a way.

@tipa
Copy link

tipa commented Mar 29, 2021

Probably the xlsx doesn't have a "currency" cell type, but you can do that by using a format. This is how I create mine to write currency values:

static string GetExcelFormat(string symbol, double value)
{
    var customCulture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
    customCulture.NumberFormat.CurrencySymbol = symbol;
    cFormat = value.ToString("C2", customCulture);
    var nFormat = value.ToString("N2");
    if (cFormat.Contains(nFormat) && cFormat.Contains(symbol))
    {
          return cFormat.Replace(nFormat, "#,##0.00").Replace(symbol, "[$" + symbol + "]");
    }
    return "#,##0.00 [$" + symbol + "]";
}

@mstum
Copy link
Owner

mstum commented Aug 25, 2022

#43

@mstum mstum closed this as not planned Won't fix, can't repro, duplicate, stale Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants