Compartilhar via


Propriedade XmlMappedRange.MergeCells

Obtém ou define um valor que indica se o controle de XmlMappedRange contém células unidas.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (em Microsoft.Office.Tools.Excel.dll)

Sintaxe

'Declaração
Property MergeCells As Object
Object MergeCells { get; set; }

Valor de propriedade

Tipo: System.Object
true se o controle de XmlMappedRange contém células unidas; caso contrário, false.

Exemplos

O exemplo de código a seguir exibe o valor das propriedades de MergeArea e de MergeCells antes e depois de mesclar um intervalo que contém XmlMappedRange. Este exemplo de código a seguir pressupõe que a planilha atual contiver XmlMappedRange chamado CustomerLastNameCell que está em uma das células da célula B2 ao B5.

Private Sub SetMergeArea()
    Dim range1 As Excel.Range = Me.Range("B2", "B5")

    Dim beforeMergeAddress As String = _
        CustomerLastNameCell.MergeArea.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)

    MsgBox("Before merging, the MergeArea property is '" & _
        beforeMergeAddress & "' and the MergeCells property is " & _
        " '" + CustomerLastNameCell.MergeCells.ToString() & "'.")

    range1.Select()
    range1.Merge(False)

    Dim afterMergeAddress As String = _
        CustomerLastNameCell.MergeArea.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)

    MsgBox("After merging, the MergeArea property is '" & _
        afterMergeAddress & "' and the MergeCells property is " & _
        " '" + CustomerLastNameCell.MergeCells.ToString() & "'.")
End Sub
private void SetMergeArea()
{
    Excel.Range range1 = this.Range["B2", "B5"];

    string beforeMergeAddress = 
        CustomerLastNameCell.MergeArea.get_Address(
        Excel.XlReferenceStyle.xlA1);

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

    range1.Select();
    range1.Merge(false);

    string afterMergeAddress =
        CustomerLastNameCell.MergeArea.get_Address(
       Excel.XlReferenceStyle.xlA1);

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

Segurança do .NET Framework

Consulte também

Referência

XmlMappedRange Interface

Namespace Microsoft.Office.Tools.Excel