Proprietà NamedRange.MergeCells

Ottiene o imposta un valore che indica se il controllo NamedRange contiene celle unite.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Sintassi

'Dichiarazione
Property MergeCells As Object
    Get
    Set
Object MergeCells { get; set; }

Valore proprietà

Tipo: System.Object
true se il controllo NamedRange contiene celle unite; in caso contrario, false.

Esempi

Nell'esempio di codice riportato di seguito viene visualizzato il valore delle proprietà MergeArea e MergeCells di un controllo NamedRange a cella singola prima e dopo l'utilizzo del metodo Merge per unire il controllo NamedRange a più celle che contiene il controllo NamedRange a cella singola.

Questo esempio è valido per una personalizzazione a livello di documento.

    Private Sub MergeRange()
        Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Me.Range("A1", "A5"), _
            "namedRange1")

        Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Me.Range("A1"), "namedRange2")

        Dim beforeMergeAddress As String = _
            namedRange2.MergeArea.Address(, , _
            Excel.XlReferenceStyle.xlA1, , )

        MessageBox.Show("Before merging, the MergeArea property is '" & _
            beforeMergeAddress & "' and the MergeCells property is " & _
            " '" & namedRange2.MergeCells.ToString() & "'.")

        namedRange1.Select()
        namedRange1.Merge(False)

        Dim afterMergeAddress As String = _
            namedRange2.MergeArea.Address(, , _
            Excel.XlReferenceStyle.xlA1, , )

        MessageBox.Show("After merging, the MergeArea property is '" & _
            afterMergeAddress & "' and the MergeCells property is " & _
            " '" & namedRange2.MergeCells.ToString() & "'.")
    End Sub

private void MergeRange()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");

    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(this.Range["A1", missing],
        "namedRange2");

    string beforeMergeAddress = namedRange2.MergeArea.get_Address(
        missing, missing, Excel.XlReferenceStyle.xlA1, missing, missing);

    MessageBox.Show("Before merging, the MergeArea property is '" +
        beforeMergeAddress + "' and the MergeCells property is " +
        " '" + namedRange2.MergeCells.ToString() + "'.");

    namedRange1.Select();
    namedRange1.Merge(false);

    string afterMergeAddress = namedRange2.MergeArea.get_Address(
        missing, missing, Excel.XlReferenceStyle.xlA1, missing, missing);

    MessageBox.Show("After merging, the MergeArea property is '" +
        afterMergeAddress + "' and the MergeCells property is " +
        " '" + namedRange2.MergeCells.ToString() + "'.");
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

NamedRange Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Excel