Share via


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 네임스페이스