【问题标题】:Recalc Pivot Table with Basic API使用基本 API 重新计算数据透视表
【发布时间】:2021-11-02 22:56:16
【问题描述】:

要更新数据透视表,我使用 uno 和此指令:

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

我不想使用 uno,而是使用 basic 及其 API 来重新计算计算表的数据透视表。

我们如何做到这一点?

【问题讨论】:

    标签: calc libreoffice-basic openoffice-basic


    【解决方案1】:

    只需使用.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
    

    【讨论】:

    • 好的,非常感谢 JohnSun。我已经测试了 oDoc.Calculate 方法,但它不起作用!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-20
    • 1970-01-01
    • 2020-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多