Skip to content

Add (方法)

新建数据透视表公式。

参数

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

返回值

一个 PivotFormula 对象,它代表新的数据透视表公式。

示例

javascript
/*本示例为第一张工作表的第一张数据透视表添加公式。*/
function test() {
    Worksheets.Item(1).PivotTables(1).PivotFormulas.Add("公式1=张三*0.9", true)
}
javascript
/*本示例为活动工作表的数据透视表添加公式,并显示该数据透视表的第二个公式的名称。*/
function test() {
    let pvtFormulas = ActiveSheet.Range("I1").PivotTable.PivotFormulas
    pvtFormulas.Add("示例数据=张三+15", true)
    console.log(pvtFormulas.Item(2).Value)
}