XmlMappedRange.NumberFormat 屬性

取得或設定 XmlMappedRange 控制項的格式化程式碼。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
Property NumberFormat As Object
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 命名空間