WorksheetBase.Index 属性
获取工作表集合中工作表的索引号。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)
语法
声明
Public ReadOnly Property Index As Integer
public int Index { get; }
属性值
类型:System.Int32
工作表集合中工作表的索引号。
示例
下面的代码示例在通过使用 Move 方法将工作表移动到工作簿中的最后一个位置之前和之后使用 Index 属性来显示当前工作表的索引号。
此示例针对的是文档级自定义项。
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());
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。