主题
RowFields (方法)
返回一个对象,该对象表示数据透视表中的单个字段( PivotField 对象),或者当前未显示为行字段的所有字段的一个集合( PivotFields 对象)。只读。
参数
属性 | 数据类型 | 必填 | 说明 |
---|---|---|---|
Index | Any | 可选 | 要返回的字段的名称或编号(可以是指定多个字段的数组)。 |
示例
python
#本示例在新工作表上的清单中添加数据透视表的行字段名称
def test():
nwSheet = Application.Worksheets.Add()
nwSheet.Activate()
pvtTable = Worksheets("Sheet1").Range("F1").PivotTable
rw = 0
for i in range(1, pvtTable.RowFields().Count):
rw = rw + 1
nwSheet.Cells.Item(rw, 1).Value2 = pvtTable.RowFields(i).Name
python
#本示例显示活动工作表中第一张数据透视表的行字段数量
def test():
print(ActiveSheet.PivotTables(1).RowFields().Count)