共用方式為


WorksheetBase.ConsolidationFunction 屬性

取得用於目前彙總的函式程式碼。

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

語法

'宣告
Public ReadOnly Property ConsolidationFunction As XlConsolidationFunction
    Get
public XlConsolidationFunction ConsolidationFunction { get; }

屬性值

型別:Microsoft.Office.Interop.Excel.XlConsolidationFunction
其中一個 XlConsolidationFunction 值。

範例

下列程式碼範例會使用 ConsolidationFunction 屬性,判斷工作表使用哪項函式執行彙總。

這是示範文件層級自訂的範例。

Private Sub ShowConsolidationFunction()
    Dim simpleName As String

    Select Case Me.ConsolidationFunction
        Case Excel.XlConsolidationFunction.xlSum
            simpleName = "Sum()"
        Case Excel.XlConsolidationFunction.xlMax
            simpleName = "Max()"
        Case Excel.XlConsolidationFunction.xlProduct
            simpleName = "Product()"
        Case Else
            simpleName = "Other"
    End Select
    MsgBox("This worksheet uses " & simpleName & _
        " for the consolidation function.")
End Sub
private void ShowConsolidationFunction()
{
    string simpleName;

    switch (this.ConsolidationFunction)
    {
        case Excel.XlConsolidationFunction.xlSum:
            simpleName = "Sum()";
            break;

        case Excel.XlConsolidationFunction.xlMax:
            simpleName = "Max()";
            break;

        case Excel.XlConsolidationFunction.xlProduct:
            simpleName = "Product()";
            break;

        default:
            simpleName = "Other";
            break;
    }
    MessageBox.Show("This worksheet uses " + simpleName +
        " for the consolidation function.");
}

.NET Framework 安全性

請參閱

參考

WorksheetBase 類別

Microsoft.Office.Tools.Excel 命名空間