使用基本 API 重新计算数据透视表 Table

Recalc Pivot Table with Basic API

要更新枢轴 tables,我将 uno 与此指令一起使用:

dispatcher.executeDispatch(monDocUno, ".uno:RecalcPivotTable", "", 0, Array())

我不想使用 uno,而是使用 basic 及其 API 来重新计算计算 sheet.

的枢轴 table

我们是怎么做到的?

只需使用.refresh()方法:

Sub refreshAllPilotTables
Dim oSheets As Variant
Dim oSheet As Variant
Dim oDataPilotTables As Variant
Dim oPilotTable As Variant
Dim i As Long
Dim j As Long
    oSheets = ThisComponent.getSheets()
    For i = 0 To oSheets.getCount()-1
        oSheet = oSheets.getByIndex(i)
        oDataPilotTables = oSheet.getDataPilotTables()
        For j = 0 To oDataPilotTables.getCount()-1
            oPilotTable = oDataPilotTables.getByIndex(j)
            oPilotTable.refresh()
        Next j
    Next i
End Sub