Share via


NumberingFormat Class

Definition

Number Formats.

This class is available in Office 2007 and above.

When the object is serialized out as xml, it's qualified name is x:numFmt.

[DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)]
[DocumentFormat.OpenXml.SchemaAttr(22, "numFmt")]
public class NumberingFormat : DocumentFormat.OpenXml.OpenXmlLeafElement
public class NumberingFormat : DocumentFormat.OpenXml.OpenXmlLeafElement
[DocumentFormat.OpenXml.SchemaAttr(22, "numFmt")]
public class NumberingFormat : DocumentFormat.OpenXml.OpenXmlLeafElement
[DocumentFormat.OpenXml.SchemaAttr("x:numFmt")]
public class NumberingFormat : DocumentFormat.OpenXml.OpenXmlLeafElement
[DocumentFormat.OpenXml.SchemaAttr("x:numFmt")]
public class NumberingFormat : DocumentFormat.OpenXml.TypedOpenXmlLeafElement
[DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)]
public class NumberingFormat : DocumentFormat.OpenXml.OpenXmlLeafElement
[<DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)>]
[<DocumentFormat.OpenXml.SchemaAttr(22, "numFmt")>]
type NumberingFormat = class
    inherit OpenXmlLeafElement
type NumberingFormat = class
    inherit OpenXmlLeafElement
[<DocumentFormat.OpenXml.SchemaAttr(22, "numFmt")>]
type NumberingFormat = class
    inherit OpenXmlLeafElement
[<DocumentFormat.OpenXml.SchemaAttr("x:numFmt")>]
type NumberingFormat = class
    inherit OpenXmlLeafElement
[<DocumentFormat.OpenXml.SchemaAttr("x:numFmt")>]
type NumberingFormat = class
    inherit TypedOpenXmlLeafElement
[<DocumentFormat.OpenXml.OfficeAvailability(DocumentFormat.OpenXml.FileFormatVersions.Office2007)>]
type NumberingFormat = class
    inherit OpenXmlLeafElement
Public Class NumberingFormat
Inherits OpenXmlLeafElement
Public Class NumberingFormat
Inherits TypedOpenXmlLeafElement
Inheritance
Inheritance
Attributes

Remarks

[ISO/IEC 29500-1 1st Edition]

numFmt (Number Format)

This element specifies number format properties which indicate how to format and render the numeric value of a cell.

Following is a listing of number formats whose formatCode value is implied rather than explicitly saved in the file. In this case a numFmtId value is written on the xf record, but no corresponding numFmt element is written. Some of these Ids can be interpreted differently, depending on the UI language of the implementing application.

Ids not specified in the listing, such as 5, 6, 7, and 8, shall follow the number format specified by the formatCode attribute.

All Languages

ID

formatCode

0

General

1

0

2

0.00

3

#,##0

4

#,##0.00

9

0%

10

0.00%

11

0.00E+00

12

# ?/?

13

# ??/??

14

mm-dd-yy

15

d-mmm-yy

16

d-mmm

17

mmm-yy

18

h:mm AM/PM

19

h:mm:ss AM/PM

20

h:mm

21

h:mm:ss

22

m/d/yy h:mm

37

#,##0 ;(#,##0)

38

#,##0 ;[Red](#,##0)

39

#,##0.00;(#,##0.00)

40

#,##0.00;[Red](#,##0.00)

45

mm:ss

46

[h]:mm:ss

47

mmss.0

48

##0.0E+0

49

@

" General " Format

Some additional comments about the "General" number format are appropriate.

The primary goal when a cell is using "General" formatting is to render the cell content without user-specified guidance to the best ability of the application.

Alignment

(Specified for Left-to-Right mode)

Strings: left aligned

Boolean/error values: centered

Numbers: right aligned

Dates: do not follow the "General" format, instead automatically convert to date formatting.

Numbers

The application shall attempt to display the full number up to 11 digits (inc. decimal point). If the number is too large, the application shall attempt to show exponential format. If the number has too many significant digits, the display shall be truncated. The optimal method of display is based on the available cell width. If the number cannot be displayed using any of these formats in the available width, the application shall show "#" across the width of the cell.

Conditions for switching to exponential format:

The cell value shall have at least five digits for xE-xx

If the exponent is bigger than the size allowed, a floating point number cannot fit, so try exponential notation.

Similarly, for negative exponents, check if there is space for even one (non-zero) digit in floating point format.

Finally, if there isn't room for all of the significant digits in floating point format (for a negative exponent), exponential format shall display more digits if the exponent is less than -3. (The 3 is because E-xx takes 4 characters, and the leading 0 in floating point takes only 1 character. Thus, for an exponent less than -3, there is more than 3 additional leading 0's, more than enough to compensate for the size of the E-xx.)

Floating point rule:

For general formatting in cells, max overall length for cell display is 11, not including negative sign, but includes leading zeros and decimal separator.

zh-tw and zh-cn

ID

zh-tw formatCode

zh-cn formatCode

27

[$-404]e/m/d

yyyy"年"m"月"

28

[$-404]e"年"m"月"d"日"

m"月"d"日"

29

[$-404]e"年"m"月"d"日"

m"月"d"日"

30

m/d/yy

m-d-yy

31

yyyy"年"m"月"d"日"

yyyy"年"m"月"d"日"

32

hh"時"mm"分"

h"时"mm"分"

33

hh"時"mm"分"ss"秒"

h"时"mm"分"ss"秒"

34

上午/下午hh"時"mm"分"

上午/下午h"时"mm"分"

35

上午/下午hh"時"mm"分"ss"秒"

上午/下午h"时"mm"分"ss"秒"

36

[$-404]e/m/d

yyyy"年"m"月"

50

[$-404]e/m/d

yyyy"年"m"月"

51

[$-404]e"年"m"月"d"日"

m"月"d"日"

52

上午/下午hh"時"mm"分"

yyyy"年"m"月"

53

上午/下午hh"時"mm"分"ss"秒"

m"月"d"日"

54

[$-404]e"年"m"月"d"日"

m"月"d"日"

55

上午/下午hh"時"mm"分"

上午/下午h"时"mm"分"

56

上午/下午hh"時"mm"分"ss"秒"

上午/下午h"时"mm"分"ss"秒"

57

[$-404]e/m/d

yyyy"年"m"月"

58

[$-404]e"年"m"月"d"日"

m"月"d"日"

zh-tw and zh-cn (with unicode values provided for language glyphs where they occur)

ID

zh-tw formatCode

zh-cn formatCode

27

[$-404]e/m/d

yyyy"5E74"m"6708"

28

[$-404]e"5E74"m"6708"d"65E5"

m"6708"d"65E5"

29

[$-404]e"5E74"m"6708"d"65E5"

m"6708"d"65E5"

30

m/d/yy

m-d-yy

31

yyyy"5E74"m"6708"d"65E5"

yyyy"5E74"m"6708"d"65E5"

32

hh"6642"mm"5206"

h"65F6"mm"5206"

33

hh"6642"mm"5206"ss"79D2"

h"65F6"mm"5206"ss"79D2"

34

4E0A5348/4E0B5348hh"6642"mm"5206"

4E0A5348/4E0B5348h"65F6"mm"5206"

35

4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2"

4E0A5348/4E0B5348h"65F6"mm"5206"ss"79D2"

36

[$-404]e/m/d

yyyy"5E74"m"6708"

50

[$-404]e/m/d

yyyy"5E74"m"6708"

51

[$-404]e"5E74"m"6708"d"65E5"

m"6708"d"65E5"

52

4E0A5348/4E0B5348hh"6642"mm"5206"

yyyy"5E74"m"6708"

53

4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2"

m"6708"d"65E5"

54

[$-404]e"5E74"m"6708"d"65E5"

m"6708"d"65E5"

55

4E0A5348/4E0B5348hh"6642"mm"5206"

4E0A5348/4E0B5348h"65F6"mm"5206"

56

4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2"

4E0A5348/4E0B5348h"65F6"mm"5206"ss"79D2"

57

[$-404]e/m/d

yyyy"5E74"m"6708"

58

[$-404]e"5E74"m"6708"d"65E5"

m"6708"d"65E5"

ja-jp and ko-kr

ID

ja-jp formatCode

ko-kr formatCode

27

[$-411]ge.m.d

yyyy"年" mm"月" dd"日"

28

[$-411]ggge"年"m"月"d"日"

mm-dd

29

[$-411]ggge"年"m"月"d"日"

mm-dd

30

m/d/yy

mm-dd-yy

31

yyyy"年"m"月"d"日"

yyyy"년" mm"월" dd"일"

32

h"時"mm"分"

h"시" mm"분"

33

h"時"mm"分"ss"秒"

h"시" mm"분" ss"초"

34

yyyy"年"m"月"

yyyy-mm-dd

35

m"月"d"日"

yyyy-mm-dd

36

[$-411]ge.m.d

yyyy"年" mm"月" dd"日"

50

[$-411]ge.m.d

yyyy"年" mm"月" dd"日"

51

[$-411]ggge"年"m"月"d"日"

mm-dd

52

yyyy"年"m"月"

yyyy-mm-dd

53

m"月"d"日"

yyyy-mm-dd

54

[$-411]ggge"年"m"月"d"日"

mm-dd

55

yyyy"年"m"月"

yyyy-mm-dd

56

m"月"d"日"

yyyy-mm-dd

57

[$-411]ge.m.d

yyyy"年" mm"月" dd"日"

58

[$-411]ggge"年"m"月"d"日"

mm-dd

ja-jp and ko-kr (with unicode values provided for language glyphs where they occur)

ID

ja-jp formatCode

ko-kr formatCode

27

[$-411]ge.m.d

yyyy"5E74" mm"6708" dd"65E5"

28

[$-411]ggge"5E74"m"6708"d"65E5"

mm-dd

29

[$-411]ggge"5E74"m"6708"d"65E5"

mm-dd

30

m/d/yy

mm-dd-yy

31

yyyy"5E74"m"6708"d"65E5"

yyyy"B144" mm"C6D4" dd"C77C"

32

h"6642"mm"5206"

h"C2DC" mm"BD84"

33

h"6642"mm"5206"ss"79D2"

h"C2DC" mm"BD84" ss"CD08"

34

yyyy"5E74"m"6708"

yyyy-mm-dd

35

m"6708"d"65E5"

yyyy-mm-dd

36

[$-411]ge.m.d

yyyy"5E74" mm"6708" dd"65E5"

50

[$-411]ge.m.d

yyyy"5E74" mm"6708" dd"65E5"

51

[$-411]ggge"5E74"m"6708"d"65E5"

mm-dd

52

yyyy"5E74"m"6708"

yyyy-mm-dd

53

m"6708"d"65E5"

yyyy-mm-dd

54

[$-411]ggge"5E74"m"6708"d"65E5"

mm-dd

55

yyyy"5E74"m"6708"

yyyy-mm-dd

56

m"6708"d"65E5"

yyyy-mm-dd

57

[$-411]ge.m.d

yyyy"5E74" mm"6708" dd"65E5"

58

[$-411]ggge"5E74"m"6708"d"65E5"

mm-dd

th-th

ID

th-th formatCode

59

t0

60

t0.00

61

t#,##0

62

t#,##0.00

67

t0%

68

t0.00%

69

t# ?/?

70

t# ??/??

71

ว/ด/ปปปป

72

ว-ดดด-ปป

73

ว-ดดด

74

ดดด-ปป

75

ช:นน

76

ช:นน:ทท

77

ว/ด/ปปปป ช:นน

78

นน:ทท

79

[ช]:นน:ทท

80

นน:ทท.0

81

d/m/bb

th-th (with unicode values provided for language glyphs where they occur)

ID

th-th formatCode

59

t0

60

t0.00

61

t#,##0

62

t#,##0.00

67

t0%

68

t0.00%

69

t# ?/?

70

t# ??/??

71

0E27/0E14/0E1B0E1B0E1B0E1B

72

0E27-0E140E140E14-0E1B0E1B

73

0E27-0E140E140E14

74

0E140E140E14-0E1B0E1B

75

0E0A:0E190E19

76

0E0A:0E190E19:0E170E17

77

0E27/0E14/0E1B0E1B0E1B0E1B 0E0A:0E190E19

78

0E190E19:0E170E17

79

[0E0A]:0E190E19:0E170E17

80

0E190E19:0E170E17.0

81

d/m/bb

Parent Elements
dxf (§18.8.14); ndxf (§18.11.1.4); numFmts (§18.8.31); odxf (§18.11.1.6)
Attributes Description
formatCode (Number Format Code) The number format code for this number format.

The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).
numFmtId (Number Format Id) Id used by the master style records (xf's) to reference this number format.

The possible values for this attribute are defined by the ST_NumFmtId simple type (§18.18.47).

[Note: The W3C XML Schema definition of this element’s content model (CT_NumFmt) is located in §A.2. end note]

� ISO/IEC29500: 2008.

Constructors

NumberingFormat()

Initializes a new instance of the NumberingFormat class.

Properties

ChildElements

Gets all the child nodes of the current element.

(Inherited from OpenXmlElement)
ExtendedAttributes

Gets all extended attributes (attributes not defined in the schema) of the current element.

(Inherited from OpenXmlElement)
Features

Gets a IFeatureCollection for the current element. This feature collection will be read-only, but will inherit features from its parent part and package if available.

(Inherited from OpenXmlElement)
FirstChild

Gets the first child of the OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no such OpenXmlElement element.

(Inherited from OpenXmlElement)
FormatCode

Number Format Code

Represents the following attribute in the schema: formatCode

HasAttributes

Gets a value indicating whether the current element has any attributes.

(Inherited from OpenXmlElement)
HasChildren

Gets a value that indicates whether the current element has any child elements.

(Inherited from OpenXmlLeafElement)
InnerText

Gets or sets the concatenated values of the node and all of its children.

(Inherited from OpenXmlElement)
InnerXml

Gets or sets the markup that only represents child elements of the current element.

(Inherited from OpenXmlLeafElement)
LastChild

Gets the last child of the OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no such OpenXmlElement element.

(Inherited from OpenXmlElement)
LocalName
LocalName

Gets the local name of the current element.

(Inherited from OpenXmlElement)
MCAttributes

Gets or sets the markup compatibility attributes. Returns null if no markup compatibility attributes are defined for the current element.

(Inherited from OpenXmlElement)
NamespaceDeclarations

Gets all the namespace declarations defined in the current element. Returns an empty enumerator if there is no namespace declaration.

(Inherited from OpenXmlElement)
NamespaceUri

Gets the namespace URI of the current element.

(Inherited from OpenXmlElement)
NumberFormatId

Number Format Id

Represents the following attribute in the schema: numFmtId

OpenXmlElementContext

Gets the OpenXmlElementContext of the current element.

(Inherited from OpenXmlElement)
OuterXml

Gets the markup that represents the current element and all of its child elements.

(Inherited from OpenXmlElement)
Parent

Gets the parent element of the current element.

(Inherited from OpenXmlElement)
Prefix

Gets the namespace prefix of current element.

(Inherited from OpenXmlElement)
XmlQualifiedName

Gets the qualified name of the current element.

(Inherited from OpenXmlElement)
XName

Gets the qualified name of the current element.

(Inherited from OpenXmlElement)

Methods

AddAnnotation(Object)

Adds an object to the current OpenXmlElement element's list of annotations.

(Inherited from OpenXmlElement)
AddNamespaceDeclaration(String, String)

Adds a namespace declaration to the current node.

(Inherited from OpenXmlElement)
Ancestors()

Enumerates all of the current element's ancestors.

(Inherited from OpenXmlElement)
Ancestors<T>()

Enumerates only the current element's ancestors that have the specified type.

(Inherited from OpenXmlElement)
Annotation(Type)

Get the first annotation object of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotation<T>()

Get the first annotation object of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotations(Type)

Gets a collection of annotations with the specified type for the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Annotations<T>()

Gets a collection of annotations with the specified type for the current OpenXmlElement element.

(Inherited from OpenXmlElement)
Append(IEnumerable<OpenXmlElement>)

Appends each element from a list of elements to the end of the current element's list of child elements.

(Inherited from OpenXmlElement)
Append(OpenXmlElement[])

Appends each element from an array of elements to the end of the current element's list of child elements.

(Inherited from OpenXmlElement)
AppendChild<T>(T)

Appends the specified element to the end of the current element's list of child nodes.

(Inherited from OpenXmlElement)
ClearAllAttributes()

Clears all of the attributes, including both known attributes and extended attributes.

(Inherited from OpenXmlElement)
Clone()

Creates a duplicate of the current node.

(Inherited from OpenXmlElement)
CloneNode(Boolean)

Creates a duplicate of this node.

Descendants()

Enumerates all of the current element's descendants.

(Inherited from OpenXmlElement)
Descendants<T>()

Enumerate all of the current element's descendants of type T.

(Inherited from OpenXmlElement)
Elements()

Enumerates all of the current element's children.

(Inherited from OpenXmlElement)
Elements<T>()

Enumerates only the current element's children that have the specified type.

(Inherited from OpenXmlElement)
ElementsAfter()

Enumerates all of the sibling elements that follow the current element and have the same parent as the current element.

(Inherited from OpenXmlElement)
ElementsBefore()

Enumerates all of the sibling elements that precede the current element and have the same parent as the current element.

(Inherited from OpenXmlElement)
GetAttribute(String, String)

Gets an Open XML attribute with the specified tag name and namespace URI.

(Inherited from OpenXmlElement)
GetAttributes()

Gets a list that contains a copy of all the attributes.

(Inherited from OpenXmlElement)
GetEnumerator()

Returns an enumerator that iterates through the child collection.

(Inherited from OpenXmlElement)
GetFirstChild<T>()

Finds the first child element in type T.

(Inherited from OpenXmlElement)
InsertAfter<T>(T, OpenXmlElement)

Inserts the specified element immediately after the specified reference element.

(Inherited from OpenXmlElement)
InsertAfterSelf<T>(T)

Inserts the specified element immediately after the current element.

(Inherited from OpenXmlElement)
InsertAt<T>(T, Int32)

Inserts the specified element at the specified index in the current element's list of child elements.

(Inherited from OpenXmlElement)
InsertBefore<T>(T, OpenXmlElement)

Inserts the specified element immediately before the specified reference element.

(Inherited from OpenXmlElement)
InsertBeforeSelf<T>(T)

Inserts the specified element immediately before the current element.

(Inherited from OpenXmlElement)
IsAfter(OpenXmlElement)

Determines if the current element appears after a specified element in document order.

(Inherited from OpenXmlElement)
IsBefore(OpenXmlElement)

Determines if the current element appears before a specified element in document order.

(Inherited from OpenXmlElement)
LookupNamespace(String)

Resolves the namespace prefix in the context of the current node.

(Inherited from OpenXmlElement)
LookupPrefix(String)

Finds the corresponding prefix for a namespace uri in the current element scope.

(Inherited from OpenXmlElement)
NextSibling()

Gets the OpenXmlElement element that immediately follows the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no next OpenXmlElement element.

(Inherited from OpenXmlElement)
NextSibling<T>()

Gets the OpenXmlElement element with the specified type that follows the current OpenXmlElement element. Returns null (Nothing in Visual Basic) if there is no next OpenXmlElement.

(Inherited from OpenXmlElement)
PrependChild<T>(T)

Inserts the specified element at the beginning of the current element's list of child elements.

(Inherited from OpenXmlElement)
PreviousSibling()

Gets the OpenXmlElement element that immediately precedes the current OpenXmlElement element. Returns null (Nothing in Visual Basic ) if there is no preceding OpenXmlElement element.

(Inherited from OpenXmlElement)
PreviousSibling<T>()

Gets the OpenXmlElement element with the specified type that precedes the current OpenXmlElement. Returns null (Nothing in Visual Basic) if there is no preceding OpenXmlElement element.

(Inherited from OpenXmlElement)
Remove()

Removes the current element from its parent.

(Inherited from OpenXmlElement)
RemoveAllChildren()

Removes all child elements of the current element.

(Inherited from OpenXmlLeafElement)
RemoveAllChildren<T>()

Remove all of the current element's child elements that are of type T.

(Inherited from OpenXmlElement)
RemoveAnnotations(Type)

Removes the annotations of the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
RemoveAnnotations<T>()

Removes the annotations with the specified type from the current OpenXmlElement element.

(Inherited from OpenXmlElement)
RemoveAttribute(String, String)

Removes the attribute from the current element.

(Inherited from OpenXmlElement)
RemoveChild<T>(T)

Removes the specified child element from the current element's list of child elements.

(Inherited from OpenXmlElement)
RemoveNamespaceDeclaration(String)

Removes the namespace declaration for the specified prefix. Removes nothing if there is no prefix.

(Inherited from OpenXmlElement)
ReplaceChild<T>(OpenXmlElement, T)

Replaces a child element with another child element in the current element's list of child elements.

(Inherited from OpenXmlElement)
SetAttribute(OpenXmlAttribute)

Sets an attribute to the specified element. If the attribute is a known attribute, the value of the attribute is set. If the attribute is an extended attribute, the 'openxmlAttribute' is added to the extended attributes list.

(Inherited from OpenXmlElement)
SetAttributes(IEnumerable<OpenXmlAttribute>)

Sets a number of attributes to the element. If an attribute is a known attribute, the value of the attribute is set. If an attribute is an extended attribute, the 'openxmlAttribute' is added to the extended attributes list.

(Inherited from OpenXmlElement)
WriteTo(XmlWriter)

Saves the current node to the specified XmlWriter.

(Inherited from OpenXmlElement)

Explicit Interface Implementations

IEnumerable.GetEnumerator() (Inherited from OpenXmlElement)
IEnumerable<OpenXmlElement>.GetEnumerator()

Returns an enumerator that iterates through the child collection.

(Inherited from OpenXmlElement)

Applies to