Proprietà WorksheetBase.Index

Ottiene il numero di indice del foglio di lavoro all'interno dell'insieme di fogli di lavoro.

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

Sintassi

'Dichiarazione
Public ReadOnly Property Index As Integer
    Get
public int Index { get; }

Valore proprietà

Tipo: System.Int32
Numero di indice del foglio di lavoro all'interno dell'insieme di fogli di lavoro.

Esempi

Nell'esempio di codice riportato di seguito viene utilizzata la proprietà Index per visualizzare il numero di indice del foglio di lavoro corrente prima e dopo lo spostamento di tale foglio in ultima posizione nella cartella di lavoro tramite il metodo Move.

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

Private Sub DisplayIndex()
    MsgBox("Before moving, this worksheet is at tab number " & _
        Me.Index.ToString())

    ' Move the worksheet to the last position in the workbook.
    Me.Move(After:=Globals.ThisWorkbook.Worksheets( _
        Globals.ThisWorkbook.Worksheets.Count))

    MsgBox("After moving, this worksheet is at tab number " & _
        Me.Index.ToString())
End Sub
private void DisplayIndex()
{
    MessageBox.Show("Before moving, this worksheet is at tab number " +
        this.Index.ToString());

    // Move the worksheet to the last position in the workbook.
    this.Move(missing, 
        Globals.ThisWorkbook.Worksheets[Globals.ThisWorkbook.Worksheets.Count]);

    MessageBox.Show("After moving, this worksheet is at tab number " +
        this.Index.ToString());
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

WorksheetBase Classe

Spazio dei nomi Microsoft.Office.Tools.Excel