次の方法で共有


WorksheetBase.ConsolidationSources プロパティ

ワークシートの現在の統合用の、参照元シートの名前と範囲を指定する、文字列の Array を取得します。

名前空間:  Microsoft.Office.Tools.Excel
アセンブリ:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 内)

構文

'宣言
Public ReadOnly Property ConsolidationSources As Object
    Get
public Object ConsolidationSources { get; }

プロパティ値

型: System.Object
ワークシートの現在の統合用の、参照元シートの名前と範囲を指定する、文字列値の Array です。シート状に統合がない場合は nullnull 参照 (Visual Basic では Nothing) です。

次のコード例では、現在のワークシート上で統合を作成し、ConsolidationSources プロパティを使用して統合元を表示します。

この例は、ドキュメント レベルのカスタマイズ用に作成されています。

Private Sub ShowConsolidationSources()

    ' Popluate the data to be consolidated.
    Me.Range("A1").Value2 = 22
    Me.Range("A2").Value2 = 33
    Dim sourceStrings() As String = {"Sheet1!R1C1", _
            "Sheet1!R2C1"}

    ' Consoldate the data by adding it together.
    Me.Range("A3").Consolidate( _
        sourceStrings, Excel.XlConsolidationFunction.xlSum, _
        False, False, False)

    ' Display the sources of the consolidated data.
    If Not (Me.ConsolidationSources Is Nothing) Then
        Me.Range("C1").Value2 = _
            "Consolidation Sources"
        Dim sources As Array = CType(Me.ConsolidationSources, Array)

        If sources.Length <> 0 Then
            Dim i As Integer
            For i = 1 To sources.Length
                Me.Range("C" & (i + 1).ToString()).Value2 = sources.GetValue(i)
            Next i
        Else
            Me.Range("C2").Value2 = "None"
        End If
    Else
        MsgBox("This worksheet has no consolidation.")
    End If
End Sub
private void ShowConsolidationSources()
{
    // Popluate the data to be consolidated.
    this.Range["A1", missing].Value2 = 22;
    this.Range["A2", missing].Value2 = 33;
    string[] sourceStrings = new string[] { "Sheet1!R1C1", 
        "Sheet1!R2C1" };

    // Consoldate the data by adding it together.
    this.Range["A3", missing].Consolidate(sourceStrings,
        Excel.XlConsolidationFunction.xlSum, false, false, false);

    // Display the sources of the consolidated data.
    if (this.ConsolidationSources != null)
    {
        this.Range["C1", missing].Value2 = "Consolidation Sources";
        Array sources = (Array)this.ConsolidationSources;

        if (sources.Length != 0)
        {
            for (int i = 1; i <= sources.Length; i++)
            {
                this.Range["C" + (i + 1).ToString(),
                    missing].Value2 = sources.GetValue(i);
            }
        }
        else
        {
            this.Range["C2", missing].Value2 = "None";
        }
    }
    else
    {
        MessageBox.Show("This worksheet has no consolidation.");
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

WorksheetBase クラス

Microsoft.Office.Tools.Excel 名前空間