Skip to content

Commit e20723f

Browse files
authored
Merge pull request #1843 from syncfusion-content/988545-DisplayCurrencySymbol
988545-Update Working with Cell or Range Formatting UG page
2 parents 7bc30fd + e218386 commit e20723f

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

Document-Processing/Excel/Excel-Library/NET/Working-with-Cell-or-Range-Formatting.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,52 @@ workbook.DetectDateTimeInValue = False
919919
{% endhighlight %}
920920
{% endtabs %}
921921

922+
N> To display the **$** symbol, apply a currency or accounting number format. Using a number format without any currency symbol does not show any currency symbol in the value.
923+
924+
{% tabs %}
925+
{% highlight c# tabtitle="C# [Cross-platform]" %}
926+
//Plain number format
927+
sheet.Range["A1"].Number = 100;
928+
sheet.Range["A1"].NumberFormat = "0.00"; //shows 100.00
929+
930+
//Currency format
931+
sheet.Range["A2"].Number = 1234.56;
932+
sheet.Range["A2"].NumberFormat = "$#,##0.00"; //shows $1,234.56
933+
934+
//Accounting format
935+
sheet.Range["A3"].Number = 234;
936+
sheet.Range["A3"].NumberFormat = "_($* #,##0.00_)"; //shows $ 234.00
937+
{% endhighlight %}
938+
939+
{% highlight c# tabtitle="C# [Windows-specific]" %}
940+
//Plain number format
941+
sheet.Range["A1"].Number = 100;
942+
sheet.Range["A1"].NumberFormat = "0.00"; //shows 100.00
943+
944+
//Currency format
945+
sheet.Range["A2"].Number = 1234.56;
946+
sheet.Range["A2"].NumberFormat = "$#,##0.00"; //shows $1,234.56
947+
948+
//Accounting format
949+
sheet.Range["A3"].Number = 234;
950+
sheet.Range["A3"].NumberFormat = "_($* #,##0.00_)"; //shows $ 234.00
951+
{% endhighlight %}
952+
953+
{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %}
954+
'Plain Number format
955+
sheet.Range("A1").Number = 100
956+
sheet.Range("A1").NumberFormat = "0.00" 'shows 100.00
957+
958+
'Currency format
959+
sheet.Range("A2").Number = 1234.56
960+
sheet.Range("A2").NumberFormat = "$#,##0.00" 'shows $1,234.56
961+
962+
'Accounting format
963+
sheet.Range("A3").Number = 234
964+
sheet.Range("A3").NumberFormat = "_($* #,##0.00_)" 'shows $ 234.00
965+
{% endhighlight %}
966+
{% endtabs %}
967+
922968
## Number Format Detection Behavior Based on System Culture
923969

924970
In Microsoft Excel, when a value is inserted, the system's culture settings determine whether the value is interpreted as a [Text](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IRange.html#Syncfusion_XlsIO_IRange_Text) or [Number](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IRange.html#Syncfusion_XlsIO_IRange_Number). If it is a valid number according to the current culture, Excel automatically detects and applies a corresponding number format.
@@ -2126,4 +2172,4 @@ A complete working example to apply rich text formatting in C# is present on [th
21262172

21272173
The output of the previous code is shown as follows:
21282174

2129-
![Excel document with rich-text formatting](Working-with-Cell-or-Range-Formatting_images/Working-with-Cell-or-Range-Formatting_img6.jpeg)
2175+
![Excel document with rich-text formatting](Working-with-Cell-or-Range-Formatting_images/Working-with-Cell-or-Range-Formatting_img6.jpeg)

0 commit comments

Comments
 (0)