0

To update pivot tables I use uno with this instruction:

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

I would like not to use uno but the basic and its API to recalculate the pivot table of a calc sheet.

How we do that?

patol
  • 136
  • 2
  • 10

1 Answers1

2

Just use the .refresh() method:

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
bad_coder
  • 11,289
  • 20
  • 44
  • 72
JohnSUN
  • 2,268
  • 2
  • 5
  • 12
  • Ok thank you so much JohnSun. I had tested ` oDoc.Calculate` method but it didn’t work! – patol Sep 07 '21 at 14:11