主题
Add (方法)
新建数据透视表公式。
参数
属性 | 数据类型 | 必填 | 说明 |
---|---|---|---|
Formula | str | 必填 | 新的数据透视表公式。 |
UseStandardFormula | Any | 可选 | 标准数据透视表公式。 |
返回值
一个 PivotFormula 对象,它代表新的数据透视表公式。
示例
python
#本示例为第一张工作表的第一张数据透视表添加公式
def test():
Worksheets.Item(1).PivotTables(1).PivotFormulas.Add("公式1=张三*0.9", True)
python
#本示例为活动工作表的数据透视表添加公式,并显示该数据透视表的第二个公式的名称
def test():
pvtFormulas = ActiveSheet.Range("I1").PivotTable.PivotFormulas
pvtFormulas.Add("示例数据=张三+15", True)
print(pvtFormulas.Item(2).Value)