XmlMappedRange.MergeCells 屬性
取得或設定指出 XmlMappedRange 控制項是否包含合併儲存格的值。
命名空間: Microsoft.Office.Tools.Excel
組件: Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)
語法
'宣告
Property MergeCells As Object
Object MergeCells { get; set; }
屬性值
型別:System.Object
如果 XmlMappedRange 控制項包含合併儲存格,此值為 true,否則為 false。
範例
下列程式碼會顯示在合併含有 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。