Simplexcel
Simplexcel copied to clipboard
Currency Support
I see no way in defining a cell as a currency cell. Would be nice if there was a way.
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 + "]";
}
https://github.com/mstum/Simplexcel/issues/43