New to Telerik Document Processing? Start a free 30-day trial

Culture Specific Predefined Formats

Updated on Oct 14, 2026

Starting with R3 2021, SpreadStreamProcessing exposes the BuiltInNumberFormats static class. This class contains several methods that allow you to get a set of predefined formats. These formats are culture-specific and depend on the current culture of the operating system. For example, if you set a currency format, you get the currency symbol for the current culture. The following methods are available:

MethodFormat in en-US cultureDescription
GetGeneralGeneralGenerates the General number format string.
GetNumber0Generates a Number number format string.
GetNumber10.00Generates a Number number format string with 2 decimal places and no thousand separator.
GetNumber2#,##0Generates a Number number format string with zero decimal places and a thousand separator.
GetNumber3#,##0.00Generates a Number number format string with 2 decimal places and a thousand separator.
GetCurrency$#,##0_);($#,##0)Generates a Currency number format string with no decimal places, and positive and negative format patterns and alignment.
GetCurrency1$#,##0_);[Red]($#,##0)Generates a Currency number format string with no decimal places, and positive and negative format with red digits patterns and alignment.
GetCurrency2$#,##0.00_);($#,##0.00)Generates a Currency number format string with two decimal places, and positive and negative format patterns and alignment.
GetCurrency3$#,##0.00_);[Red]($#,##0.00)Generates a Currency number format string with two decimal places, and positive and negative format with red digits patterns and alignment.
GetPercent0%Generates a Percent number format string.
GetPercent10.00%Generates a Percent number format string with 2 decimal places and no thousand separator.
GetScientific0.00E+00Generates a culture-dependent Scientific number format string.
GetFraction# ?/?Generates a Fraction number format for up to one digit.
GetFraction1# ??/??Generates a Fraction number format for up to two digits.
GetShortDatem/d/yyyyGenerates a Date number format for short date.
GetDayMonthYeard-mmm-yyGenerates a Date number format with day, month, and year.
GetDayMonthd-mmmGenerates a Date number format with day and month.
GetMonthYearmmm-yyGenerates a Date number format with month and year.
GetHourMinuteAMPMh:mm AM/PMGenerates a Time number format with hours, minutes, and AM/PM.
GetHourMinuteSecondAMPMh:mm:ss AM/PMGenerates a Time number format with hours, minutes, seconds, and AM/PM.
GetHourMinuteh:mmGenerates a Time number format with hours and minutes.
GetHourMinuteSecondh:mm:ssGenerates a Time number format with hours, minutes, and seconds.
GetShortDateHourMinutem/d/yyyy h:mmGenerates a Time number format with short date, hours, and minutes.
GetDayMonthLongYearm/d/yyyyGenerates a Date number format with day, month, and year.
GetNumber4#,##0_);(#,##0)Generates a Currency number format string with no decimal places, a thousand separator, and positive and negative format pattern and alignment.
GetNumber5#,##0_);[Red](#,##0)Generates a Currency number format string with no decimal places, a thousand separator, and positive and negative format with red digits patterns and alignment.
GetNumber6#,##0.00_);(#,##0.00)Generates a Currency number format string with two decimal places, a thousand separator, and positive and negative format pattern and alignment.
GetNumber7#,##0.00_);[Red](#,##0.00)Generates a Currency number format string with two decimal places, a thousand separator, and positive and negative format with red digits patterns and alignment.
GetCurrency4(*#,##0);(*(#,##0);(* "-");(@_)
GetCurrency5($*#,##0);($*(#,##0);($* "-");(@_)
GetCurrency6(*#,##0.00);(*(#,##0.00);(*"-"??);(@_)
GetCurrency7($*#,##0.00);($*(#,##0.00);($*"-"??);(@_)
GetScientific2##0.0E+0

Working with the BuiltInNumberFormats Class

The following example demonstrates how you can get a specific format and set it when exporting a cell.

Example 1: Apply a culture-specific fraction format to an exported cell value

C#
SpreadCellFormat format = new SpreadCellFormat();
format.NumberFormat = BuiltInNumberFormats.GetFraction();

using (ICellExporter cell = row.CreateCellExporter())
{
    cell.SetValue(0.5);
    cell.SetFormat(format);
}

Invariant Number Formats

By default, the NumberFormat property of SpreadCellFormat and SpreadCellStyle accepts a format code that is interpreted according to the current culture. To set the format code exactly as it appears in the Open XML model, regardless of the current culture, use the InvariantNumberFormat property.

The following rules apply to InvariantNumberFormat:

  • The value is an invariant Excel format code (for example, #,##0.00 or yyyy-mm-dd), not a .NET format string.
  • The following canonical numeric codes are exported as built-in formats with their fixed IDs: 0, 0.00, #,##0, #,##0.00, 0%, 0.00%, 0.00E+00, # ?/?, # ??/??, #,##0_);(#,##0), #,##0_);[Red](#,##0), #,##0.00_);(#,##0.00), #,##0.00_);[Red](#,##0.00), and ##0.0E+0.
  • Any other code is preserved unchanged as a custom format.
  • An empty string applies the General format, and null clears the override.
  • NumberFormat and InvariantNumberFormat are mutually exclusive. The last assignment to either property determines which one is used, even when the string is unchanged. The inactive property returns null.

Example 2: Apply an invariant number format to an exported cell

csharp
using (ICellExporter cell = row.CreateCellExporter())
{
    SpreadCellFormat format = new SpreadCellFormat
    {
        InvariantNumberFormat = "#,##0.00"
    };

    cell.SetFormat(format);
    cell.SetValue(1234.5);
}

See Also