We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set custom currency formatting

Hi, I’n trying to set a custom currency formatting that corresponds to the following Excel setting. (currency.png)


This is what I have tried but it results in a corrupt file.

var currencyStyle = book.CreateStyle();
currencyStyle.Number = 8; //Or should it be 7?
currencyStyle.Custom = “#,##0 SEK”; //If I remove “SEK” the file is not corrupt
cell.SetStyle(currencyStyle, new StyleFlag { NumberFormat = true });

Hi,


Please try following custom format string on your side.

C#

var book = new Workbook();
var cell = book.Worksheets[0].Cells[“A1”];
cell.PutValue(500);
var currencyStyle = book.CreateStyle();

currencyStyle.Custom = “#,##0 [$SEK]”;


cell.SetStyle(currencyStyle, new StyleFlag { NumberFormat = true });
book.Save(“C:/temp/output.xlsx”);

Thanks Babar Raza, that worked great.

Hi again,


Thank you for the confirmation. Please feel free to contact us back in case you need our further assistance with Aspose APIs.