XmlMappedRange.Address 属性

获取 XmlMappedRange 控件的范围引用。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
ReadOnly Property Address As XmlMappedRange_AddressType
    Get
XmlMappedRange_AddressType Address { get; }

属性值

类型:Microsoft.Office.Tools.Excel.XmlMappedRange_AddressType
一个字符串,以 R1C1 样式或 A1 样式表示法表示 XmlMappedRange 控件的范围引用。

备注

Address 属性适合与下面的参数一起使用。

Parameter

说明

RowAbsolute

为 true 时,将行作为绝对引用返回;否则为 false。 默认值为 true。

ColumnAbsolute

为 true 时,将列作为绝对引用返回;否则为 false。 默认值为 true。

ReferenceStyle

XlReferenceStyle 值之一。

External

如果返回外部引用,则为 true;如果返回本地引用,则为 false。 默认值为 false。

RelativeTo

一个用于定义起始点的 Range。 如果 RowAbsolute 和 ColumnAbsolute 为 false,ReferenceStyle 为 xlR1C1,则必须包括相对引用的起始点。

如果尝试在不指定任何参数的情况下使用 Address,则 Address 将获取一个 XmlMappedRange_AddressType 对象,该对象是 Visual Studio 基础结构中 Office 开发工具的一部分,不能直接从您的代码使用。

可选参数

有关可选参数的信息,请参见Office 解决方案中的可选参数

示例

下面的代码示例使用 Address 属性显示 XmlMappedRange 的范围位置。 该示例使用 ReferenceStyle、RowAbsolute、ColumnAbsolute 和 RelativeTo 参数的不同组合以四种不同的格式显示范围位置。 此代码示例假定当前工作表包含一个名为 CustomerLastNameCell 的 XmlMappedRange。 如果 CustomerLastNameCell 位于单元格 A2,则该示例将显示地址字符串“$A$2”、“$A2”、“R2C2”和“R[-1]C[-1]”。

Private Sub DisplayAddress()
    Me.Range("A1").Value2 = _
        Me.CustomerLastNameCell.Address(True, True, _
        Excel.XlReferenceStyle.xlA1, False)

    Me.Range("A2").Value2 = _
        Me.CustomerLastNameCell.Address(False, True, _
        Excel.XlReferenceStyle.xlA1, False)

    Me.Range("A3").Value2 = _
        Me.CustomerLastNameCell.Address(True, True, _
        Excel.XlReferenceStyle.xlR1C1, False)

    Me.Range("A4").Value2 = _
        Me.CustomerLastNameCell.Address(False, False, _
        Excel.XlReferenceStyle.xlR1C1, False, Me.Cells(3, 3))
End Sub
private void DisplayAddress()
{
    this.Range["A1", missing].Value2 = 
        this.CustomerLastNameCell.Address[true, true,
        Excel.XlReferenceStyle.xlA1, false, missing];

    this.Range["A2", missing].Value2 = 
        this.CustomerLastNameCell.Address[false, true,
        Excel.XlReferenceStyle.xlA1, false, missing];

    this.Range["A3", missing].Value2 = 
        this.CustomerLastNameCell.Address[true, true,
        Excel.XlReferenceStyle.xlR1C1, false, missing];

    this.Range["A4", missing].Value2 = 
        this.CustomerLastNameCell.Address[false, false,
        Excel.XlReferenceStyle.xlR1C1, false, this.Cells[3, 3]];
}

.NET Framework 安全性

请参见

参考

XmlMappedRange 接口

Microsoft.Office.Tools.Excel 命名空间