Class BuiltinFormats
The class contains the built-in formats.
Inheritance
Namespace: IronXL.Formatting
Assembly: IronXL.dll
Syntax
public static class BuiltinFormats : Object
Currency, percentage, date, and accounting layouts that a spreadsheet needs every day live as ready-made strings on BuiltinFormats. Each field holds an Excel number-format code, so a developer assigns one to a cell instead of hand-writing a format pattern like "$#,##0.00". It is the shortcut a developer reaches for behind a search like "C# Excel number format".
The fields feed the FormatString property on a Cell or a Range. After loading or creating a workbook, pick the field that matches the data and assign it: BuiltinFormats.Currency2 for two-decimal money, BuiltinFormats.Percent2 for percentages, BuiltinFormats.ShortDate for dates. Because BuiltinFormats is a static class of constants, there is nothing to construct; reference the field directly wherever a format string is expected.
The fields group by data kind. Money and accounting cover Currency0, Currency2, Accounting0, Accounting2, and their red-negative variants such as Currency2Red. Numbers cover Number0, Number2, Thousands2, Scientific1, and the Fraction1 family. Dates and times cover ShortDate, LongDate1, ShortDateAndTime, and the Time1 through Time4 set. Percent and Percent2 handle ratios, while Text forces literal text and General restores Excel's default. The trailing digit on most names is the decimal-place count, so Number0 shows whole numbers and Number2 shows two places. When none of the built-ins fit, assign a raw Excel format code to FormatString directly instead of a BuiltinFormats field.
using IronXL;
using IronXL.Formatting;
WorkBook book = WorkBook.Create();
WorkSheet sheet = book.DefaultWorkSheet;
sheet["B2"].Value = 1234.5;
sheet["B2"].FormatString = BuiltinFormats.Currency2;
book.SaveAs("formatted.xlsx");The set cell data format how-to walks through applying a format to a cell or range, the Excel number formats example shows several built-ins side by side, and the style cells example combines formats with fonts and borders.
Fields
Accounting0
Returns the built-in format string for a accounting value with zero digits after the dot. ("#,##0_);(#,##0)")
Declaration
public static readonly string Accounting0
Field Value
| Type | Description |
|---|---|
| System.String |
Accounting0Red
Returns the built-in format string for a accounting value without digits after the dot and red style for negative value. (#,##0_);Red"")
Declaration
public static readonly string Accounting0Red
Field Value
| Type | Description |
|---|---|
| System.String |
Accounting2
Returns the built-in format string for a accounting value with two digits after the dot. ("#,##0.00);(#,##0.00)")
Declaration
public static readonly string Accounting2
Field Value
| Type | Description |
|---|---|
| System.String |
Accounting2Red
Returns the built-in format string for a accounting value with two digits after the dot and red style for negative value. ("#,##0.00_);Red")
Declaration
public static readonly string Accounting2Red
Field Value
| Type | Description |
|---|---|
| System.String |
Currency0
Returns the built-in format string for a currency value with zero digits after the dot. ("$#,##0_);($#,##0)")
Declaration
public static readonly string Currency0
Field Value
| Type | Description |
|---|---|
| System.String |
Currency0Red
Returns the built-in format string for a currency value without digits after the dot and red style for negative value. ("$#,##0_);Red")
Declaration
public static readonly string Currency0Red
Field Value
| Type | Description |
|---|---|
| System.String |
Currency2
Returns the built-in format string for a currency value with two digits after the dot. ("$#,##0.00);($#,##0.00)")
Declaration
public static readonly string Currency2
Field Value
| Type | Description |
|---|---|
| System.String |
Currency2Red
Returns the built-in format string for a currency value with two digits after the dot and red style for negative value. ("$#,##0.00_);Red")
Declaration
public static readonly string Currency2Red
Field Value
| Type | Description |
|---|---|
| System.String |
Duration1
Returns the built-in format string for a duration value. ("mm:ss")
Declaration
public static readonly string Duration1
Field Value
| Type | Description |
|---|---|
| System.String |
Duration2
Returns the built-in format string for a duration value. ("[h]:mm:ss")
Declaration
public static readonly string Duration2
Field Value
| Type | Description |
|---|---|
| System.String |
Duration3
Returns the built-in format string for a duration value. ("mm:ss.0")
Declaration
public static readonly string Duration3
Field Value
| Type | Description |
|---|---|
| System.String |
Fraction1
Returns the built-in format string for a fraction with one digit. ("# ?/?")
Declaration
public static readonly string Fraction1
Field Value
| Type | Description |
|---|---|
| System.String |
Fraction2
Returns the built-in format string for a fraction with two digits. ("# ??/??")
Declaration
public static readonly string Fraction2
Field Value
| Type | Description |
|---|---|
| System.String |
General
Returns the general built-in format string. ("General")
Declaration
public static readonly string General
Field Value
| Type | Description |
|---|---|
| System.String |
LongDate1
Returns the built-in format string for a long date. ("d-mmm-yy")
Declaration
public static readonly string LongDate1
Field Value
| Type | Description |
|---|---|
| System.String |
LongDate2
Returns the built-in format string for a long date. ("d-mmm")
Declaration
public static readonly string LongDate2
Field Value
| Type | Description |
|---|---|
| System.String |
LongDate3
Returns the built-in format string for a long date. ("mmm-yy")
Declaration
public static readonly string LongDate3
Field Value
| Type | Description |
|---|---|
| System.String |
Number0
Returns the built-in format string for a number value without digits after the dot. ("0")
Declaration
public static readonly string Number0
Field Value
| Type | Description |
|---|---|
| System.String |
Number2
Returns the built-in format string for a number value with two digits after the dot. ("0.00")
Declaration
public static readonly string Number2
Field Value
| Type | Description |
|---|---|
| System.String |
Percent
Returns the built-in format string for a percent without digits after the dot. ("0%")
Declaration
public static readonly string Percent
Field Value
| Type | Description |
|---|---|
| System.String |
Percent2
Returns the built-in format string for a percent with two digits after the dot. ("0.00%")
Declaration
public static readonly string Percent2
Field Value
| Type | Description |
|---|---|
| System.String |
Scientific1
Returns the built-in format string for a scientific with one digit after the dot. ("##0.0E+0")
Declaration
public static readonly string Scientific1
Field Value
| Type | Description |
|---|---|
| System.String |
Scientific2
Returns the built-in format string for a scientific with two digits after the dot. ("0.00E+00")
Declaration
public static readonly string Scientific2
Field Value
| Type | Description |
|---|---|
| System.String |
ShortDate
Returns the built-in format string for a short date. ("m/d/yy")
Declaration
public static readonly string ShortDate
Field Value
| Type | Description |
|---|---|
| System.String |
ShortDateAndTime
Returns the built-in format string for a short date and time. ("m/d/yy h:mm")
Declaration
public static readonly string ShortDateAndTime
Field Value
| Type | Description |
|---|---|
| System.String |
Text
Returns the built-in format string for a text value. ("@")
Declaration
public static readonly string Text
Field Value
| Type | Description |
|---|---|
| System.String |
Thousands0
Returns the built-in format string for a number value with thousands and without digits after the dot. ("#,##0")
Declaration
public static readonly string Thousands0
Field Value
| Type | Description |
|---|---|
| System.String |
Thousands2
Returns the built-in format string for a number value with thousands and two digits after the dot. ("#,##0.00")
Declaration
public static readonly string Thousands2
Field Value
| Type | Description |
|---|---|
| System.String |
Time1
Returns the built-in format string for a time. ("h:mm AM/PM")
Declaration
public static readonly string Time1
Field Value
| Type | Description |
|---|---|
| System.String |
Time2
Returns the built-in format string for a time. ("h:mm:ss AM/PM")
Declaration
public static readonly string Time2
Field Value
| Type | Description |
|---|---|
| System.String |
Time3
Returns the built-in format string for a time. ("h:mm")
Declaration
public static readonly string Time3
Field Value
| Type | Description |
|---|---|
| System.String |
Time4
Returns the built-in format string for a time. ("h:mm:ss")
Declaration
public static readonly string Time4
Field Value
| Type | Description |
|---|---|
| System.String |