WorksheetBase.CustomProperties 屬性

定義

取得 CustomProperties 物件,表示與工作表相關的識別項資訊。Gets a CustomProperties object representing the identifier information associated with a worksheet.

public Microsoft.Office.Interop.Excel.CustomProperties CustomProperties { get; }

屬性值

CustomProperties

CustomProperties 物件,表示與工作表相關的識別項資訊。A CustomProperties object representing the identifier information associated with a worksheet.

範例

下列程式碼範例會使用 CustomProperties 屬性,將名為 "Microsoft" 的自訂屬性(其值為 "MSFT")新增至目前的工作表。The following code example uses the CustomProperties property to add a custom property named "Microsoft" with the value "MSFT" to the current worksheet. 然後,此範例會逐一查看自訂屬性的集合,直到找到 "Microsoft" 屬性,並將這個屬性的值設定為儲存格 A1。The example then iterates through the collection of custom properties until it finds the "Microsoft" property, and sets the value of this property to the cell A1.

這個範例適用于檔層級自訂。This example is for a document-level customization.

private void AddStockSymbol()
{
    this.CustomProperties.Add("Microsoft", "MSFT");

    for (int i = 1; i <= this.CustomProperties.Count; i++)
    {
        if (this.CustomProperties.get_Item(i).Name == "Microsoft")
        {
            this.Range["A1"].Value2 =
                this.CustomProperties.get_Item(i).Value.ToString();
            return;
        }
    }
}
Private Sub AddStockSymbol()
    Me.CustomProperties.Add("Microsoft", "MSFT")

    Dim i As Integer
    For i = 1 To Me.CustomProperties.Count
        If Me.CustomProperties(i).Name = "Microsoft" Then
            Me.Range("A1").Value2 = _
                Me.CustomProperties(i).Value.ToString()
            Return
        End If
    Next i

End Sub 'AddStockSymbol

適用於