GemBox.Spreadsheet
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    NumberFormatBuilder Class

    Namespace:
    GemBox.Spreadsheet
    Assembly:
    GemBox.Spreadsheet.dll

    Utility class that can be used to create a number format for NumberFormat.

    • C#
    • VB.NET
    public static class NumberFormatBuilder
    Public Module NumberFormatBuilder
    Inheritance:
    System.Object
    NumberFormatBuilder

    Methods

    Accounting(Int32, Boolean, Boolean, String, Boolean)

    Creates an accounting number format.

    • C#
    • VB.NET
    public static string Accounting(int decimalPlaces, bool useThousandsSeparator = true, bool useParenthesesToDisplayNegativeValue = false, string currencySymbol = null, bool showCurrencySymbolToTheRightOfNumber = false)
    Public Shared Function Accounting(decimalPlaces As Integer, useThousandsSeparator As Boolean = True, useParenthesesToDisplayNegativeValue As Boolean = False, currencySymbol As String = Nothing, showCurrencySymbolToTheRightOfNumber As Boolean = False) As String
    Parameters
    decimalPlaces
    System.Int32

    Number of decimal places that should be displayed to the right of the decimal separator.

    useThousandsSeparator
    System.Boolean

    True if the thousands separator should be displayed, false otherwise. The default value is true.

    useParenthesesToDisplayNegativeValue
    System.Boolean

    True if negative value should be displayed using parentheses notation, false if minus sign (-) should be used. The default value is false.

    currencySymbol
    System.String

    The currency symbol. Null, if no currency symbol should be displayed. The default value is null.

    showCurrencySymbolToTheRightOfNumber
    System.Boolean

    True if the currency symbol should be displayed to the right of the number, false otherwise. The default value is false.

    Returns
    System.String

    The created number format.

    Currency(String, Int32, Boolean, Boolean, Boolean, Boolean)

    Creates a currency number format.

    • C#
    • VB.NET
    public static string Currency(string currencySymbol, int decimalPlaces, bool useThousandsSeparator = true, bool useParenthesesToDisplayNegativeValue = false, bool showCurrencySymbolToTheRightOfNumber = false, bool showSpaceBetweenCurrencySymbolAndNumber = true)
    Public Shared Function Currency(currencySymbol As String, decimalPlaces As Integer, useThousandsSeparator As Boolean = True, useParenthesesToDisplayNegativeValue As Boolean = False, showCurrencySymbolToTheRightOfNumber As Boolean = False, showSpaceBetweenCurrencySymbolAndNumber As Boolean = True) As String
    Parameters
    currencySymbol
    System.String

    The currency symbol.

    decimalPlaces
    System.Int32

    Number of decimal places that should be displayed to the right of the decimal separator.

    useThousandsSeparator
    System.Boolean

    True if the thousands separator should be displayed, false otherwise. The default value is true.

    useParenthesesToDisplayNegativeValue
    System.Boolean

    True if negative value should be displayed using parentheses notation, false if minus sign (-) should be used. The default value is false.

    showCurrencySymbolToTheRightOfNumber
    System.Boolean

    True if the currency symbol should be displayed to the right of the number, false otherwise. The default value is false.

    showSpaceBetweenCurrencySymbolAndNumber
    System.Boolean

    True if space should be displayed between the currency symbol and the number. The default value is true.

    Returns
    System.String

    The created number format.

    DateTimeIso8061(Int32)

    Creates date and time format according to the ISO 8061 standard.

    • C#
    • VB.NET
    public static string DateTimeIso8061(int decimalPlaces = 0)
    Public Shared Function DateTimeIso8061(decimalPlaces As Integer = 0) As String
    Parameters
    decimalPlaces
    System.Int32

    The number of decimal places that should be used to display a fraction of a second. The default value is 0.

    Returns
    System.String

    The created number format.

    FractionWithFittingDenominator(Int32, Boolean)

    Creates a fraction number format with the denominator value that best fits the fraction part of the number.

    • C#
    • VB.NET
    public static string FractionWithFittingDenominator(int maxDenominatorDigits, bool displayAsPureFraction = false)
    Public Shared Function FractionWithFittingDenominator(maxDenominatorDigits As Integer, displayAsPureFraction As Boolean = False) As String
    Parameters
    maxDenominatorDigits
    System.Int32

    The maximum number of digits used to display the denominator of the fraction.

    displayAsPureFraction
    System.Boolean

    True to display the number as a single fraction without the integral part, false otherwise. For example, the number 1.25 will be displayed as "5/4" if the parameter is true and as "1 1/4" if the parameter is false. The default value is false.

    Returns
    System.String

    The created number format.

    FractionWithPreciseDenominator(Int32, Boolean)

    Creates a fraction number format with the precise denominator value.

    • C#
    • VB.NET
    public static string FractionWithPreciseDenominator(int denominator, bool displayAsPureFraction = false)
    Public Shared Function FractionWithPreciseDenominator(denominator As Integer, displayAsPureFraction As Boolean = False) As String
    Parameters
    denominator
    System.Int32

    Denominator that will be used to display the fraction part of the number.

    displayAsPureFraction
    System.Boolean

    True to display the number as a single fraction without the integral part, false otherwise. For example, the number 1.25 will be displayed as "5/4" if the parameter is true and as "1 1/4" if the parameter is false. The default value is false.

    Returns
    System.String

    The created number format.

    IsDateTime(String)

    Checks if the provide number format is date format.

    • C#
    • VB.NET
    public static bool IsDateTime(string numberFormat)
    Public Shared Function IsDateTime(numberFormat As String) As Boolean
    Parameters
    numberFormat
    System.String
    Returns
    System.Boolean

    True, if number format is date format, false otherwise.

    Number(Int32, Int32, Boolean, Boolean)

    Creates a format for a number.

    • C#
    • VB.NET
    public static string Number(int decimalPlaces, int minDigits = 1, bool useThousandsSeparator = false, bool useParenthesesToDisplayNegativeValue = false)
    Public Shared Function Number(decimalPlaces As Integer, minDigits As Integer = 1, useThousandsSeparator As Boolean = False, useParenthesesToDisplayNegativeValue As Boolean = False) As String
    Parameters
    decimalPlaces
    System.Int32

    The number of decimal places that should be displayed to the right of the decimal separator.

    minDigits
    System.Int32

    The minimal number of digits that should be displayed to the left of the decimal separator. The default value is 1.

    useThousandsSeparator
    System.Boolean

    True if the thousands separator should be displayed, false otherwise. The default value is false.

    useParenthesesToDisplayNegativeValue
    System.Boolean

    True if negative value should be displayed using parentheses notation, false if minus sign (-) should be used instead. The default value is false.

    Returns
    System.String

    The created number format.

    Percentage(Int32)

    Creates a percentage number format.

    • C#
    • VB.NET
    public static string Percentage(int decimalPlaces)
    Public Shared Function Percentage(decimalPlaces As Integer) As String
    Parameters
    decimalPlaces
    System.Int32

    The number of decimal places that should be displayed to the right of the decimal separator.

    Returns
    System.String

    The created number format.

    Scientific(Int32)

    Creates a scientific number format.

    • C#
    • VB.NET
    public static string Scientific(int decimalPlaces)
    Public Shared Function Scientific(decimalPlaces As Integer) As String
    Parameters
    decimalPlaces
    System.Int32

    The number of decimal places that should be displayed to the right of the decimal separator.

    Returns
    System.String

    The created number format.

    Text()

    Creates a text number format.

    • C#
    • VB.NET
    public static string Text()
    Public Shared Function Text As String
    Returns
    System.String

    The created number format.

    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.