XmlMappedRange.MergeArea 屬性
取得 Range,表示 XmlMappedRange 控制項包含合併的範圍。
命名空間: Microsoft.Office.Tools.Excel
組件: Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)
語法
'宣告
ReadOnly Property MergeArea As Range
Get
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(
missing, missing, Excel.XlReferenceStyle.xlA1,
missing, missing);
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(
missing, missing, Excel.XlReferenceStyle.xlA1,
missing, missing);
MessageBox.Show("After merging, the MergeArea property is '" +
afterMergeAddress + "' and the MergeCells property is " +
" '" + CustomerLastNameCell.MergeCells.ToString() + "'.");
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。