擅长:python、mysql、java
<p>也许已经太迟了,但你可以在xlwings内完成它-这是对我有效的方法:</p>
<pre><code>import xlwings as xw
# open excel App
app_excel = xw.App(visible = False)
# open the excel file, select the tab and the PivotTable to refresh
wbook = xw.Book( 'YourFile.xlsx' )
wbook.sheets['Tab1'].select()
wbook.api.ActiveSheet.PivotTables('PivotTableName').PivotCache().refresh()
</code></pre>