web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / unable to save excel f...
Power Automate
Suggested Answer

unable to save excel file using run Python script execution in power automate

(0) ShareShare
ReportReport
Posted on by 2
I am trying to execute python script using an action of "run python script" . this script will save the file in excel file using .to_excel function:
 
import pandas as pd

data = {'Column1': [1, 2, 3], 'Column2': ['A', 'B', 'C']}
df = pd.DataFrame(data)

output_file_path = "C:\\Scripts\\output_data.xlsx" 
df.to_excel(output_file_path, index=False)
 
 
but not able to save file. can you please help me to find out my error.
note: I have saved the script in file and calling via python executable path and script path
I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2026 Season 1 on at
     
     
    Can you let me know what you are trying to do with excel, so i can help you better.
     
     
     
    Regards,
    Vishnu Reddy
  • SG-28080944-0 Profile Picture
    2 on at
    @VishnuReddy1997 : i want o save the output of python into excel file.
  • Suggested answer
    TN-20081510-0 Profile Picture
    52 on at
    You need to open excel and write to excel with Python code only .Basically you need to do entire operation using Python code itself and then use Power Automate Run python to just invoke the script.
     
    So import Python module like  openpyxl and do  all excel operations using Python code .
     
    Then use PA to just invoke the python script. 
     
    Just pasting some sample code:
    import openpyxl
    wBook = openpyxl.load_workbook('mydata.xlsx')
    sheet = wBook.active
    n = int(input('How many records you want to insert: '))
    for i in range(n):
        name = input(f'{i+1}. Enter name: ')
        age = input(f'{i+1}. Enter age: ')
        enroll = input(f'{i+1}. Enter Enrollment number: ')
        data = [name, age, enroll]
        sheet.append(data)
        wBook.save('mydata.xlsx')
    print('All records inserted successfully !')

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 636

#2
Valantis Profile Picture

Valantis 372

#3
11manish Profile Picture

11manish 335

Last 30 days Overall leaderboard