Free Support Forum -

Apply currency format to a cell in Excel spreadsheet in .NET


I would like to have the currency format applied to cells in excel (eg: $123.44).
I am populating the excel template using smart markers and is then setting the styles (backgroung color, font etc) from another excel template file (called as formatExcel). The user is allowed to edit this formatExcel file, and the changes are reflected in the generated excel.

The code that is used to set the style is

sheet.Cells[i,j].Style = formatCell.Style;

I am setting the format of the cell (in formatExcel) to be of Currency.
But when I use the code given above, only the back ground color, font etc of the formatCell are applied to the sheet.Cells[i,j]. The CURRENCY type is getting applied.

What could be wrong in here?


Do you change the style in the format cell? Please try:


And please download and try v3.1.1 at

Actually I have a typo in my question.
I meant the CURRENCY type is NOT getting applied. (Forgot to put NOT in the question before)

Yes I change the style in the format cell and aplly it to the excel file created.
I tried the method that you have given, but it doesn’t work

My test code:

Excel excel1 = new Excel();
Excel excel2 = new Excel();
excel2.Worksheets[0].Cells[“a1”].Style = excel1.Worksheets[0].Cells[“a1”].Style;
excel2.Save(“result.xls”, SaveType.OpenInExcel, FileFormatType.Default, this.Response);

I am populating the values in to the excel sheet first and then applying the styles based on the values in each row. In the test code that you have given, the style is applied first and then the value. In your case it works, but mine doesn’t.

Again, what I want is to populate the data first and apply the styles depending on the value. Let me know how I can add the currency symbol in that case.


Hi David,

Set value first then set style also works.

Excel excel1 = new Excel();
Excel excel2 = new Excel();
excel2.Worksheets[0].Cells[“a1”].Style = excel1.Worksheets[0].Cells[“a1”].Style;

excel2.Save(“result.xls”, SaveType.OpenInExcel, FileFormatType.Default, this.Response);

or you can try:

excel2.Worksheets[0].Cells[“a1”].Style. Number = 7;

If it still doesn’t work, could you please post more of your sample code here? Thank you.


I found the problem with the currency display. It occurs because, the incomming data from the dataset is of string type, thus the currency formatting does not get applied.

Another question, is how can the column width be applied to the generated excel file from a designer template?


I am not clear about your question on column width.

When you import a designer template, column width are automatically imported. If you want to change the column width, please try Cells.SetColumnWidth method.

There is a strange behaviour.
Could you explain me why I have no ability to change format of cells using toolbars icons (i.e. selecting $ doesn't work to switch number to currency format) in exported document.
But :
I can change the style after copy-paste to another document (in that document)
I can change the style with cell format from menu
Is it Excels bug?
You can reproduce that behaviour on any number cells in the document in attachment.

This is really a strange problem. I will check this issue.

I’m still facing with an inability to change format of cells using toolbars icons in exported document

Could you plz clarify this issue?

Sorry for not replying ealier. Please try this attached fix.

Thanks a lot.
It works.

The same behaviour if we applay % format from toolbar icon.
Could you, please fix this bug?

Thank you

I will check and fix this issue. You will get the fix next week.

Please try this new fix.