Forum Discussion
Excel Script - Refresh data
Hi,
I have an excel file which has a data connection. I have been trying to get the data and associated pivot tables to refresh through a script but it doesn't seem to work fully. The script is as follows:
- petraronaldMicrosoft
PDTaylor Currently, pivot table refresh/Power Query refresh is not supported with Office Scripts. If you would like to see this feature in the Office Scripts feature-set, please upvote this request here: Enable Office Scripts to refresh Power Query queries · Community (microsoft.com).
- Klaas LanghoutMicrosoftPetra, any other suggestions for how with PowerAutomate/OfficeScripts to 'refresh' a query and pivot table ? Want to get to use PowerAutomate to send the latest info including a refresh.
- BaronK2230Copper Contributor
This link appears to be broken? petraronald
- DirkvHCopper Contributor
I used your code and it did not work
I did not get an error message but the pivot table just did not refresh
by adding () at the end and it workssample code
function main(workbook: ExcelScript.Workbook) {// Refresh Pivot Tablesworkbook.refreshAllPivotTables()}I know it is a bit late but perhaps someone still has some use for this
😉- Martin_KrygerCopper ContributorThis one works, thank you!
- BaronK2230Copper Contributordoes it work for queries?
It depends on do we speak about Excel desktop or Excel for web.
On desktop workbook.refreshAllDataConnections() works the same way as Refresh All button.
On web only connections to the sources in the same file or anonymous ODate are refreshed. Why so and could it be resolved is in comments to Power Query Refresh is now generally available in Excel for the web (microsoft.com)
- BisioCopper ContributorHi, I am having the same issue. Did you find any solution?