XmlMappedRange.NumberFormat 属性

获取或设置 XmlMappedRange 控件的格式代码。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Property NumberFormat As Object
    Get
    Set
Object NumberFormat { get; set; }

属性值

类型:System.Object
XmlMappedRange 控件的格式代码。

备注

如果 XmlMappedRange 控件中的所有单元格不具有相同的数字格式,则此属性返回 nullnull 引用(在 Visual Basic 中为 Nothing)。

格式代码是与**“设置单元格格式”对话框中“设置代码格式”**选项相同的字符串。 Format 函数与 NumberFormatNumberFormatLocal 属性使用不同的格式代码字符串。

示例

下面的代码示例使用 NumberFormat 属性设置 XmlMappedRange 中的日期字符串的格式。 该示例还使用 NumberFormatLocal 属性以用户的语言来显示日期格式。 此代码示例假定当前工作表包含一个名为 CustomerDateCell 的 XmlMappedRange

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 安全性

请参见

参考

XmlMappedRange 接口

Microsoft.Office.Tools.Excel 命名空间