Share via


Proprietà NamedRange.NumberFormat

Ottiene o imposta il codice di formattazione per il controllo NamedRange.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Sintassi

'Dichiarazione
Property NumberFormat As Object
    Get
    Set
Object NumberFormat { get; set; }

Valore proprietà

Tipo: System.Object
Codice di formattazione per il controllo NamedRange.

Note

Questa proprietà restituisce il valore nullriferimento null (Nothing in Visual Basic) se il formato numerico non è identico per tutte le celle nel controllo NamedRange.

Il codice di formattazione corrisponde alla stringa dell'opzione Codici di formattazione della finestra di dialogo Formato celle. La funzione Format utilizza stringhe di codice di formattazione diverse rispetto alle proprietà NumberFormat e NumberFormatLocal.

Esempi

Nell'esempio di codice riportato di seguito viene utilizzata la proprietà NumberFormat per formattare una stringa di data in un controllo NamedRange. Viene inoltre utilizzata la proprietà NumberFormatLocal per visualizzare il formato della data nella lingua dell'utente.

Questo esempio è valido per una personalizzazione a livello di documento.

Private formatRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub ApplyNumberFormatting()
    formatRange = Me.Controls.AddNamedRange( _
        Me.Range("C1"), "formatRange")

    Me.formatRange.Value2 = "4-Apr-1974"
    Me.formatRange.NumberFormat = "m/d/yyyy"

    ' Display the number format in the language of the user.
    MessageBox.Show("The number format for the NamedRange is: " & _
        Me.formatRange.NumberFormatLocal.ToString())
End Sub
Microsoft.Office.Tools.Excel.NamedRange formatRange;
private void ApplyNumberFormatting()
{
    formatRange = this.Controls.AddNamedRange(
         this.Range["C1", missing], "formatRange");

    this.formatRange.Value2 = "4-Apr-1974";
    this.formatRange.NumberFormat = "m/d/yyyy";

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

NamedRange Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Excel