Skip to content
本页内容

LocationInTable (属性)

返回一个常量,该常量描述包含指定区域左上角部分的 PivotTable 部分。可为以下 XlLocationInTable 常量之一。int 类型,只读。

说明

XlLocationInTable 可为以下 XlLocationInTable 常量之一。
xlRowHeader
xlColumnHeader
xlPageHeader
xlDataHeader
xlRowItem
xlColumnItem
xlPageItem
xlDataItem
xlTableBody

示例

python
#本示例显示一个消息框,用以描述数据透视表中活动单元格所在的位置
def test():
    Worksheets.Item("Sheet1").Activate()
    if Selection.LocationInTable == xlRowHeader:
        print("Active cell is part of a row header")
    elif Selection.LocationInTable == xlColumnHeader:
        print("Active cell is part of a column header")
    elif Selection.LocationInTable == xlPageHeader:
        print("Active cell is part of a page header")
    elif Selection.LocationInTable == xlDataHeader:
        print("Active cell is part of a data header")
    elif Selection.LocationInTable == xlRowItem:
        print("Active cell is part of a row item")
    elif Selection.LocationInTable == xlColumnItem:
        print("Active cell is part of a column item")
    elif Selection.LocationInTable == xlPageItem:
        print("Active cell is part of a page item")
    elif Selection.LocationInTable == xlDataItem:
        print("Active cell is part of a data item")
    elif Selection.LocationInTable == xlTableBody:
        print("Active cell is part of the table body")
python
#本示例判断 A2 单元格是否为数据透视表的正文
def test():
    if Range("A2").LocationInTable == xlTableBody:
        print("A2单元格为数据透视表的正文")