XmlMappedRange.MergeArea 属性
获取一个 Range,它表示包含 XmlMappedRange 控件的合并范围。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
ReadOnly Property MergeArea As Range
Range MergeArea { get; }
属性值
类型:Microsoft.Office.Interop.Excel.Range
一个 Range,表示包含 XmlMappedRange 控件的合并范围。如果 XmlMappedRange 控件不在合并范围中,则此属性返回 XmlMappedRange 控件。
备注
MergeArea 属性只能工作于单个单元格范围上。
示例
下面的代码示例在合并包含 XmlMappedRange 的范围前后显示 MergeArea 和 MergeCells 属性的值。 此代码示例假定当前工作表包含一个名为 CustomerLastNameCell 的位于单元格 B2 至 B5 中的一个单元格内的 XmlMappedRange。
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() + "'.");
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。