Skip to content
本页内容

Add (方法)

新建数据透视表公式。

参数

属性数据类型必填说明
Formulastr必填新的数据透视表公式。
UseStandardFormulaAny可选标准数据透视表公式。

返回值

一个 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)