cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jendebett
Regular Visitor

data connection refresh excel with flow

Hello,

 

I have an excel workbook saved in a document library on sharepoint. The excel file contains a table with data from a .txt file.

 

every day a new .txt file is emailed, and I have used flow to save the file in sharpoint.

 

I have the data connection set to refresh in the background, and refresh on opening.

 

so every day I open excel, allow the table to refresh, save and close.

 

i'd really like to have flow do this data refresh without opening excel... is this possible?

48 REPLIES 48
ChristianAbata
Most Valuable Professional
Most Valuable Professional

mmm using defaut PA actions not, but you can use UI flows to make this open excel proces automated.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Website Tutorials: Christian Abata

how do i use flow to open and refresh the data connection on the excel file?

 

I already have the data source (txt file) saving daily automatically

 

now i need to refresh the excel file daily and save.

 

that way when it saves i can have flow email it. is this possible?

ChristianAbata
Most Valuable Professional
Most Valuable Professional

no my friend by using PA you can't open a file. Just with UI 



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Website Tutorials: Christian Abata

is it possible to refresh the data without opening the file? I would prefer to not set up a ui flow so it can still run if im not logged into my computer.

 

i tried this but it doesnt work

 

when a file is created or modified in a folder (this is where the text file is)

list rows present in a table (this is in the excel file)

apply to each> update a row 

 

4-22-2020 4-58-44 PM.jpg

 

 

 

paulburnett224
Advocate I
Advocate I

1) Save the excel xlsx file to one drive or SharePoint and make sure you do not keep a local copy that is syncing. If you are keeping a local copy of the report it will prevent the refresh because it causes a lock: see step 4: https://support.microsoft.com/en-us/office/excel-file-is-locked-for-editing-6fa93887-2c2c-45f0-abcc-...

 

2) in excel online, open the xlsx file recommend going to file\info and protect the sheet. This set the sheet to view mode when opening, as an added precaution.

 

3) in excel online (this only works in online and the file has to be an xlsx and not a xlsm file), click on "Automate" and "code editor."

 

4) put this code in:

 

function main(workbook: ExcelScript.Workbook) {

// Refresh all data connections

let selectedSheet = workbook.getActiveWorksheet();

selectedSheet.refreshAllPivotTables();

}

 

5) make sure you checkmark the "share with others in the workbook" in the script so power automate can see the script.

 

6) in power automate, do the excel online (business), trigger script connector. Select your script and done!

ELEIBLE
Regular Visitor

Hi @paulburnett224 . Couple questions for you. If you have two connection queries, will your code above refresh both queries ? The data from each query is located on its own spreadsheet within the workbook. I added the code using the automate tab and i also allowed the code to be shared so that it's picked up by my flow. Please see my flow attached. When my flow sends me the attached report, the queries within the report still have not been updated. Can you let me know any issues you see or any watch outs i should be concerned with as i'm trying to figure out why it's not refreshing ?

 ThanksMy Flow.png

A few points: 

The documentation on running a script in excel from power automate is here:

https://docs.microsoft.com/en-us/connectors/excelonlinebusiness/#run-script-(preview)

You'll be using an action, not a trigger.

The sample code you provided is to refresh a pivot table  (selectedSheet.refreshAllPivotTables();)

This solution did not work for me, as my data connection is to a source that requires authentication to perform the refresh.

 

Anonymous
Not applicable

S, did you ever solve the issue of refreshing Excel? I have a similar project.

Running above office script manually, refreshes the pivot table and data. But when I am trying to trigger this script from power automate flow, data not getting refreshed. Please suggest if any configurations required or is there any limitations while running the script from power automate.

 

 

echu128
Regular Visitor

I am experiencing the same problem where the script does nothing, even though I recorded the script with macro. Does anyone know if this is a limitation or am I missing something?

Anonymous
Not applicable

anyone with an update on this?

Anonymous
Not applicable

@paulburnett224, thanks for this information. I need something similar. It seems it would only update All Pivot tables from the active worksheet. is there a way to have All Tables in the workbook updated?

eatcrispycreme2
New Member

Same issues here, I'm wanting to automatically update an excel query that's pulling in outside data but can't seem to do it with flow. Anyone have any updates?

driekes
Helper I
Helper I

I have a similar issue. My XL file in the app has updatet data. I close the file, and this syncs with the onedrive client.

When using this  to be sent in an email using a flow, I get non-updated data. 

 

Flow seems to have some sort of in-built limitation where it refers to a historical copy of the file for a certain time period. I recently constructed a flow to update an excel and email the output to our engineers, but when they submitted the form, it would email the previous person's input. 

 

I was able to resolve my issue by, at the start of the flow, creating a new file from a template, inputting the data in that sheet, sending that copy and then deleting the copy at the end of the flow.

 

I'm not sure if this is a possibility in your flow? Prior to figuring that out, I was only able to guarantee it would give the correct output if you set a delay of around 2 mins before emailing the file.

It would be nice to have some statement from MS on this. I have quite a simple flow. Creating new files is not something I want to do, to avoid making things overcomplex. 

 

My excel file refers to another .xlsm file (This file also has external data connections). As you can see in the formula in the picture. When I open this file in Excel Online (It contains a table from which I create a html table to mail around), the external data connections have been disabled. Maybe this could be the reason for my issue. 

I have no idea how to accept external data in that excel file automatically. Could it be a sharepoint setting?

 

When I open this excel online and click 'Enable Content', run my flow, I do get the updated data I want.

 

I just have this .xlsx file that refers to a .xlsm file, because a the .xlsm file does not seem to work in Powerautomate.

 

External data.PNG

The main thing I took from your first message was that the file you were sending was not updated. Was the file in fact updated, but the data being sent was not?

The file is updated in the excel app. It sync's with onedrive (to sharepoint) . When sending the file from the flow (by getting it from sharepoint), it was not updated.

I have to manually open the file in excell online, accept external data connections, run the flow, and then the updated data is mailed around. Look a security setting in Excel online that prevent the file on SP to get updated. I do not get this message in the excel app. I configured trustcentre in the excel app, to renew dataconnections automatically. 

Can you post a picture of your flow?

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (6,419)