Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

Creates a format string for displaying currency values, and allows locale-specific currency symbols.

Signature
C#
C#
 public System.String CreateCurrency(int numDecimalPlaces, boolean useNegativeSign, boolean useParensForNegatives, Color negativeColor, System.String currencySymbol, System.String localeCode, boolean currencyAtFront, boolean spaceBetween)
{signature}{signature:
}
Signature
vb.net
vb.net
Public Function CreateCurrency(ByVal numDecimalPlaces As Integer, ByVal useNegativeSign As Boolean, ByVal useParensForNegatives As Boolean, ByVal negativeColor As Color, ByVal currencySymbol As String, ByVal localeCode As String, _
		ByVal currencyAtFront As Boolean, ByVal spaceBetween As Boolean) As String
{signature}
{parameters}
{param:numDecimalPlaces}The number of decimal places to display.{param}
{param:useNegativeSign}If {{true}}, the negative sign will be used for negative values.{param}
{param:useParensForNegatives}If {{true}}, negative numbers will be shown in parentheses.{param}
{param:negativeColor}A color to use when displaying negative numbers.  {{negativeColor}} may be null.{param}
{param:currencySymbol}A string representing the currency symbol.  This could be the individual Unicode character for the currency symbol \(such as the dollar, pound, euro, etc\) or the alphabetic representation of the currency symbol \(such as USD, GBP, EUR, etc\).  If this value is null, no currency string or formatting will be inserted.{param}
{param:localeCode}A string representing the Windows locale code, used for determining display on localized versions of Excel.  This is optional, and can be null.{param}
{param:currencyAtFront}If the currencySymbol is non\-null, this param determines if the currency string will appear before the number or after.  If true, the symbol will appear before the value.  If currencySymbol is null, this value is ignored.{param}
{param:spaceBetween}If the currencySymbol is non\-null, and this param is true, a space will appear between the currency symbol and the value.  If currencySymbol is null, this value is ignored.{param}
{returns}A currency format string.{returns}
{example}{code:csharp|title=C#}
Parameters
Param
numDecimalPlaces
numDecimalPlaces

The number of decimal places to display.

Param
useNegativeSign
useNegativeSign

If true, the negative sign will be used for negative values.

Param
useParensForNegatives
useParensForNegatives

If true, negative numbers will be shown in parentheses.

Param
negativeColor
negativeColor

A color to use when displaying negative numbers. negativeColor may be null.

Param
currencySymbol
currencySymbol

A string representing the currency symbol. This could be the individual Unicode character for the currency symbol (such as the dollar, pound, euro, etc) or the alphabetic representation of the currency symbol (such as USD, GBP, EUR, etc). If this value is null, no currency string or formatting will be inserted.

Param
localeCode
localeCode

A string representing the Windows locale code, used for determining display on localized versions of Excel. This is optional, and can be null.

Param
currencyAtFront
currencyAtFront

If the currencySymbol is non-null, this param determines if the currency string will appear before the number or after. If true, the symbol will appear before the value. If currencySymbol is null, this value is ignored.

Param
spaceBetween
spaceBetween

If the currencySymbol is non-null, and this param is true, a space will appear between the currency symbol and the value. If currencySymbol is null, this value is ignored.

Returns

A currency format string.

Example
Code Block
csharp
csharp
titleC#


          //--- Create a style.
          Style styl = wb.CreateStyle();

          //--- The following assigns the currency string "[$€-2] #,##0.00;[Red][$€-2] #,##0.00"
          //--- to the style, which will use the Euro symbol prior to the values, with the
          //--- color red for negative values.
          styl.NumberFormat = wb.NumberFormat.CreateCurrency(2,
               false,
               false,
               NumberFormat.Color.Red,
               "€",
               "2",
               true,
               true);
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          '--- Create a style.
          Dim styl As Style = wb.CreateStyle()

          '--- The following assigns the currency string "[$€-2] #,##0.00;[Red][$€-2] #,##0.00"
          '--- to the style, which will use the Euro symbol prior to the values, with the
          '--- color red for negative values.
          styl.NumberFormat = wb.NumberFormat.CreateCurrency(2, _
               False, _
               False, _
               NumberFormat.Color.Red, _
               "€", _
               "2", _
               True, _
               True)
        
{code} {example}