Share via


XmlMappedRange.NumberFormat Property

Gets or sets the format code for the XmlMappedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Property NumberFormat As Object
Object NumberFormat { get; set; }

Property Value

Type: System.Object
The format code for the XmlMappedRange control.

Remarks

This property returns nulla null reference (Nothing in Visual Basic) if all cells in the XmlMappedRange control do not have the same number format.

The format code is the same string as the Format Codes option in the Format Cells dialog box. The Format function uses different format code strings than do the NumberFormat and NumberFormatLocal properties.

Examples

The following code example uses the NumberFormat property to format date strings in an XmlMappedRange. The example also uses the NumberFormatLocal property to display the date format in the language of the user. This code example assumes that the current worksheet contains an XmlMappedRange named CustomerDateCell.

Private Sub ApplyNumberFormatting()
    Me.CustomerDateCell.Value2 = "4-Apr-1974" 
    Me.CustomerDateCell.NumberFormat = "m/d/yyyy" 

    ' Display the number format in the language of the user.
    MsgBox("The number format for CustomerDateCell is: " & _
        Me.CustomerDateCell.NumberFormatLocal.ToString())
End Sub
private void ApplyNumberFormatting()
{
    this.CustomerDateCell.Value2 = "4-Apr-1974";
    this.CustomerDateCell.NumberFormat = "m/d/yyyy";

    // Display the number format in the language of the user.
    MessageBox.Show("The number format for CustomerDateCell is: " +
        this.CustomerDateCell.NumberFormatLocal.ToString());
}

.NET Framework Security

See Also

Reference

XmlMappedRange Interface

Microsoft.Office.Tools.Excel Namespace